Record Class ClearEffectsEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.ClearEffectsEffect
- Record Components:
durationReduction- TheLevelBasedValuenumber of ticks subtracted from each active status effect before topological scaling.entityFilter- OptionalContextAwarePredicaterestricting which entities are affected.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect
public record ClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that reduces the remaining duration of all active status effects
on targeted LivingEntity instances by an amount scaled by the entity's local topological
multiplier, removing any effect whose remaining duration drops to or below zero.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ClearEffectsEffect> MapCodec for serializing and deserializingClearEffectsEffectinstances from JSON.static final StringJSON field key for the status effect duration reduction in ticks.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
ConstructorsConstructorDescriptionClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction) Constructs an unfilteredClearEffectsEffect.ClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) Creates an instance of aClearEffectsEffectrecord class.ClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs aClearEffectsEffectrestricted 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) Reduces the duration of all activeMobEffectInstances onvictimby $\text{durationReduction} \cdot \text{volumeScalar}$, removing expired effects and updating surviving ones.com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of thedurationReductionrecord component.Optional<net.minecraft.advancements.predicates.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
-
DURATION_REDUCTION
JSON field key for the status effect duration reduction in ticks.- 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 deserializingClearEffectsEffectinstances from JSON.
-
-
Constructor Details
-
ClearEffectsEffect
public ClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction) Constructs an unfilteredClearEffectsEffect.- Parameters:
durationReduction- TheLevelBasedValueduration reduction in ticks.
-
ClearEffectsEffect
public ClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction, net.minecraft.advancements.predicates.ContextAwarePredicate entityFilter) Constructs aClearEffectsEffectrestricted by the given entity predicate filter.- Parameters:
durationReduction- TheLevelBasedValueduration reduction in ticks.entityFilter- The predicate filter to match against candidate entities.
-
ClearEffectsEffect
public ClearEffectsEffect(net.minecraft.world.item.enchantment.LevelBasedValue durationReduction, Optional<net.minecraft.advancements.predicates.ContextAwarePredicate> entityFilter) Creates an instance of aClearEffectsEffectrecord class.- Parameters:
durationReduction- the value for thedurationReductionrecord 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) Reduces the duration of all activeMobEffectInstances onvictimby $\text{durationReduction} \cdot \text{volumeScalar}$, removing expired effects and updating surviving ones.- 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). -
durationReduction
public net.minecraft.world.item.enchantment.LevelBasedValue durationReduction()Returns the value of thedurationReductionrecord component.- Returns:
- the value of the
durationReductionrecord component
-
entityFilter
Returns the value of theentityFilterrecord component.- Returns:
- the value of the
entityFilterrecord component
-