Record Class ResetLifetimeEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.ResetLifetimeEffect
- Record Components:
entityFilter- OptionalLootItemConditionrestricting which entities have their age reset.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect
public record ResetLifetimeEffect(Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that resets the internal despawn age timer of targeted
ItemEntity and ExperienceOrb instances back to 0 ticks, preventing
them from despawning while inside the spell field.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ResetLifetimeEffect> MapCodec for serializing and deserializingResetLifetimeEffectinstances from JSON.static final StringRegistry path identifier for this spell field entity effect. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an unfilteredResetLifetimeEffect.ResetLifetimeEffect(Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aResetLifetimeEffectrecord class.ResetLifetimeEffect(net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aResetLifetimeEffectrestricted by the given entity predicate filter. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(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) Resets the internalagefield to0ifvictimis anItemEntityorExperienceOrband matchesentityFilter().com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> 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
-
KEY
Registry path identifier for this spell field entity effect.- See Also:
-
CODEC
MapCodec for serializing and deserializingResetLifetimeEffectinstances from JSON.
-
-
Constructor Details
-
ResetLifetimeEffect
public ResetLifetimeEffect()Constructs an unfilteredResetLifetimeEffect. -
ResetLifetimeEffect
public ResetLifetimeEffect(net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs aResetLifetimeEffectrestricted by the given entity predicate filter.- Parameters:
entityFilter- The predicate filter to match against candidate entities.
-
ResetLifetimeEffect
public ResetLifetimeEffect(Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aResetLifetimeEffectrecord class.- Parameters:
entityFilter- 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) Resets the internalagefield to0ifvictimis anItemEntityorExperienceOrband 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
-
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). -
entityFilter
public Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter()Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-