Record Class SpellFieldComponent

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent
Record Components:
volumes - The list of geometric volumes and topological falloffs defining the spell field.
entityEffects - Effects applied to individual entities intersecting the evaluated volumes.
blockEffects - Effects applied to individual block coordinates within the evaluated volumes.
volumeEffects - Effects evaluated globally across the entire composite volume geometry.
visualEffects - Particle and visual effects rendered across the volume geometry.
All Implemented Interfaces:
net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

public record SpellFieldComponent(List<SpellFieldVolume> volumes, List<SpellFieldEntityEffect> entityEffects, List<SpellFieldBlockEffect> blockEffects, List<SpellFieldVolumeEffect> volumeEffects, List<SpellFieldVisualEffect> visualEffects) extends Record implements net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
Core EnchantmentEntityEffect component responsible for evaluating spatial volumes, topological distance falloff curves, and dispatching entity, block, volume, and visual spell field effects.
  • Field Details

    • VOLUMES

      public static final String VOLUMES
      JSON field key for the list of spatial volumes.
      See Also:
    • ENTITY_EFFECTS

      public static final String ENTITY_EFFECTS
      JSON field key for the list of entity-targeted spell field effects.
      See Also:
    • BLOCK_EFFECTS

      public static final String BLOCK_EFFECTS
      JSON field key for the list of block-targeted spell field effects.
      See Also:
    • VOLUME_EFFECTS

      public static final String VOLUME_EFFECTS
      JSON field key for the list of volume-wide spell field effects.
      See Also:
    • VISUAL_EFFECTS

      public static final String VISUAL_EFFECTS
      JSON field key for the list of visual/particle spell field effects.
      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 dynamic data transformation.
    • CODEC

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

  • 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)
      Evaluates all configured volumes and dispatches entity, block, volume, and visual effects.

      When collecting and executing block effects, coordinates residing in chunks that are not actively ticking blocks (Level.shouldTickBlocksAt(BlockPos) is false) are skipped. This prevents spell fields that straddle chunk boundaries from synchronously force-loading unloaded chunks or placing transient blocks into non-ticking border chunks.

      Specified by:
      apply in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Parameters:
      level - The executing server level.
      enchantmentLevel - The level of the spell field enchantment.
      context - The item usage context triggering the spell field.
      target - The anchor entity or focal point of the spell field.
      origin - The origin position vector passed by the enchantment 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
    • builder

      public static SpellFieldComponent.Builder builder()
      Creates a new fluent SpellFieldComponent.Builder for constructing a SpellFieldComponent.
      Returns:
      A new SpellFieldComponent.Builder 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. 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.
    • volumes

      public List<SpellFieldVolume> volumes()
      Returns the value of the volumes record component.
      Returns:
      the value of the volumes record component
    • entityEffects

      public List<SpellFieldEntityEffect> entityEffects()
      Returns the value of the entityEffects record component.
      Returns:
      the value of the entityEffects record component
    • blockEffects

      public List<SpellFieldBlockEffect> blockEffects()
      Returns the value of the blockEffects record component.
      Returns:
      the value of the blockEffects record component
    • volumeEffects

      public List<SpellFieldVolumeEffect> volumeEffects()
      Returns the value of the volumeEffects record component.
      Returns:
      the value of the volumeEffects record component
    • visualEffects

      public List<SpellFieldVisualEffect> visualEffects()
      Returns the value of the visualEffects record component.
      Returns:
      the value of the visualEffects record component