Record Class SummonSpellFieldAnchorEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.SummonSpellFieldAnchorEffect
Record Components:
duration - The LevelBasedValue total lifespan of the anchor entity in ticks.
tickRate - The LevelBasedValue interval in ticks between successive spell field evaluations.
activationDelay - The LevelBasedValue initial delay in ticks before the anchor begins evaluating its spell field.
activePhase - The LevelBasedValue duration in ticks of each active pulsing window (or <= 0 for continuous).
restPhase - The LevelBasedValue duration in ticks of each dormant rest window between active phases.
spellField - The SpellFieldComponent executed by the anchor on each active tick.
visualConfig - Optional AnchorVisualConfig controlling billboard sprite or custom 3D model rendering for the anchor.
useOrigin - If true, spawns the anchor at the trigger's origin vector; if false, spawns at target.position().
All Implemented Interfaces:
net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

public record SummonSpellFieldAnchorEffect(net.minecraft.world.item.enchantment.LevelBasedValue duration, net.minecraft.world.item.enchantment.LevelBasedValue tickRate, net.minecraft.world.item.enchantment.LevelBasedValue activationDelay, net.minecraft.world.item.enchantment.LevelBasedValue activePhase, net.minecraft.world.item.enchantment.LevelBasedValue restPhase, SpellFieldComponent spellField, Optional<AnchorVisualConfig> visualConfig, boolean useOrigin) extends Record implements net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
An EnchantmentEntityEffect that spawns a persistent SpellFieldAnchorEntity in the world to repeatedly or delayedly evaluate an embedded SpellFieldComponent over time.
  • Field Details

    • DURATION

      public static final String DURATION
      JSON field key for the anchor lifespan in ticks.
      See Also:
    • TICK_RATE

      public static final String TICK_RATE
      JSON field key for the evaluation tick interval.
      See Also:
    • ACTIVATION_DELAY

      public static final String ACTIVATION_DELAY
      JSON field key for the initial activation delay in ticks.
      See Also:
    • ACTIVE_PHASE

      public static final String ACTIVE_PHASE
      JSON field key for the active duty-cycle window in ticks.
      See Also:
    • REST_PHASE

      public static final String REST_PHASE
      JSON field key for the dormant rest window in ticks.
      See Also:
    • SPELL_FIELD

      public static final String SPELL_FIELD
      JSON field key for the nested spell field component definition.
      See Also:
    • VISUAL_CONFIG

      public static final String VISUAL_CONFIG
      JSON field key for the optional client visual configuration.
      See Also:
    • USE_ORIGIN

      public static final String USE_ORIGIN
      JSON field key for spawning at the trigger origin instead of the target entity position.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this enchantment 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<SummonSpellFieldAnchorEffect> CODEC
      MapCodec for serializing and deserializing SummonSpellFieldAnchorEffect instances from JSON.
  • Constructor Details

    • SummonSpellFieldAnchorEffect

      public SummonSpellFieldAnchorEffect()
      Constructs a default SummonSpellFieldAnchorEffect with a 1-tick duration, 1-tick rate, no delays, and an empty SpellFieldComponent.
    • SummonSpellFieldAnchorEffect

      public SummonSpellFieldAnchorEffect(net.minecraft.world.item.enchantment.LevelBasedValue duration, net.minecraft.world.item.enchantment.LevelBasedValue tickRate, net.minecraft.world.item.enchantment.LevelBasedValue activationDelay, net.minecraft.world.item.enchantment.LevelBasedValue activePhase, net.minecraft.world.item.enchantment.LevelBasedValue restPhase, SpellFieldComponent spellField, Optional<AnchorVisualConfig> visualConfig, boolean useOrigin)
      Creates an instance of a SummonSpellFieldAnchorEffect record class.
      Parameters:
      duration - the value for the duration record component
      tickRate - the value for the tickRate record component
      activationDelay - the value for the activationDelay record component
      activePhase - the value for the activePhase record component
      restPhase - the value for the restPhase record component
      spellField - the value for the spellField record component
      visualConfig - the value for the visualConfig record component
      useOrigin - the value for the useOrigin 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 target, net.minecraft.world.phys.Vec3 origin)
      Instantiates, configures, and spawns a SpellFieldAnchorEntity in the server level, inheriting the yaw and pitch orientation of context.owner() (or target if no owner is present).
      Specified by:
      apply in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Parameters:
      level - The server level in which the anchor is spawned.
      enchantmentLevel - The active level of the source enchantment.
      context - The context of the enchanted item in use.
      target - The target entity at which the effect was triggered.
      origin - The origin coordinate vector of the trigger.
    • codec

      public com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect> codec()
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
    • withDuration

      public SummonSpellFieldAnchorEffect withDuration(net.minecraft.world.item.enchantment.LevelBasedValue duration)
      Returns a copy of this effect with the specified anchor lifespan duration.
      Parameters:
      duration - The new LevelBasedValue duration in ticks.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withTickRate

      public SummonSpellFieldAnchorEffect withTickRate(net.minecraft.world.item.enchantment.LevelBasedValue tickRate)
      Returns a copy of this effect with the specified evaluation tick interval.
      Parameters:
      tickRate - The new LevelBasedValue tick rate.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withActivationDelay

      public SummonSpellFieldAnchorEffect withActivationDelay(net.minecraft.world.item.enchantment.LevelBasedValue activationDelay)
      Returns a copy of this effect with the specified initial activation delay.
      Parameters:
      activationDelay - The new LevelBasedValue activation delay in ticks.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withActivePhase

      public SummonSpellFieldAnchorEffect withActivePhase(net.minecraft.world.item.enchantment.LevelBasedValue activePhase)
      Returns a copy of this effect with the specified active phase duration.
      Parameters:
      activePhase - The new LevelBasedValue active phase window in ticks.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withRestPhase

      public SummonSpellFieldAnchorEffect withRestPhase(net.minecraft.world.item.enchantment.LevelBasedValue restPhase)
      Returns a copy of this effect with the specified dormant rest phase duration.
      Parameters:
      restPhase - The new LevelBasedValue rest phase window in ticks.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withSpellFieldComponent

      public SummonSpellFieldAnchorEffect withSpellFieldComponent(SpellFieldComponent spellField)
      Returns a copy of this effect with the specified SpellFieldComponent payload.
      Parameters:
      spellField - The SpellFieldComponent to evaluate.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withVisualConfig

      public SummonSpellFieldAnchorEffect withVisualConfig(AnchorVisualConfig visualConfig)
      Returns a copy of this effect with the specified client visual configuration.
      Parameters:
      visualConfig - The AnchorVisualConfig to attach.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • withUseOrigin

      public SummonSpellFieldAnchorEffect withUseOrigin(boolean useOrigin)
      Returns a copy of this effect configured to spawn at either the trigger origin or the target entity's position.
      Parameters:
      useOrigin - true to use the trigger origin coordinate, false to use the target's position.
      Returns:
      A new SummonSpellFieldAnchorEffect instance.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • duration

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

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

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

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

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

      public SpellFieldComponent spellField()
      Returns the value of the spellField record component.
      Returns:
      the value of the spellField record component
    • visualConfig

      public Optional<AnchorVisualConfig> visualConfig()
      Returns the value of the visualConfig record component.
      Returns:
      the value of the visualConfig record component
    • useOrigin

      public boolean useOrigin()
      Returns the value of the useOrigin record component.
      Returns:
      the value of the useOrigin record component