Record Class SurfaceHazardEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.volume.SurfaceHazardEffect
Record Components:
entityType - The hazard EntityType to instantiate and place on the surface.
count - The LevelBasedValue number of surface hazards spawned when evaluated as a volume effect.
verticalSearch - The LevelBasedValue vertical half-range (in blocks above and below the target point) searched for a solid surface.
distribution - Optional ProbabilityDistribution used to sample horizontal/vertical starting coordinates when evaluated as a volume effect.
entityFilter - Optional ContextAwarePredicate restricting which entities trigger hazards when evaluated as an entity effect.
All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect, SpellFieldVolumeEffect

public record SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter) extends Record implements SpellFieldEntityEffect, SpellFieldVolumeEffect
Dual-purpose spell field effect implementing both SpellFieldEntityEffect and SpellFieldVolumeEffect that scans vertically downward from a target or sampled coordinate to locate the nearest solid ground surface and spawns a hazard entity (such as EvokerFangs) directly atop that block.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<SurfaceHazardEffect>
    MapCodec for serializing and deserializing SurfaceHazardEffect instances from JSON.
    static final String
    JSON field key for the volume hazard count.
    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
    JSON field key for the hazard entity type identifier.
    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 the vertical ground search range in blocks.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch)
    Constructs an unfiltered SurfaceHazardEffect with uniform volume sampling.
    SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
    Creates an instance of a SurfaceHazardEffect record class.
    SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, ProbabilityDistribution distribution)
    Constructs an unfiltered SurfaceHazardEffect with a custom spatial ProbabilityDistribution.
    SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, ProbabilityDistribution distribution, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
    Constructs a SurfaceHazardEffect with both a custom ProbabilityDistribution and an entity filter.
    SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
    Constructs a SurfaceHazardEffect 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 count() points across volumes using distribution() (or uniform sampling if absent) and spawns a surface hazard on the ground below each sampled point.
    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)
    Searches vertically around victim's position and spawns a surface hazard beneath the entity if it 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.
    Returns the value of the distribution record component.
    Optional<net.minecraft.advancements.criterion.ContextAwarePredicate>
    Returns the value of the entityFilter record component.
    net.minecraft.world.entity.EntityType<?>
    Returns the value of the entityType 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.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the verticalSearch record component.

    Methods inherited from class java.lang.Object

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

    • ENTITY_TYPE

      public static final String ENTITY_TYPE
      JSON field key for the hazard entity type identifier.
      See Also:
    • COUNT

      public static final String COUNT
      JSON field key for the volume hazard count.
      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<SurfaceHazardEffect> CODEC
      MapCodec for serializing and deserializing SurfaceHazardEffect instances from JSON.
  • Constructor Details

    • SurfaceHazardEffect

      public SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch)
      Constructs an unfiltered SurfaceHazardEffect with uniform volume sampling.
      Parameters:
      entityType - The hazard EntityType to spawn.
      count - The number of volume hazards to spawn.
      verticalSearch - The vertical search radius in blocks.
    • SurfaceHazardEffect

      public SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, ProbabilityDistribution distribution)
      Constructs an unfiltered SurfaceHazardEffect with a custom spatial ProbabilityDistribution.
      Parameters:
      entityType - The hazard EntityType to spawn.
      count - The number of volume hazards to spawn.
      verticalSearch - The vertical search radius in blocks.
      distribution - The spatial probability distribution for volume sampling.
    • SurfaceHazardEffect

      public SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
      Constructs a SurfaceHazardEffect restricted by an entity predicate filter.
      Parameters:
      entityType - The hazard EntityType to spawn.
      count - The number of volume hazards to spawn.
      verticalSearch - The vertical search radius in blocks.
      entityFilter - The predicate filter to match against candidate entities.
    • SurfaceHazardEffect

      public SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, ProbabilityDistribution distribution, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
      Constructs a SurfaceHazardEffect with both a custom ProbabilityDistribution and an entity filter.
      Parameters:
      entityType - The hazard EntityType to spawn.
      count - The number of volume hazards to spawn.
      verticalSearch - The vertical search radius in blocks.
      distribution - The spatial probability distribution for volume sampling.
      entityFilter - The predicate filter to match against candidate entities.
    • SurfaceHazardEffect

      public SurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
      Creates an instance of a SurfaceHazardEffect record class.
      Parameters:
      entityType - the value for the entityType record component
      count - the value for the count record component
      verticalSearch - the value for the verticalSearch 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)
      Searches vertically around victim's position and spawns a surface hazard beneath the entity if it 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 count() points across volumes using distribution() (or uniform sampling if absent) and spawns a surface hazard on the ground below each sampled point.
      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. 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.
    • entityType

      public net.minecraft.world.entity.EntityType<?> entityType()
      Returns the value of the entityType record component.
      Returns:
      the value of the entityType record component
    • 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
    • verticalSearch

      public net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch()
      Returns the value of the verticalSearch record component.
      Returns:
      the value of the verticalSearch 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.advancements.criterion.ContextAwarePredicate> entityFilter()
      Returns the value of the entityFilter record component.
      Returns:
      the value of the entityFilter record component