Record Class SurfaceHazardEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.volume.SurfaceHazardEffect
- Record Components:
entityType- The hazardEntityTypeto instantiate and place on the surface.count- TheLevelBasedValuenumber of surface hazards spawned when evaluated as a volume effect.verticalSearch- TheLevelBasedValuevertical half-range (in blocks above and below the target point) searched for a solid surface.distribution- OptionalProbabilityDistributionused to sample horizontal/vertical starting coordinates when evaluated as a volume effect.entityFilter- OptionalContextAwarePredicaterestricting 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
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<SurfaceHazardEffect> MapCodec for serializing and deserializingSurfaceHazardEffectinstances from JSON.static final StringJSON field key for the volume hazard count.static final StringJSON field key for the optional spatial probability distribution.static final StringJSON field key for the optional entity filter predicate.static final StringJSON field key for the hazard entity type identifier.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 the vertical ground search range in blocks. -
Constructor Summary
ConstructorsConstructorDescriptionSurfaceHazardEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch) Constructs an unfilteredSurfaceHazardEffectwith 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 aSurfaceHazardEffectrecord 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 unfilteredSurfaceHazardEffectwith a custom spatialProbabilityDistribution.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 aSurfaceHazardEffectwith both a customProbabilityDistributionand 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 aSurfaceHazardEffectrestricted 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) Samplescount()points acrossvolumesusingdistribution()(or uniform sampling if absent) and spawns a surface hazard on the ground below each sampled point.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) Searches vertically aroundvictim's position and spawns a surface hazard beneath the entity if it 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.Returns the value of thedistributionrecord component.Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> Returns the value of theentityFilterrecord component.net.minecraft.world.entity.EntityType<?> Returns the value of theentityTyperecord 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.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of theverticalSearchrecord component.
-
Field Details
-
ENTITY_TYPE
JSON field key for the hazard entity type identifier.- See Also:
-
COUNT
JSON field key for the volume hazard count.- See Also:
-
VERTICAL_SEARCH
JSON field key for the vertical ground search range in blocks.- 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
Registry path identifier for this spell field effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingSurfaceHazardEffectinstances 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 unfilteredSurfaceHazardEffectwith uniform volume sampling.- Parameters:
entityType- The hazardEntityTypeto 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 unfilteredSurfaceHazardEffectwith a custom spatialProbabilityDistribution.- Parameters:
entityType- The hazardEntityTypeto 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 aSurfaceHazardEffectrestricted by an entity predicate filter.- Parameters:
entityType- The hazardEntityTypeto 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 aSurfaceHazardEffectwith both a customProbabilityDistributionand an entity filter.- Parameters:
entityType- The hazardEntityTypeto 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 aSurfaceHazardEffectrecord class.- Parameters:
entityType- the value for theentityTyperecord componentcount- the value for thecountrecord componentverticalSearch- the value for theverticalSearchrecord 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) Searches vertically aroundvictim's position and spawns a surface hazard beneath the entity if it 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) Samplescount()points acrossvolumesusingdistribution()(or uniform sampling if absent) and spawns a surface hazard on the ground below each sampled point.- 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
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. -
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. -
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). -
entityType
public net.minecraft.world.entity.EntityType<?> entityType()Returns the value of theentityTyperecord component.- Returns:
- the value of the
entityTyperecord component
-
count
public net.minecraft.world.item.enchantment.LevelBasedValue count()Returns the value of thecountrecord component.- Returns:
- the value of the
countrecord component
-
verticalSearch
public net.minecraft.world.item.enchantment.LevelBasedValue verticalSearch()Returns the value of theverticalSearchrecord component.- Returns:
- the value of the
verticalSearchrecord component
-
distribution
Returns the value of thedistributionrecord component.- Returns:
- the value of the
distributionrecord component
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-