Record Class SummonEntityEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.SummonEntityEffect
Record Components:
entityType - The EntityType to instantiate and spawn.
count - The LevelBasedValue number of entities to spawn (supports fractional probabilistic rounding).
distribution - Optional ProbabilityDistribution used to sample spawn coordinates when evaluated as a volume effect.
entityFilter - Optional LootItemCondition restricting 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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<SummonEntityEffect>
    MapCodec for serializing and deserializing SummonEntityEffect instances from JSON.
    static final String
    JSON field key for the number of entities to summon.
    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 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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count)
    Constructs an unfiltered SummonEntityEffect with 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 a SummonEntityEffect record 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 a SummonEntityEffect without a custom spatial distribution.
    SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, ProbabilityDistribution distribution)
    Constructs an unfiltered SummonEntityEffect with a custom spatial ProbabilityDistribution.
    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 a SummonEntityEffect with both a custom ProbabilityDistribution and 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 a SummonEntityEffect 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)
    Summons the calculated number of entities at coordinates sampled across volumes using distribution() (or uniform volume sampling if absent).
    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 at victim's position and orientation.
    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.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>>
    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.

    Methods inherited from class Object

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

    • ENTITY_TYPE

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

      public static final String COUNT
      JSON field key for the number of entities to summon.
      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<SummonEntityEffect> CODEC
      MapCodec for serializing and deserializing SummonEntityEffect instances 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 a SummonEntityEffect without a custom spatial distribution.
      Parameters:
      entityType - The EntityType to summon.
      count - The LevelBasedValue spawn count.
      entityFilter - Optional entity predicate filter.
    • SummonEntityEffect

      public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count)
      Constructs an unfiltered SummonEntityEffect with uniform volume sampling.
      Parameters:
      entityType - The EntityType to summon.
      count - The LevelBasedValue spawn count.
    • SummonEntityEffect

      public SummonEntityEffect(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.item.enchantment.LevelBasedValue count, ProbabilityDistribution distribution)
      Constructs an unfiltered SummonEntityEffect with a custom spatial ProbabilityDistribution.
      Parameters:
      entityType - The EntityType to summon.
      count - The LevelBasedValue spawn 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 a SummonEntityEffect restricted by an entity predicate filter.
      Parameters:
      entityType - The EntityType to summon.
      count - The LevelBasedValue spawn 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 a SummonEntityEffect with both a custom ProbabilityDistribution and an entity filter.
      Parameters:
      entityType - The EntityType to summon.
      count - The LevelBasedValue spawn 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 a SummonEntityEffect record class.
      Parameters:
      entityType - the value for the entityType record component
      count - the value for the count 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)
      Summons the calculated number of entities directly at victim's position and orientation.
      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)
      Summons the calculated number of entities at coordinates sampled across volumes using distribution() (or uniform volume sampling if absent).
      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
    • 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