Record Class LightningStrikeEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.volume.LightningStrikeEffect
Record Components:
count - The LevelBasedValue number of lightning bolts to strike (supports fractional probabilistic rounding).
delayTicks - The LevelBasedValue base delay in ticks before each lightning bolt strikes.
delayVariance - The LevelBasedValue random +/- 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 - Optional ProbabilityDistribution used to sample strike coordinates when evaluated as a volume effect.
entityFilter - Optional LootItemCondition restricting 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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<LightningStrikeEffect>
    MapCodec for serializing and deserializing LightningStrikeEffect instances from JSON.
    static final String
    JSON field key for the lightning strike count.
    static final String
    JSON field key for the base strike delay in ticks.
    static final String
    JSON field key for the random delay variance in ticks.
    static final String
    JSON field key for the optional spatial probability distribution.
    static final String
    JSON field key for the optional entity filter predicate.
    static final String
    Registry path identifier for this spell field effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for toggling visual-only lightning bolts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 unfiltered LightningStrikeEffect with 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 a LightningStrikeEffect record 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 unfiltered LightningStrikeEffect with a custom spatial ProbabilityDistribution.
    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 a LightningStrikeEffect with both a custom ProbabilityDistribution and 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 a LightningStrikeEffect restricted by an 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, List<GlobalVolume> volumes)
    Samples a target coordinate across volumes using distribution() (or uniform sampling if absent) and schedules the configured number of lightning strikes at that location.
    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 at victim's position with the strike count scaled by volumeScalar if the entity matches entityFilter().
    com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the count record component.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the delayTicks record component.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the delayVariance record component.
    Returns the value of the distribution record component.
    Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>>
    Returns the value of the entityFilter record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.
    boolean
    Returns the value of the visualOnly record component.

    Methods inherited from class Object

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

    • COUNT

      public static final String COUNT
      JSON field key for the lightning strike count.
      See Also:
    • DELAY_TICKS

      public static final String DELAY_TICKS
      JSON field key for the base strike delay in ticks.
      See Also:
    • DELAY_VARIANCE

      public static final String DELAY_VARIANCE
      JSON field key for the random delay variance in ticks.
      See Also:
    • VISUAL_ONLY

      public static final String VISUAL_ONLY
      JSON field key for toggling visual-only lightning bolts.
      See Also:
    • DISTRIBUTION

      public static final String DISTRIBUTION
      JSON field key for the optional spatial probability distribution.
      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 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<LightningStrikeEffect> CODEC
      MapCodec for serializing and deserializing LightningStrikeEffect instances 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 unfiltered LightningStrikeEffect with 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 unfiltered LightningStrikeEffect with a custom spatial ProbabilityDistribution.
      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 a LightningStrikeEffect restricted 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 a LightningStrikeEffect with both a custom ProbabilityDistribution and 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 a LightningStrikeEffect record class.
      Parameters:
      count - the value for the count record component
      delayTicks - the value for the delayTicks record component
      delayVariance - the value for the delayVariance record component
      visualOnly - the value for the visualOnly record component
      distribution - the value for the distribution 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)
      Schedules lightning strikes at victim's position with the strike count scaled by volumeScalar if the entity matches entityFilter().
      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.
    • 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 across volumes using distribution() (or uniform sampling if absent) and schedules the configured number of lightning strikes at that location.
      Specified by:
      apply in interface SpellFieldVolumeEffect
      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-space GlobalVolumes defining the spell field geometry.
    • 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.
    • 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.
    • count

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

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

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

      public boolean visualOnly()
      Returns the value of the visualOnly record component.
      Returns:
      the value of the visualOnly record component
    • distribution

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

      public Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter()
      Returns the value of the entityFilter record component.
      Returns:
      the value of the entityFilter record component