Record Class ApplyPotionEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.ApplyPotionEffect
Record Components:
potionEffects - The list of PotionPayload definitions to apply.
entityFilter - Optional ContextAwarePredicate restricting which entities receive the effects.
All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect

public record ApplyPotionEffect(List<PotionPayload> potionEffects, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) extends Record implements SpellFieldEntityEffect
A SpellFieldEntityEffect that applies one or more configured PotionPayload status effects directly to targeted LivingEntity instances within a spell field volume.
  • Field Details

    • POTION_EFFECTS

      public static final String POTION_EFFECTS
      JSON field key for the list of potion payloads.
      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 entity 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<ApplyPotionEffect> CODEC
      MapCodec for serializing and deserializing ApplyPotionEffect instances from JSON.
  • Constructor Details

    • ApplyPotionEffect

      public ApplyPotionEffect(PotionPayload... potionPayload)
      Constructs an unfiltered ApplyPotionEffect with the specified potion payloads.
      Parameters:
      potionPayload - One or more PotionPayloads to apply.
    • ApplyPotionEffect

      public ApplyPotionEffect(PotionPayload potionPayload, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter)
      Constructs an ApplyPotionEffect with a single potion payload and an entity filter.
      Parameters:
      potionPayload - The PotionPayload to apply.
      entityFilter - The predicate filter to match against candidate entities.
    • ApplyPotionEffect

      public ApplyPotionEffect(net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter)
      Constructs an ApplyPotionEffect with an entity filter and an initially empty payload list.
      Parameters:
      entityFilter - The predicate filter to match against candidate entities.
    • ApplyPotionEffect

      public ApplyPotionEffect()
      Constructs an empty, unfiltered ApplyPotionEffect for fluent configuration.
    • ApplyPotionEffect

      public ApplyPotionEffect(List<PotionPayload> potionEffects, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter)
      Creates an instance of a ApplyPotionEffect record class.
      Parameters:
      potionEffects - the value for the potionEffects 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)
      Evaluates and applies each configured PotionPayload as a MobEffectInstance to victim if it is a LivingEntity and 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.
    • 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.
    • addPotionEffect

      public ApplyPotionEffect addPotionEffect(PotionPayload... potionPayload)
      Returns a copy of this effect with the specified PotionPayloads appended.
      Parameters:
      potionPayload - One or more PotionPayloads to append.
      Returns:
      A new ApplyPotionEffect instance containing the combined payload list.
    • 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.
    • potionEffects

      public List<PotionPayload> potionEffects()
      Returns the value of the potionEffects record component.
      Returns:
      the value of the potionEffects record component
    • entityFilter

      public Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter()
      Returns the value of the entityFilter record component.
      Returns:
      the value of the entityFilter record component