Record Class LightningStrikeEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.volume.LightningStrikeEffect
- Record Components:
count- TheLevelBasedValuenumber of lightning bolts to strike (supports fractional probabilistic rounding).delayTicks- TheLevelBasedValuebase delay in ticks before each lightning bolt strikes.delayVariance- TheLevelBasedValuerandom +/- tick jitter applied to each strike's delay.visualOnly- Whether the spawned lightning bolts are purely visual (LightningBolt.setVisualOnly(boolean)) without dealing damage or starting fires.distribution- OptionalProbabilityDistributionused to sample strike coordinates when evaluated as a volume effect.entityFilter- OptionalLootItemConditionrestricting which entities are struck when evaluated as an entity effect.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect, SpellFieldVolumeEffect
public record LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter)
extends Record
implements SpellFieldEntityEffect, SpellFieldVolumeEffect
Dual-purpose spell field effect implementing both
SpellFieldEntityEffect and
SpellFieldVolumeEffect that schedules one or more LightningBolt strikes at
targeted entities or sampled volume coordinates.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<LightningStrikeEffect> MapCodec for serializing and deserializingLightningStrikeEffectinstances from JSON.static final StringJSON field key for the lightning strike count.static final StringJSON field key for the base strike delay in ticks.static final StringJSON field key for the random delay variance in ticks.static final StringJSON field key for the optional spatial probability distribution.static final StringJSON field key for the optional entity filter predicate.static final StringRegistry path identifier for this spell field effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for toggling visual-only lightning bolts. -
Constructor Summary
ConstructorsConstructorDescriptionLightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly) Constructs an unfilteredLightningStrikeEffectwith uniform volume sampling.LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aLightningStrikeEffectrecord class.LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, ProbabilityDistribution distribution) Constructs an unfilteredLightningStrikeEffectwith a custom spatialProbabilityDistribution.LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, ProbabilityDistribution distribution, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aLightningStrikeEffectwith both a customProbabilityDistributionand an entity filter.LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aLightningStrikeEffectrestricted by an 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, List<GlobalVolume> volumes) Samples a target coordinate acrossvolumesusingdistribution()(or uniform sampling if absent) and schedules the configured number of lightning strikes at that location.voidapply(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) Schedules lightning strikes atvictim's position with the strike count scaled byvolumeScalarif the entity matchesentityFilter().com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.net.minecraft.world.item.enchantment.LevelBasedValuecount()Returns the value of thecountrecord component.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of thedelayTicksrecord component.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of thedelayVariancerecord component.Returns the value of thedistributionrecord component.Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> Returns the value of theentityFilterrecord 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.booleanReturns the value of thevisualOnlyrecord component.
-
Field Details
-
COUNT
-
DELAY_TICKS
-
DELAY_VARIANCE
JSON field key for the random delay variance in ticks.- See Also:
-
VISUAL_ONLY
JSON field key for toggling visual-only lightning bolts.- See Also:
-
DISTRIBUTION
JSON field key for the optional spatial probability distribution.- See Also:
-
ENTITY_FILTER
JSON field key for the optional entity filter predicate.- See Also:
-
KEY
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingLightningStrikeEffectinstances from JSON.
-
-
Constructor Details
-
LightningStrikeEffect
public LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly) Constructs an unfilteredLightningStrikeEffectwith uniform volume sampling.- Parameters:
count- The number of lightning strikes.delayTicks- The base delay in ticks.delayVariance- The random delay variance in ticks.visualOnly- Whether the lightning bolts are visual-only.
-
LightningStrikeEffect
public LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, ProbabilityDistribution distribution) Constructs an unfilteredLightningStrikeEffectwith a custom spatialProbabilityDistribution.- Parameters:
count- The number of lightning strikes.delayTicks- The base delay in ticks.delayVariance- The random delay variance in ticks.visualOnly- Whether the lightning bolts are visual-only.distribution- The spatial probability distribution for volume sampling.
-
LightningStrikeEffect
public LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aLightningStrikeEffectrestricted by an entity predicate filter.- Parameters:
count- The number of lightning strikes.delayTicks- The base delay in ticks.delayVariance- The random delay variance in ticks.visualOnly- Whether the lightning bolts are visual-only.entityFilter- The predicate filter to match against candidate entities.
-
LightningStrikeEffect
public LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, ProbabilityDistribution distribution, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aLightningStrikeEffectwith both a customProbabilityDistributionand an entity filter.- Parameters:
count- The number of lightning strikes.delayTicks- The base delay in ticks.delayVariance- The random delay variance in ticks.visualOnly- Whether the lightning bolts are visual-only.distribution- The spatial probability distribution for volume sampling.entityFilter- The predicate filter to match against candidate entities.
-
LightningStrikeEffect
public LightningStrikeEffect(net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue delayTicks, net.minecraft.world.item.enchantment.LevelBasedValue delayVariance, boolean visualOnly, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aLightningStrikeEffectrecord class.- Parameters:
count- the value for thecountrecord componentdelayTicks- the value for thedelayTicksrecord componentdelayVariance- the value for thedelayVariancerecord componentvisualOnly- the value for thevisualOnlyrecord componentdistribution- the value for thedistributionrecord 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) Schedules lightning strikes atvictim's position with the strike count scaled byvolumeScalarif the entity matchesentityFilter().- 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.
-
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, List<GlobalVolume> volumes) Samples a target coordinate acrossvolumesusingdistribution()(or uniform sampling if absent) and schedules the configured number of lightning strikes at that location.- Specified by:
applyin interfaceSpellFieldVolumeEffect- 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.volumes- The list of evaluated world-spaceGlobalVolumes defining the spell field geometry.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
count
-
delayTicks
public net.minecraft.world.item.enchantment.LevelBasedValue delayTicks()Returns the value of thedelayTicksrecord component.- Returns:
- the value of the
delayTicksrecord component
-
delayVariance
public net.minecraft.world.item.enchantment.LevelBasedValue delayVariance()Returns the value of thedelayVariancerecord component.- Returns:
- the value of the
delayVariancerecord component
-
visualOnly
public boolean visualOnly()Returns the value of thevisualOnlyrecord component.- Returns:
- the value of the
visualOnlyrecord component
-
distribution
Returns the value of thedistributionrecord component.- Returns:
- the value of the
distributionrecord component
-
entityFilter
public Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter()Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-