java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.ImpulseEffect
Record Components:
strength - The LevelBasedValue peak impulse magnitude (positive pushes along the axis; negative pulls against it).
direction - Optional FieldAxis dictating the impulse vector geometry (defaults to FieldAxis.RADIAL).
entityFilter - Optional ContextAwarePredicate restricting 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.criterion.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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<ImpulseEffect>
    MapCodec for serializing and deserializing ImpulseEffect instances from JSON.
    static final String
    JSON field key for the directional field axis.
    static final String
    JSON field key for the optional entity filter predicate.
    static final String
    Registry path identifier for this spell field entity effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the impulse force magnitude.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength)
    Constructs an unfiltered radial ImpulseEffect.
    ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, Optional<FieldAxis> direction, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
    Creates an instance of a ImpulseEffect record class.
    ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction)
    Constructs an unfiltered ImpulseEffect along the specified FieldAxis.
    ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
    Constructs an ImpulseEffect along the specified FieldAxis and restricted by an entity filter.
    ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
    Constructs a radial ImpulseEffect restricted by the given entity predicate filter.
  • Method Summary

    Modifier and Type
    Method
    Description
    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 from direction() (or FieldAxis.RADIAL), scales it by $\text{strength} \cdot \text{volumeScalar}$, adds a small vertical friction-overcoming bump for grounded horizontal impulses, and updates victim's velocity.
    com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    Returns the value of the direction record component.
    Optional<net.minecraft.advancements.criterion.ContextAwarePredicate>
    Returns the value of the entityFilter record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Retrieves the active FieldAxis along which this effect operates.
    final int
    Returns a hash code value for this object.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the strength record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • STRENGTH

      public static final String STRENGTH
      JSON field key for the impulse force magnitude.
      See Also:
    • DIRECTION

      public static final String DIRECTION
      JSON field key for the directional field axis.
      See Also:
    • ENTITY_FILTER

      public static final String ENTITY_FILTER
      JSON field key for the optional entity filter predicate.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this spell field entity effect.
      See Also:
    • KEY_PROVIDER

      public static final LevelBasedKeyProvider KEY_PROVIDER
      Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    • CODEC

      public static final com.mojang.serialization.MapCodec<ImpulseEffect> CODEC
      MapCodec for serializing and deserializing ImpulseEffect instances from JSON.
  • Constructor Details

    • ImpulseEffect

      public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength)
      Constructs an unfiltered radial ImpulseEffect.
      Parameters:
      strength - The LevelBasedValue impulse strength.
    • ImpulseEffect

      public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, FieldAxis direction)
      Constructs an unfiltered ImpulseEffect along the specified FieldAxis.
      Parameters:
      strength - The LevelBasedValue impulse strength.
      direction - The FieldAxis direction.
    • ImpulseEffect

      public ImpulseEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
      Constructs a radial ImpulseEffect restricted by the given entity predicate filter.
      Parameters:
      strength - The LevelBasedValue impulse 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.criterion.ContextAwarePredicate entityFilter)
      Constructs an ImpulseEffect along the specified FieldAxis and restricted by an entity filter.
      Parameters:
      strength - The LevelBasedValue impulse strength.
      direction - The FieldAxis direction.
      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.criterion.ContextAwarePredicate> entityFilter)
      Creates an instance of a ImpulseEffect record class.
      Parameters:
      strength - the value for the strength record component
      direction - the value for the direction record component
      entityFilter - the value for the entityFilter record 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 from direction() (or FieldAxis.RADIAL), scales it by $\text{strength} \cdot \text{volumeScalar}$, adds a small vertical friction-overcoming bump for grounded horizontal impulses, and updates victim's velocity.
      Specified by:
      apply in interface SpellFieldEntityEffect
      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 for victim.
    • codec

      public com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()
      Description copied from interface: SpellFieldEffect
      Retrieves the MapCodec responsible for serializing and deserializing this effect.
      Specified by:
      codec in interface SpellFieldEffect
      Returns:
      The registered MapCodec instance.
    • getActiveAxis

      public Optional<FieldAxis> getActiveAxis()
      Description copied from interface: DirectionalSpellFieldEffect
      Retrieves the active FieldAxis along which this effect operates.
      Specified by:
      getActiveAxis in interface DirectionalSpellFieldEffect
      Returns:
      An Optional containing the configured FieldAxis, or empty if no directional axis is active.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • strength

      public net.minecraft.world.item.enchantment.LevelBasedValue strength()
      Returns the value of the strength record component.
      Returns:
      the value of the strength record component
    • direction

      public Optional<FieldAxis> direction()
      Returns the value of the direction record component.
      Returns:
      the value of the direction record component
    • entityFilter

      public Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter()
      Returns the value of the entityFilter record component.
      Returns:
      the value of the entityFilter record component