Class ServerMobEffectEvents
Status effect events are useful when implementing generic behavior for many status effects and modifying the addition and removal behavior of existing status effects.
When only one class of status effects
requires code to be run before/after the addition or removal of the effect,
consider using FabricMobEffect.onEffectAdded(MobEffectInstance, LivingEntity),
FabricMobEffect.onEffectRemoved(MobEffectInstance, LivingEntity), or
FabricMobEffect.onEffectStarted(MobEffectInstance, LivingEntity).
Additionally, an EffectEventContext parameter is passed to all
listeners of these events.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interfacestatic interfacestatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Event<ServerMobEffectEvents.AfterAdd> An event that is called after an effect is added.static final Event<ServerMobEffectEvents.AfterRemove> An event that is called after an effect is removed.static final Event<ServerMobEffectEvents.AllowAdd> An event that checks whether an effect may be added.static final Event<ServerMobEffectEvents.AllowEarlyRemove> An event that checks whether an effect may be removed.static final Event<ServerMobEffectEvents.BeforeAdd> An event that is called before an effect is added.static final Event<ServerMobEffectEvents.BeforeRemove> An event that is called before an effect is removed. -
Method Summary
-
Field Details
-
ALLOW_ADD
An event that checks whether an effect may be added.This event can be used to cancel effects given specific conditions such as a held item, a data attachment, or another status effect.
-
BEFORE_ADD
An event that is called before an effect is added.This event can be used to generalize behavior normally in the
MobEffect.onEffectAdded(LivingEntity, int)methods to a subset of status effects or even to all status effects.- See Also:
-
AFTER_ADD
An event that is called after an effect is added.This event is useful for code that is required to run only after an effect is applied, such as a method that checks if an effect is present on an entity.
-
ALLOW_EARLY_REMOVE
An event that checks whether an effect may be removed.Note: this event is not called when an effect expires. The behavior of effect expiry typically should not be modified.
This event is called when effects are removed before they expire. For example, drinking milk, drinking honey when poisoned, using a totem of undying, or using a command such as
/effect cleartriggers this event. If you don't want commands to be affected, anEffectEventContextparameter is passed to listeners.This event can be used to cancel the removal of effects given specific conditions such as a held item, a data attachment, or another status effect.
-
BEFORE_REMOVE
An event that is called before an effect is removed.This event can be used to generalize behavior normally in the
FabricMobEffect.onEffectRemoved(MobEffectInstance, LivingEntity)method to a subset of status effects or even to all status effects.- See Also:
-
AFTER_REMOVE
An event that is called after an effect is removed.This event is useful for code that is required to run only after an effect is removed, such as a method that checks if an effect is present on an entity.
-