StatusEffectUpdate
com.jsmacrosce.jsmacros.client.api.event.impl.player.EventStatusEffectUpdate
Fires while the client processes a status-effect update or removal packet for the local player. Listeners run before the packet's effect change is applied.
Updates (including refreshes or downgrades) set added; removals set removed.
Effects on other entities do not raise this event.
js
JsMacros.on("StatusEffectUpdate", JavaWrapper.methodToJava(function (event) {
if (event.removed) {
if (event.oldEffect !== null) {
Chat.log(`Lost ${event.oldEffect.getId()}`);
}
return;
}
if (event.newEffect !== null) {
const effect = event.newEffect;
Chat.log(`${effect.getId()} ${effect.getStrength() + 1} for ${effect.getTime()} ticks`);
}
}))Constructors
new EventStatusEffectUpdate
new EventStatusEffectUpdate(StatusEffectHelper oldEffect, StatusEffectHelper newEffect, boolean added)#Initializes the event with the supplied effect helpers and update flag; the helpers are stored as supplied, including
null, and removed is the complement of added.Parameters:
oldEffect: supplied helper for the prior effect, ornullnewEffect: supplied helper for the incoming effect, ornulladded:truefor an update orfalsefor a removal; this records the event's change type and does not guarantee an effect is present or an update succeeds
Fields
added
true for an update packet (including a refresh); false for a removal.newEffect
The effect specified by an update packet, or
null on a removal. Its strength is the zero-based amplifier returned by StatusEffectHelper.getStrength().oldEffect
A wrapper for the effect stored on the player before the packet is applied, or
null if none is stored. On removal, the wrapper is created even if the effect is absent; in that case StatusEffectHelper.getRaw() returns null, and effect accessors cannot be used.removed
true for a removal packet; false for an update packet.Methods
toString
Formats a diagnostic string using the selected effect helper:
newEffect for an update and oldEffect for a removal. The selected helper's accessors are evaluated when called; a null selected helper or one whose raw effect is null causes a NullPointerException. The change label is unquoted, so the result is not JSON.Returns: a formatted diagnostic containing the selected effect's ID, strength, duration, and added/removed label