Record Class DamageHealingEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.DamageHealingEffect
Record Components:
multiplier - The LevelBasedValue multiplied by the inflicted damage to compute the restored amount.
healingType - The restoration mode (HealingType.HEALING or HealingType.ABSORPTION).
maxAbsorption - An optional LevelBasedValue capping the maximum absorption hearts granted when using HealingType.ABSORPTION.

public record DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption) extends Record
Data-driven enchantment effect component that restores health or grants absorption hearts to an attacker proportional to the amount of combat damage dealt (life-steal / leech mechanic).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<DamageHealingEffect>
    Codec for serializing and deserializing DamageHealingEffect instances from JSON.
    static final String
    JSON field key for the healing restoration mode.
    static final String
    Registry path identifier for this effect component.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the optional maximum absorption cap.
    static final String
    JSON field key for the damage-to-healing multiplier.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType)
    Constructs a DamageHealingEffect without an absorption cap.
    DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption)
    Creates an instance of a DamageHealingEffect record class.
    DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption)
    Constructs a DamageHealingEffect with a defined maximum absorption cap.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(net.minecraft.world.entity.LivingEntity living, int enchantmentLevel, float damageDealt)
    Applies the proportional healing or absorption to the specified living entity based on the damage dealt.
    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.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the multiplier record component.
    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

    • MULTIPLIER

      public static final String MULTIPLIER
      JSON field key for the damage-to-healing multiplier.
      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 effect component.
      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.Codec<DamageHealingEffect> CODEC
      Codec for serializing and deserializing DamageHealingEffect instances from JSON.
  • Constructor Details

    • DamageHealingEffect

      public DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption)
      Constructs a DamageHealingEffect with a defined maximum absorption cap.
      Parameters:
      multiplier - The damage-to-healing multiplier.
      healingType - The restoration mode.
      maxAbsorption - The maximum absorption heart cap.
    • DamageHealingEffect

      public DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType)
      Constructs a DamageHealingEffect without an absorption cap.
      Parameters:
      multiplier - The damage-to-healing multiplier.
      healingType - The restoration mode.
    • DamageHealingEffect

      public DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, Optional<net.minecraft.world.item.enchantment.LevelBasedValue> maxAbsorption)
      Creates an instance of a DamageHealingEffect record class.
      Parameters:
      multiplier - the value for the multiplier 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.world.entity.LivingEntity living, int enchantmentLevel, float damageDealt)
      Applies the proportional healing or absorption to the specified living entity based on the damage dealt.
      Parameters:
      living - The entity receiving the health or absorption restoration (typically the attacker).
      enchantmentLevel - The active level of the enchantment.
      damageDealt - The raw amount of damage inflicted that triggered this effect.
    • 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.
    • multiplier

      public net.minecraft.world.item.enchantment.LevelBasedValue multiplier()
      Returns the value of the multiplier record component.
      Returns:
      the value of the multiplier 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