Skip to content

StatusEffectHelper ​

com.jsmacrosce.jsmacros.client.api.helper.StatusEffectHelper

Since1.2.4

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
new StatusEffectHelper(MobEffect s)Since1.8.4#
Wraps the status-effect type with zero duration.

Parameters:

  • s: the status-effect type to wrap
new StatusEffectHelper(MobEffect s, int t)Since1.8.4#
Wraps the status-effect type with the supplied duration.

Parameters:

  • s: the status-effect type to wrap
  • t: the initial duration in ticks, or -1 for infinite duration

Methods ​

getCategory ​

getCategory(): StringSince1.8.4#
Returns the effect category.
Returns: "HARMFUL", "NEUTRAL", or "BENEFICIAL"

getId ​

getId(): StringSince1.2.4#
Returns the effect's registry identifier.
Returns: the identifier

getStrength ​

getStrength(): intSince1.2.4#
Returns the zero-based amplifier (level I is 0).
Returns: the amplifier

getTime ​

getTime(): intSince1.2.4#
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 duration

hasIcon ​

hasIcon(): booleanSince1.8.4#
Returns whether the effect display should show an icon.
Returns: true if the icon is shown; false otherwise

isAmbient ​

isAmbient(): booleanSince1.8.4#
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 otherwise

isBeneficial ​

isBeneficial(): booleanSince1.8.4#
Returns: true if this effect is considered beneficial, false otherwise.

isHarmful ​

isHarmful(): booleanSince1.8.4#
Returns: true if this effect is considered harmful, false otherwise.

isInstant ​

isInstant(): booleanSince1.8.4#
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 ​

isNeutral(): booleanSince1.8.4#
Returns: true if this effect is considered neutral, false otherwise.

isPermanent ​

isPermanent(): booleanSince1.8.4#
Returns whether this instance has infinite duration.
Returns: true for infinite duration; false otherwise

isVisible ​

isVisible(): booleanSince1.8.4#
Returns: true if this effect is shown in the game's effect display; false otherwise.

toString ​

toString(): String#
Returns a diagnostic string containing the effect identifier, strength, and duration.
Returns: diagnostic representation of the wrapped status-effect instance