Skip to content

HealthChange ​

com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange

Since1.8.4Not cancellable

Fires before the local player's health is updated. change is positive for an increase and negative for a decrease. Setting health to its current value does not fire this event.

js
JsMacros.on("HealthChange", JavaWrapper.methodToJava(function (event) {
  if (event.change > 0) {
    Chat.log(`Healed ${event.change} hp, now at ${event.health} hp`);  
  } else {
    Chat.log(`Lost ${-event.change} hp, now at ${event.health} hp`);  
  }
}))

Constructors ​

new EventHealthChange ​

new EventHealthChange(float health, float change)#
Initializes the event with the supplied health and signed health difference.

Parameters:

  • health: supplied health, in health points
  • change: supplied signed health difference, in health points

Fields ​

change ​

change: floatread-only#
Signed health difference: negative for health lost and positive for health gained. Unlike EventDamage.change and EventHeal.change, this value retains its sign.

health ​

health: floatread-only#
Player health after the change, in health points (two points per heart).

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and stored health values, formatted as %s:{"health": %f, "change": %f}. The %f conversions use the default format precision and locale; this is not lossless serialization or JSON.
Returns: event name and stored health values in diagnostic form