# EntityDamaged

`com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged`

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

Fires before a client-side living entity's health decreases through `setHealth`; it does not
identify a damage source. `health` is the incoming value and
`damage` is the difference from the previously tracked health.  
```js
JsMacros.on("EntityDamaged", JavaWrapper.methodToJava(function (event) {
  if (event.entity instanceof EntityHelpers.Creeper) {
    Chat.log(`Creeper took ${event.damage} damage; incoming health: ${event.health}`);  
  }
}))
```

## Constructors

### new EventEntityDamaged {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged_constructor-Entity-float-float-}

```js
new EventEntityDamaged(Entity e, float health, float amount)
```

Wraps an entity and stores the supplied health and damage values without applying damage.  
A `null` entity causes [Objects.requireNonNull(Object)](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Objects.html) to throw
[NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) during helper creation.

**Parameters:**
- `e`: non-null entity to wrap; no living-entity validation is performed
- `health`: supplied incoming health value; it is stored unchanged and not applied
- `amount`: supplied decrease amount, stored unchanged as `damage` without calculation or validation

## Fields

### damage {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged_damage}

```js
damage: float
```

Decrease from the previously tracked health; positive.

### entity {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged_entity}

```js
entity: EntityHelper<?>
```

Entity whose health is decreasing.

### health {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged_health}

```js
health: float
```

Incoming health value passed to `setHealth`.

**Since:** 1.6.5

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged_toString-}

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

Returns a diagnostic string containing the event name, entity helper string, and stored values.  
The format is `%s:{"entity": %s, "health": %f, "damage": %f}`.

**Returns:** diagnostic text in the stated format
