Record Class ApplyPotionEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.ApplyPotionEffect
- Record Components:
potionEffects- The list ofPotionPayloaddefinitions to apply.entityFilter- OptionalLootItemConditionrestricting which entities receive the effects.
- All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect
public record ApplyPotionEffect(List<PotionPayload> potionEffects, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter)
extends Record
implements SpellFieldEntityEffect
A
SpellFieldEntityEffect that applies one or more configured PotionPayload status
effects directly to targeted LivingEntity instances within a spell field volume.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ApplyPotionEffect> MapCodec for serializing and deserializingApplyPotionEffectinstances 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.static final StringJSON field key for the list of potion payloads. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty, unfilteredApplyPotionEffectfor fluent configuration.ApplyPotionEffect(List<PotionPayload> potionEffects, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aApplyPotionEffectrecord class.ApplyPotionEffect(PotionPayload... potionPayload) Constructs an unfilteredApplyPotionEffectwith the specified potion payloads.ApplyPotionEffect(PotionPayload potionPayload, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs anApplyPotionEffectwith a single potion payload and an entity filter.ApplyPotionEffect(net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs anApplyPotionEffectwith an entity filter and an initially empty payload list. -
Method Summary
Modifier and TypeMethodDescriptionaddPotionEffect(PotionPayload... potionPayload) Returns a copy of this effect with the specifiedPotionPayloads appended.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) Evaluates and applies each configuredPotionPayloadas aMobEffectInstancetovictimif it is aLivingEntityand 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.Returns the value of thepotionEffectsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
POTION_EFFECTS
-
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 deserializingApplyPotionEffectinstances from JSON.
-
-
Constructor Details
-
ApplyPotionEffect
Constructs an unfilteredApplyPotionEffectwith the specified potion payloads.- Parameters:
potionPayload- One or morePotionPayloads to apply.
-
ApplyPotionEffect
public ApplyPotionEffect(PotionPayload potionPayload, net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs anApplyPotionEffectwith a single potion payload and an entity filter.- Parameters:
potionPayload- ThePotionPayloadto apply.entityFilter- The predicate filter to match against candidate entities.
-
ApplyPotionEffect
public ApplyPotionEffect(net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition> entityFilter) Constructs anApplyPotionEffectwith an entity filter and an initially empty payload list.- Parameters:
entityFilter- The predicate filter to match against candidate entities.
-
ApplyPotionEffect
public ApplyPotionEffect()Constructs an empty, unfilteredApplyPotionEffectfor fluent configuration. -
ApplyPotionEffect
public ApplyPotionEffect(List<PotionPayload> potionEffects, Optional<net.minecraft.core.Holder<net.minecraft.world.level.storage.loot.predicates.LootItemCondition>> entityFilter) Creates an instance of aApplyPotionEffectrecord class.- Parameters:
potionEffects- the value for thepotionEffectsrecord 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) Evaluates and applies each configuredPotionPayloadas aMobEffectInstancetovictimif 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.
-
addPotionEffect
Returns a copy of this effect with the specifiedPotionPayloads appended.- Parameters:
potionPayload- One or morePotionPayloads to append.- Returns:
- A new
ApplyPotionEffectinstance containing the combined payload list.
-
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). -
potionEffects
Returns the value of thepotionEffectsrecord component.- Returns:
- the value of the
potionEffectsrecord component
-
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
-