Record Class HealingEntityEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.HealingEntityEffect
Record Components:
amount - The LevelBasedValue governing the flat amount of health or absorption restored.
healingType - The restoration mode (HealingType.HEALING or HealingType.ABSORPTION).
maxAbsorption - An optional LevelBasedValue capping the maximum absorption hearts when using HealingType.ABSORPTION.
All Implemented Interfaces:
net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

public record HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption) extends Record implements net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
An EnchantmentEntityEffect that restores health points or grants temporary absorption hearts to a target LivingEntity.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON field key for the restored health or absorption amount.
    static final com.mojang.serialization.MapCodec<HealingEntityEffect>
    MapCodec for serializing and deserializing HealingEntityEffect instances from JSON.
    static final String
    JSON field key for the healing restoration mode.
    static final String
    Registry path identifier for this entity effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the optional maximum absorption cap.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType)
    Constructs a HealingEntityEffect without an absorption cap.
    HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption)
    Creates an instance of a HealingEntityEffect record class.
    HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption)
    Constructs a HealingEntityEffect with an explicit absorption cap.
  • 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 itemInUse, net.minecraft.world.entity.Entity target, net.minecraft.world.phys.Vec3 origin)
    Applies the calculated healing or absorption to the target entity if it is a living, alive entity.
    com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect>
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the healingType record component.
    Optional<net.minecraft.world.item.enchantment.LevelBasedValue>
    Returns the value of the maxAbsorption record component.
    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

    Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect

    onChangedBlock

    Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

    onDeactivated
  • Field Details

    • AMOUNT

      public static final String AMOUNT
      JSON field key for the restored health or absorption amount.
      See Also:
    • HEALING_TYPE

      public static final String HEALING_TYPE
      JSON field key for the healing restoration mode.
      See Also:
    • MAX_ABSORPTION

      public static final String MAX_ABSORPTION
      JSON field key for the optional maximum absorption cap.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this 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<HealingEntityEffect> CODEC
      MapCodec for serializing and deserializing HealingEntityEffect instances from JSON.
  • Constructor Details

    • HealingEntityEffect

      public HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption)
      Constructs a HealingEntityEffect with an explicit absorption cap.
      Parameters:
      amount - The amount of health or absorption to restore.
      healingType - The restoration mode.
      maxAbsorption - The maximum absorption cap.
    • HealingEntityEffect

      public HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType)
      Constructs a HealingEntityEffect without an absorption cap.
      Parameters:
      amount - The amount of health or absorption to restore.
      healingType - The restoration mode.
    • HealingEntityEffect

      public HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption)
      Creates an instance of a HealingEntityEffect record class.
      Parameters:
      amount - the value for the amount record component
      healingType - the value for the healingType record component
      maxAbsorption - the value for the maxAbsorption record component
  • Method Details

    • apply

      public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse itemInUse, net.minecraft.world.entity.Entity target, net.minecraft.world.phys.Vec3 origin)
      Applies the calculated healing or absorption to the target entity if it is a living, alive entity.
      Specified by:
      apply in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Parameters:
      level - The server level in which the effect is triggered.
      enchantmentLevel - The level of the source enchantment.
      itemInUse - The context of the enchanted item in use.
      target - The entity receiving the healing effect.
      origin - The origin position vector of the trigger.
    • codec

      public com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect> codec()
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
    • 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.
    • 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
    • healingType

      public HealingType healingType()
      Returns the value of the healingType record component.
      Returns:
      the value of the healingType record component
    • maxAbsorption

      public Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption()
      Returns the value of the maxAbsorption record component.
      Returns:
      the value of the maxAbsorption record component