Record Class HealingEntityEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.HealingEntityEffect
- Record Components:
amount- TheLevelBasedValuegoverning the flat amount of health or absorption restored.healingType- The restoration mode (HealingType.HEALINGorHealingType.ABSORPTION).maxAbsorption- An optionalLevelBasedValuecapping the maximum absorption hearts when usingHealingType.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
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the restored health or absorption amount.static final com.mojang.serialization.MapCodec<HealingEntityEffect> MapCodec for serializing and deserializingHealingEntityEffectinstances from JSON.static final StringJSON field key for the healing restoration mode.static final StringRegistry path identifier for this entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for the optional maximum absorption cap. -
Constructor Summary
ConstructorsConstructorDescriptionHealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType) Constructs aHealingEntityEffectwithout 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 aHealingEntityEffectrecord class.HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption) Constructs aHealingEntityEffectwith an explicit absorption cap. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.enchantment.LevelBasedValueamount()Returns the value of theamountrecord component.voidapply(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> codec()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.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
onChangedBlockMethods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
onDeactivated
-
Field Details
-
AMOUNT
JSON field key for the restored health or absorption amount.- See Also:
-
HEALING_TYPE
JSON field key for the healing restoration mode.- See Also:
-
MAX_ABSORPTION
JSON field key for the optional maximum absorption cap.- See Also:
-
KEY
Registry path identifier for this entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingHealingEntityEffectinstances from JSON.
-
-
Constructor Details
-
HealingEntityEffect
public HealingEntityEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, HealingType healingType, net.minecraft.world.item.enchantment.LevelBasedValue maxAbsorption) Constructs aHealingEntityEffectwith 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 aHealingEntityEffectwithout 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 aHealingEntityEffectrecord class.- Parameters:
amount- the value for theamountrecord componenthealingType- the value for thehealingTyperecord componentmaxAbsorption- the value for themaxAbsorptionrecord 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:
applyin interfacenet.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:
codecin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect- Specified by:
codecin interfacenet.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
-
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. -
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. -
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). -
amount
public net.minecraft.world.item.enchantment.LevelBasedValue amount()Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord 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
-