# Damage

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

**Since:** 1.2.7

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

Fires when a call decreases the local player's health, before the incoming value is applied.  
 It dispatches before [EventHealthChange](EventHealthChange.md),  
 which dispatches before [EventEntityDamaged](../world/EventEntityDamaged.md).  
 The injected event supplies a generic damage source, so [source](#) is its generic damage
 type ID and [attacker](#) is `null`.  
 ```js
JsMacros.on("Damage", JavaWrapper.methodToJava(function (event) {
  Chat.log(`Took ${event.change} damage, ${event.health} hp left`);  
  if (4.0 >= event.health) {
    Chat.log("About to die");  
  }
}))
 ```

## Constructors

### new EventDamage {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventDamage_constructor-DamageSource-float-float-}

```js
new EventDamage(DamageSource source, float health, float change)
```

Initializes the event with the supplied damage source and health values. The source's message ID
 is stored as `source`; the causing entity is wrapped as `attacker`, or `null`
 when absent. A `null` source throws [NullPointerException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `source`: damage source used to obtain its message ID and causing entity
- `health`: incoming health value
- `change`: amount of health lost

## Fields

### change {#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventDamage_change}

```js
change: float
```

Amount of health lost; positive, unlike the matching
 [change](EventHealthChange.md#com.jsmacrosce.jsmacros.client.api.event.impl.player.EventHealthChange_change)
 which is negative on the same change.

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

```js
health: float
```

Incoming player health value, before it is applied.

## Methods

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

```js
toString(): String
```

Returns a diagnostic string containing this event's name, health, and change values.

**Returns:** a string in the form `eventName:{"health": %f, "change": %f}`
