# HealthChange

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

**Since:** 1.8.4

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

Fires before the local player's health is updated. [change](#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange_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 {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange_constructor-float-float-}

```js
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 {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange_change}

```js
change: float
```

Signed health difference: negative for health lost and positive for health gained. Unlike
 [EventDamage.change](EventDamage.md#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventDamage_change) and [EventHeal.change](EventHeal.md#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHeal_change), this value retains its sign.

### health {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange_health}

```js
health: float
```

Player health after the change, in health points (two points per heart).

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange_toString-}

```js
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
