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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder for assembling aSpellFieldComponentprogrammatically. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the list of block-targeted spell field effects.static final com.mojang.serialization.MapCodec<SpellFieldComponent> MapCodec for serializing and deserializingSpellFieldComponentinstances from JSON or NBT.static final StringJSON field key for the list of entity-targeted spell field effects.static final StringRegistry path identifier for this enchantment entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for dynamic data transformation.static final StringJSON field key for the list of visual/particle spell field effects.static final StringJSON field key for the list of volume-wide spell field effects.static final StringJSON field key for the list of spatial volumes. -
Constructor Summary
ConstructorsConstructorDescriptionSpellFieldComponent(List<SpellFieldVolume> volumes, List<SpellFieldEntityEffect> entityEffects, List<SpellFieldBlockEffect> blockEffects, List<SpellFieldVolumeEffect> volumeEffects, List<SpellFieldVisualEffect> visualEffects) Creates an instance of aSpellFieldComponentrecord class. -
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 target, net.minecraft.world.phys.Vec3 origin) Evaluates all configured volumes and dispatches entity, block, volume, and visual effects.Returns the value of theblockEffectsrecord component.static SpellFieldComponent.Builderbuilder()Creates a new fluentSpellFieldComponent.Builderfor constructing aSpellFieldComponent.com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect> codec()Returns the value of theentityEffectsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.Returns the value of thevisualEffectsrecord component.Returns the value of thevolumeEffectsrecord component.volumes()Returns the value of thevolumesrecord component.Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
onChangedBlockMethods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
onDeactivated
-
Field Details
-
VOLUMES
-
ENTITY_EFFECTS
JSON field key for the list of entity-targeted spell field effects.- See Also:
-
BLOCK_EFFECTS
JSON field key for the list of block-targeted spell field effects.- See Also:
-
VOLUME_EFFECTS
JSON field key for the list of volume-wide spell field effects.- See Also:
-
VISUAL_EFFECTS
JSON field key for the list of visual/particle spell field effects.- See Also:
-
KEY
Registry path identifier for this enchantment entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for dynamic data transformation. -
CODEC
MapCodec for serializing and deserializingSpellFieldComponentinstances from JSON or NBT.
-
-
Constructor Details
-
SpellFieldComponent
public SpellFieldComponent(List<SpellFieldVolume> volumes, List<SpellFieldEntityEffect> entityEffects, List<SpellFieldBlockEffect> blockEffects, List<SpellFieldVolumeEffect> volumeEffects, List<SpellFieldVisualEffect> visualEffects) Creates an instance of aSpellFieldComponentrecord class.- Parameters:
volumes- the value for thevolumesrecord componententityEffects- the value for theentityEffectsrecord componentblockEffects- the value for theblockEffectsrecord componentvolumeEffects- the value for thevolumeEffectsrecord componentvisualEffects- the value for thevisualEffectsrecord 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) 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)isfalse) 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:
applyin interfacenet.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:
codecin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect- Specified by:
codecin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
-
builder
Creates a new fluentSpellFieldComponent.Builderfor constructing aSpellFieldComponent.- Returns:
- A new
SpellFieldComponent.Builderinstance.
-
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). -
volumes
-
entityEffects
Returns the value of theentityEffectsrecord component.- Returns:
- the value of the
entityEffectsrecord component
-
blockEffects
Returns the value of theblockEffectsrecord component.- Returns:
- the value of the
blockEffectsrecord component
-
volumeEffects
Returns the value of thevolumeEffectsrecord component.- Returns:
- the value of the
volumeEffectsrecord component
-
visualEffects
Returns the value of thevisualEffectsrecord component.- Returns:
- the value of the
visualEffectsrecord component
-