Record Class SummonEntityEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.SummonEntityEffect
- Record Components:
entityType- TheEntityTypeto instantiate and spawn.count- TheLevelBasedValuenumber of entities to spawn (supports fractional probabilistic rounding).distribution- OptionalProbabilityDistributionused to sample spawn coordinates when evaluated as a volume effect.entityFilter- OptionalLootItemConditionrestricting target eligibility.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect, SpellFieldVolumeEffect
public record SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, 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 that summons one or more entities of a configured
EntityType.
Implements both SpellFieldEntityEffect and SpellFieldVolumeEffect so it can be
used in either "entity_effects" (spawning at each targeted entity's location) or
"volume_effects" (spawning at points sampled across the volume geometry, including
self-targeted spell fields where context.owner() is excluded from entity_effects).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<SummonEntityEffect> MapCodec for serializing and deserializingSummonEntityEffectinstances from JSON.static final StringJSON field key for the number of entities to summon.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 entity type identifier.static final StringRegistry path identifier for this spell field effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
Constructor Summary
ConstructorsConstructorDescriptionSummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count) Constructs an unfilteredSummonEntityEffectwith uniform volume sampling.SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aSummonEntityEffectrecord class.SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Constructs aSummonEntityEffectwithout a custom spatial distribution.SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, ProbabilityDistribution distribution) Constructs an unfilteredSummonEntityEffectwith a custom spatialProbabilityDistribution.SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, ProbabilityDistribution distribution, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aSummonEntityEffectwith both a customProbabilityDistributionand an entity filter.SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aSummonEntityEffectrestricted 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) Summons the calculated number of entities at coordinates sampled acrossvolumesusingdistribution()(or uniform volume sampling if absent).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) Summons the calculated number of entities directly atvictim's position and orientation.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.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> 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.
-
Field Details
-
ENTITY_TYPE
-
COUNT
-
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 deserializingSummonEntityEffectinstances from JSON.
-
-
Constructor Details
-
SummonEntityEffect
public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Constructs aSummonEntityEffectwithout a custom spatial distribution.- Parameters:
entityType- TheEntityTypeto summon.count- TheLevelBasedValuespawn count.entityFilter- Optional entity predicate filter.
-
SummonEntityEffect
public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count) Constructs an unfilteredSummonEntityEffectwith uniform volume sampling.- Parameters:
entityType- TheEntityTypeto summon.count- TheLevelBasedValuespawn count.
-
SummonEntityEffect
public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, ProbabilityDistribution distribution) Constructs an unfilteredSummonEntityEffectwith a custom spatialProbabilityDistribution.- Parameters:
entityType- TheEntityTypeto summon.count- TheLevelBasedValuespawn count.distribution- The spatial probability distribution for volume sampling.
-
SummonEntityEffect
public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aSummonEntityEffectrestricted by an entity predicate filter.- Parameters:
entityType- TheEntityTypeto summon.count- TheLevelBasedValuespawn count.entityFilter- The predicate filter to match against candidate entities.
-
SummonEntityEffect
public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, ProbabilityDistribution distribution, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aSummonEntityEffectwith both a customProbabilityDistributionand an entity filter.- Parameters:
entityType- TheEntityTypeto summon.count- TheLevelBasedValuespawn count.distribution- The spatial probability distribution for volume sampling.entityFilter- The predicate filter to match against candidate entities.
-
SummonEntityEffect
public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, Optional<ProbabilityDistribution> distribution, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aSummonEntityEffectrecord class.- Parameters:
entityType- the value for theentityTyperecord componentcount- the value for thecountrecord 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) Summons the calculated number of entities directly atvictim's position and orientation.- 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) Summons the calculated number of entities at coordinates sampled acrossvolumesusingdistribution()(or uniform volume sampling if absent).- 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. 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
-
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
-