Record Class DamageHealingEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.DamageHealingEffect
- Record Components:
multiplier- TheLevelBasedValuemultiplied by the inflicted damage to compute the restored amount.healingType- The restoration mode (HealingType.HEALINGorHealingType.ABSORPTION).maxAbsorption- An optionalLevelBasedValuecapping the maximum absorption hearts granted when usingHealingType.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
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<DamageHealingEffect> Codec for serializing and deserializingDamageHealingEffectinstances from JSON.static final StringJSON field key for the healing restoration mode.static final StringRegistry path identifier for this effect component.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for the optional maximum absorption cap.static final StringJSON field key for the damage-to-healing multiplier. -
Constructor Summary
ConstructorsConstructorDescriptionDamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType) Constructs aDamageHealingEffectwithout 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 aDamageHealingEffectrecord class.DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption) Constructs aDamageHealingEffectwith a defined maximum absorption cap. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(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 booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thehealingTyperecord component.Optional<net.minecraft.world.item.enchantment.LevelBasedValue> Returns the value of themaxAbsorptionrecord component.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of themultiplierrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
MULTIPLIER
JSON field key for the damage-to-healing multiplier.- See Also:
-
HEALING_TYPE
-
MAX_ABSORPTION
JSON field key for the optional maximum absorption cap.- See Also:
-
KEY
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
Codec for serializing and deserializingDamageHealingEffectinstances from JSON.
-
-
Constructor Details
-
DamageHealingEffect
public DamageHealingEffect(net.minecraft.world.item.enchantment.LevelBasedValue multiplier, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption) Constructs aDamageHealingEffectwith 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 aDamageHealingEffectwithout 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 aDamageHealingEffectrecord class.- Parameters:
multiplier- the value for themultiplierrecord componenthealingType- the value for thehealingTyperecord componentmaxAbsorption- the value for themaxAbsorptionrecord 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
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
multiplier
public net.minecraft.world.item.enchantment.LevelBasedValue multiplier()Returns the value of themultiplierrecord component.- Returns:
- the value of the
multiplierrecord component
-
healingType
Returns the value of thehealingTyperecord component.- Returns:
- the value of the
healingTyperecord component
-
maxAbsorption
Returns the value of themaxAbsorptionrecord component.- Returns:
- the value of the
maxAbsorptionrecord component
-