[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / entity/Damage

# entity/Damage

## Interfaces

### Mitigation

Defined in: [packages/prismarine/src/entity/Damage.ts:102](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L102)

What the damage pipeline knows about the entity being hit.

#### Properties

##### bypassesArmor

> **bypassesArmor**: `boolean`

Defined in: [packages/prismarine/src/entity/Damage.ts:118](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L118)

Whether the cause ignores armor points.

##### bypassesEnchantments

> **bypassesEnchantments**: `boolean`

Defined in: [packages/prismarine/src/entity/Damage.ts:120](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L120)

Whether it ignores the enchantments on that armor too.

##### defensePoints

> **defensePoints**: `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:104](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L104)

Armor points worn, out of twenty.

##### enchantmentProtection

> **enchantmentProtection**: `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:114](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L114)

The Enchantment Protection Factor of everything worn, already summed.

The total of every `minecraft:damage_protection` effect component that
answered this particular blow; see `enchantmentProtection` in
`src/enchantment/mitigation.ts`, which is what works it out.

##### resistance

> **resistance**: `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:116](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L116)

The level of the Resistance effect, or zero.

##### toughness

> **toughness**: `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:106](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L106)

Armor toughness, which only diamond and netherite have.

## Variables

### INVULNERABILITY\_TICKS

> `const` **INVULNERABILITY\_TICKS**: `10` = `10`

Defined in: [packages/prismarine/src/entity/Damage.ts:99](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L99)

Ticks of grace after a hit lands, during which a weaker one is ignored.

Half a second, as in vanilla, and it is what stops a mob standing in a cactus from dying in
a fifth of a second - or two players from trading twenty hits a second. A harder blow still
gets through while it runs, for the difference.

## Functions

### armorFactor()

> **armorFactor**(`damage`, `defensePoints`, `toughness`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:159](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L159)

The fraction of a blow armor lets through, which depends on how hard the blow is.

#### Parameters

##### damage

`number`

The blow, in half-hearts.

##### defensePoints

`number`

Armor points worn; at or below zero everything gets through.

##### toughness

`number`

Armor toughness.

#### Returns

`number`

The factor, from 0.2 to 1.

***

### armorReduced()

> **armorReduced**(`damage`, `defensePoints`, `toughness`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:149](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L149)

What armor leaves of a blow.

#### Parameters

##### damage

`number`

The blow, in half-hearts.

##### defensePoints

`number`

Armor points worn.

##### toughness

`number`

Armor toughness.

#### Returns

`number`

What gets through.

#### Example

```typescript
// A full set of iron, against a hard hit.
armorReduced(10, 15, 0); // => 4.6
```

***

### bypassesArmor()

> **bypassesArmor**(`cause`): `boolean`

Defined in: [packages/prismarine/src/entity/Damage.ts:128](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L128)

Whether armor points are any use against this kind of damage.

#### Parameters

##### cause

[`DamageCause`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageCause/index.md#damagecause-1)

What did the damage.

#### Returns

`boolean`

`true` if the armor step should be skipped.

***

### bypassesEnchantments()

> **bypassesEnchantments**(`cause`): `boolean`

Defined in: [packages/prismarine/src/entity/Damage.ts:135](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L135)

Whether the enchantments on that armor are any use either.

#### Parameters

##### cause

[`DamageCause`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageCause/index.md#damagecause-1)

What did the damage.

#### Returns

`boolean`

`true` if the protection step should be skipped.

***

### protectionFactor()

> **protectionFactor**(`enchantmentProtection`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:186](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L186)

The fraction of a blow the `damage_protection` enchantments let through.

#### Parameters

##### enchantmentProtection

`number`

The summed Enchantment Protection Factor.

#### Returns

`number`

The factor, from 0.2 to 1.

***

### protectionReduced()

> **protectionReduced**(`damage`, `enchantmentProtection`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:178](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L178)

What the `damage_protection` enchantments leave of what armor let through.

Which enchantments contributed, and how much each one was worth, is decided
by their files rather than here: this is only Java's `CombatRules` arithmetic
over whatever total they came to.

#### Parameters

##### damage

`number`

What armor let through.

##### enchantmentProtection

`number`

The summed Enchantment Protection Factor.

#### Returns

`number`

What gets through.

***

### reduceDamage()

> **reduceDamage**(`damage`, `mitigation`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:222](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L222)

The whole reduction, in vanilla's order.

#### Parameters

##### damage

`number`

The raw blow, in half-hearts.

##### mitigation

[`Mitigation`](#mitigation)

What the entity is wearing and under.

#### Returns

`number`

What reaches the entity's health, never below zero.

***

### resistanceFactor()

> **resistanceFactor**(`level`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:209](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L209)

The fraction of a blow the Resistance effect lets through.

#### Parameters

##### level

`number`

The effect's level; five and above stops everything.

#### Returns

`number`

The factor, from 0 to 1.

***

### resistanceReduced()

> **resistanceReduced**(`damage`, `level`): `number`

Defined in: [packages/prismarine/src/entity/Damage.ts:197](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/Damage.ts#L197)

What the Resistance effect leaves.

#### Parameters

##### damage

`number`

What the armor left.

##### level

`number`

The effect's level; five and above stops everything.

#### Returns

`number`

What gets through.
