java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.DamageEffect
Record Components:
damageType - The registry ResourceKey of the DamageType to inflict.
amount - The LevelBasedValue base damage amount before topological scaling.
entityFilter - Optional ContextAwarePredicate restricting which entities take damage.
All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect

public record DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter) extends Record implements SpellFieldEntityEffect
A SpellFieldEntityEffect that inflicts damage of a specified DamageType to targeted entities within a spell field volume, scaled by each target's local topological multiplier.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON field key for the base damage amount.
    static final com.mojang.serialization.MapCodec<DamageEffect>
    MapCodec for serializing and deserializing DamageEffect instances from JSON.
    static final String
    JSON field key for the damage type resource key.
    static final String
    JSON field key for the optional entity filter predicate.
    static final String
    Registry path identifier for this spell field entity effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount)
    Constructs an unfiltered DamageEffect.
    DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter)
    Creates an instance of a DamageEffect record class.
    DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.critereon.ContextAwarePredicate entityFilter)
    Constructs a DamageEffect restricted by the given entity predicate filter.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the amount record component.
    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)
    Inflicts $\text{amount} \cdot \text{volumeScalar}$ damage of type damageType() to victim, attributing spatialReference as the direct entity and context.owner() as the causing entity.
    com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>
    Returns the value of the damageType record component.
    Optional<net.minecraft.advancements.critereon.ContextAwarePredicate>
    Returns the value of the entityFilter 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 java.lang.Object

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

    • DAMAGE_TYPE

      public static final String DAMAGE_TYPE
      JSON field key for the damage type resource key.
      See Also:
    • AMOUNT

      public static final String AMOUNT
      JSON field key for the base damage amount.
      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<DamageEffect> CODEC
      MapCodec for serializing and deserializing DamageEffect instances from JSON.
  • Constructor Details

    • DamageEffect

      public DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount)
      Constructs an unfiltered DamageEffect.
      Parameters:
      damageType - The DamageType resource key.
      amount - The LevelBasedValue base damage amount.
    • DamageEffect

      public DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.critereon.ContextAwarePredicate entityFilter)
      Constructs a DamageEffect restricted by the given entity predicate filter.
      Parameters:
      damageType - The DamageType resource key.
      amount - The LevelBasedValue base damage amount.
      entityFilter - The predicate filter to match against candidate entities.
    • DamageEffect

      public DamageEffect(net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType, net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter)
      Creates an instance of a DamageEffect record class.
      Parameters:
      damageType - the value for the damageType record component
      amount - the value for the amount 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)
      Inflicts $\text{amount} \cdot \text{volumeScalar}$ damage of type damageType() to victim, attributing spatialReference as the direct entity and context.owner() as the causing entity.
      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.
    • 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.
    • damageType

      public net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType()
      Returns the value of the damageType record component.
      Returns:
      the value of the damageType record component
    • amount

      public net.minecraft.world.item.enchantment.LevelBasedValue amount()
      Returns the value of the amount record component.
      Returns:
      the value of the amount record component
    • entityFilter

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