StatusEffectHelper
com.jsmacrosce.jsmacros.client.api.helper.StatusEffectHelper
Describes a status-effect instance, including its type, amplifier, duration, and display flags.
Amplifiers are zero-based (level I is 0); duration is in ticks, with -1 indicating infinite duration. Values are snapshots and do not count down after retrieval. Use an entity's status-effect list for applied instances, or the registry to inspect an effect type.
js
const player = Player.getPlayer();
if (player !== null) {
for (const effect of player.getStatusEffects()) {
// strength is the amplifier, so level II reads as 1
const level = effect.getStrength() + 1;
// the duration is in ticks, and twenty of those is a second
const remaining = effect.isPermanent() ? "infinite" : `${Math.ceil(effect.getTime() / 20)}s left`;
Chat.log(`${effect.getId()} ${effect.getCategory()} level ${level}, ${remaining}`);
}
}
// the registry knows about every effect, whether or not anyone has it
const registry = Client.getRegistryManager();
const speed = registry.getStatusEffect("minecraft:speed");
if (speed.isBeneficial()) {
Chat.log(`speed is a beneficial effect, instant: ${speed.isInstant()}`);
}Constructors
new StatusEffectHelper
new StatusEffectHelper(MobEffectInstance s)#Wraps the supplied status-effect instance.
Parameters:
s: raw status-effect instance to wrap
Wraps the status-effect type with zero duration.
Parameters:
s: the status-effect type to wrap
Methods
getCategory
getId
getStrength
Returns the zero-based amplifier (level I is
0).Returns: the amplifier
getTime
Returns the instance's remaining duration snapshot in ticks. Infinite duration is
-1; zero is an expired duration. Re-read the entity's effect to observe its countdown.Returns: remaining ticks, or
-1 for infinite durationhasIcon
Returns whether the effect display should show an icon.
Returns:
true if the icon is shown; false otherwiseisAmbient
Returns the instance's ambient flag. This is a display/state flag and does not reliably identify how the effect was applied.
Returns:
true if ambient; false otherwiseisBeneficial
Returns:
true if this effect is considered beneficial, false otherwise.isHarmful
Returns:
true if this effect is considered harmful, false otherwise.isInstant
Reports whether this effect type applies its effect instantly; this is independent of the instance's duration.
Returns:
true if this effect should be applied instantly, false otherwise.isNeutral
Returns:
true if this effect is considered neutral, false otherwise.isPermanent
Returns whether this instance has infinite duration.
Returns:
true for infinite duration; false otherwiseisVisible
Returns:
true if this effect is shown in the game's effect display; false otherwise.