Record Class ImpulseEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.ImpulseEffect
- Record Components:
strength- TheLevelBasedValuepeak impulse magnitude (positive pushes along the axis; negative pulls against it).direction- OptionalFieldAxisdictating the impulse vector geometry (defaults toFieldAxis.RADIAL).entityFilter- OptionalContextAwarePredicaterestricting which entities receive the impulse.
- All Implemented Interfaces:
DirectionalSpellFieldEffect, SpellFieldEffect, SpellFieldEntityEffect
public record ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, Optional<FieldAxis> direction, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect, DirectionalSpellFieldEffect
A directional
SpellFieldEntityEffect that applies a kinetic velocity impulse to targeted
entities along a configured FieldAxis (defaulting to FieldAxis.RADIAL), scaled by
each entity's local topological multiplier.
Implements DirectionalSpellFieldEffect to expose its active axis to visual particle fields
and the client-side spell field debug renderer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ImpulseEffect> MapCodec for serializing and deserializingImpulseEffectinstances from JSON.static final StringJSON field key for the directional field axis.static final StringJSON field key for the optional entity filter predicate.static final StringRegistry path identifier for this spell field entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for the impulse force magnitude. -
Constructor Summary
ConstructorsConstructorDescriptionImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength) Constructs an unfiltered radialImpulseEffect.ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, Optional<FieldAxis> direction, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) Creates an instance of aImpulseEffectrecord class.ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction) Constructs an unfilteredImpulseEffectalong the specifiedFieldAxis.ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs anImpulseEffectalong the specifiedFieldAxisand restricted by an entity filter.ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs a radialImpulseEffectrestricted by the given entity predicate filter. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Computes the directional unit vector fromdirection()(orFieldAxis.RADIAL), scales it by $\text{strength} \cdot \text{volumeScalar}$, adds a small vertical friction-overcoming bump for grounded horizontal impulses, and updatesvictim's velocity.com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.Returns the value of thedirectionrecord component.Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> Returns the value of theentityFilterrecord component.final booleanIndicates whether some other object is "equal to" this one.Retrieves the activeFieldAxisalong which this effect operates.final inthashCode()Returns a hash code value for this object.net.minecraft.world.item.enchantment.LevelBasedValuestrength()Returns the value of thestrengthrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
STRENGTH
-
DIRECTION
-
ENTITY_FILTER
JSON field key for the optional entity filter predicate.- See Also:
-
KEY
Registry path identifier for this spell field entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingImpulseEffectinstances from JSON.
-
-
Constructor Details
-
ImpulseEffect
public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength) Constructs an unfiltered radialImpulseEffect.- Parameters:
strength- TheLevelBasedValueimpulse strength.
-
ImpulseEffect
public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction) Constructs an unfilteredImpulseEffectalong the specifiedFieldAxis.- Parameters:
strength- TheLevelBasedValueimpulse strength.direction- TheFieldAxisdirection.
-
ImpulseEffect
public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs a radialImpulseEffectrestricted by the given entity predicate filter.- Parameters:
strength- TheLevelBasedValueimpulse strength.entityFilter- The predicate filter to match against candidate entities.
-
ImpulseEffect
public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs anImpulseEffectalong the specifiedFieldAxisand restricted by an entity filter.- Parameters:
strength- TheLevelBasedValueimpulse strength.direction- TheFieldAxisdirection.entityFilter- The predicate filter to match against candidate entities.
-
ImpulseEffect
public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, Optional<FieldAxis> direction, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) Creates an instance of aImpulseEffectrecord class.- Parameters:
strength- the value for thestrengthrecord componentdirection- the value for thedirectionrecord componententityFilter- the value for theentityFilterrecord component
-
-
Method Details
-
apply
public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Computes the directional unit vector fromdirection()(orFieldAxis.RADIAL), scales it by $\text{strength} \cdot \text{volumeScalar}$, adds a small vertical friction-overcoming bump for grounded horizontal impulses, and updatesvictim's velocity.- Specified by:
applyin interfaceSpellFieldEntityEffect- Parameters:
level- The executing server level.enchantmentLevel- The active level of the spell field enchantment.context- The item usage context triggering the spell field.spatialReference- The anchor entity or focal point of the spell field.epicenter- The exact spatial origin vector of the spell field.victim- The target entity intersecting the spell field.volumeScalar- The active topological multiplier forvictim.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
getActiveAxis
Description copied from interface:DirectionalSpellFieldEffectRetrieves the activeFieldAxisalong which this effect operates.- Specified by:
getActiveAxisin interfaceDirectionalSpellFieldEffect- Returns:
- An
Optionalcontaining the configuredFieldAxis, or empty if no directional axis is active.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
strength
-
direction
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-