Record Class HealEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.HealEffect
- Record Components:
amount- TheLevelBasedValuebase health restored before topological scaling.entityFilter- OptionalContextAwarePredicaterestricting which entities are healed.
- All Implemented Interfaces:
SpellFieldEffect,SpellFieldEntityEffect
public record HealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that restores health points to targeted LivingEntity
instances within a spell field volume, scaled by each target's local topological multiplier.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the base healing amount.static final com.mojang.serialization.MapCodec<HealEffect> MapCodec for serializing and deserializingHealEffectinstances from JSON.static final StringJSON field key for the optional entity filter predicate.static final StringRegistry path identifier for this spell field entity effect.static final LevelBasedKeyProviderSupplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
Constructor Summary
ConstructorsConstructorDescriptionHealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount) Constructs an unfilteredHealEffect.HealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter) Creates an instance of aHealEffectrecord class.HealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.critereon.ContextAwarePredicate entityFilter) Constructs aHealEffectrestricted by the given entity predicate filter. -
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 context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.world.entity.Entity victim, float volumeScalar) Restores $\text{amount} \cdot \text{volumeScalar}$ health tovictimif it is aLivingEntityand matchesentityFilter().com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> Returns the value of theentityFilterrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
AMOUNT
JSON field key for the base healing amount.- See Also:
-
ENTITY_FILTER
JSON field key for the optional entity filter predicate.- See Also:
-
KEY
Registry path identifier for this spell field entity effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingHealEffectinstances from JSON.
-
-
Constructor Details
-
HealEffect
public HealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount) Constructs an unfilteredHealEffect.- Parameters:
amount- TheLevelBasedValuebase healing amount.
-
HealEffect
public HealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, net.minecraft.advancements.critereon.ContextAwarePredicate entityFilter) Constructs aHealEffectrestricted by the given entity predicate filter.- Parameters:
amount- TheLevelBasedValuebase healing amount.entityFilter- The predicate filter to match against candidate entities.
-
HealEffect
public HealEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount, Optional<net.minecraft.advancements.critereon.ContextAwarePredicate> entityFilter) Creates an instance of aHealEffectrecord class.- Parameters:
amount- the value for theamountrecord componententityFilter- the value for theentityFilterrecord 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) Restores $\text{amount} \cdot \text{volumeScalar}$ health tovictimif it is aLivingEntityand matchesentityFilter().- Specified by:
applyin interfaceSpellFieldEntityEffect- 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 forvictim.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
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
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-