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

# entity/damageTypes

## Interfaces

### DamageOrigins

Defined in: [packages/prismarine/src/entity/damageTypes.ts:150](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L150)

Where `/damage` says a blow came from.

#### Properties

##### at?

> `readonly` `optional` **at?**: [`Vector3`](https://jsprismarine.dev/api/@jsprismarine/math/classes/Vector3.md)

Defined in: [packages/prismarine/src/entity/damageTypes.ts:156](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L156)

`at`: a point the blow came from.

##### by?

> `readonly` `optional` **by?**: [`StoreActor`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storeActors/classes/StoreActor.md)

Defined in: [packages/prismarine/src/entity/damageTypes.ts:152](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L152)

`by`: what made contact.

##### from?

> `readonly` `optional` **from?**: [`StoreActor`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/data/storeActors/classes/StoreActor.md)

Defined in: [packages/prismarine/src/entity/damageTypes.ts:154](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L154)

`from`: who is answerable for `by`; without it `by` is both.

## Type Aliases

### DamageScaling

> **DamageScaling** = `"never"` \| `"always"` \| `"when_caused_by_living_non_player"`

Defined in: [packages/prismarine/src/entity/damageTypes.ts:134](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L134)

How a damage type scales with the difficulty, Java's `DamageScaling`.

## Functions

### damageCauseOfType()

> **damageCauseOfType**(`type`, `tags`): [`DamageCause`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageCause/index.md#damagecause-1)

Defined in: [packages/prismarine/src/entity/damageTypes.ts:53](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L53)

The cause of this server's enum a Java damage type stands for; `generic` when it names none.

#### Parameters

##### type

`string`

##### tags

`ReadonlySet`\<`string`\>

#### Returns

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

***

### damageCausesInTag()

> **damageCausesInTag**(`content`, `tag`): `ReadonlySet`\<[`DamageCause`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageCause/index.md#damagecause-1)\>

Defined in: [packages/prismarine/src/entity/damageTypes.ts:69](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L69)

The causes the types of one `damage_type` tag stand for, such as the magic, sonic boom and
thorns of Java's `witch_resistant_to`.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build, for its `damage_type` tags.

##### tag

`string`

The tag, such as `minecraft:witch_resistant_to`.

#### Returns

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

***

### damageScalingOf()

> **damageScalingOf**(`content`, `cause`, `damageType?`): [`DamageScaling`](#damagescaling)

Defined in: [packages/prismarine/src/entity/damageTypes.ts:143](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L143)

Whether a blow scales with the difficulty, by the `scaling` its damage type declares: `never`,
`always`, or `when_caused_by_living_non_player`, which is every mob attack.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build, for the damage type definitions.

##### cause

`string`

The cause name the blow carries.

##### damageType?

`string`

The Java damage type the blow names, when it names one.

#### Returns

[`DamageScaling`](#damagescaling)

***

### damageSourceOfType()

> **damageSourceOfType**(`content`, `type`, `origins?`): [`DamageSource`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageSource/classes/DamageSource.md)

Defined in: [packages/prismarine/src/entity/damageTypes.ts:179](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L179)

Builds the source for a damage type and the entities behind it, the way Java's `/damage` does.

With `by` alone the entity is both who made contact and who is answerable. With `from` as well,
`from` is answerable and `by` made contact, so an arrow shot by a skeleton blames the skeleton.
With neither there is no source entity at all, whoever ran the command.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build, for the type's tags.

##### type

`string`

A damage type id.

##### origins?

[`DamageOrigins`](#damageorigins) = `{}`

The optional `by`, `from` and `at` clauses.

#### Returns

[`DamageSource`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/DamageSource/classes/DamageSource.md)

***

### foodExhaustionOf()

> **foodExhaustionOf**(`content`, `cause`, `damageType?`): `number`

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

The food exhaustion a blow that takes a player's health costs, Java's
`DamageSource.getFoodExhaustion`: the `exhaustion` its damage type declares, 0.1 for a blow and
0 for drowning, falling, starving and the other types that are not.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build, for the damage type definitions.

##### cause

`string`

The cause name the blow carries.

##### damageType?

`string`

The Java damage type the blow names, when it names one.

#### Returns

`number`

***

### hasDamageType()

> **hasDamageType**(`content`, `type`): `boolean`

Defined in: [packages/prismarine/src/entity/damageTypes.ts:164](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L164)

Whether the loaded datapacks declare a damage type.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

The content build.

##### type

`string`

A damage type id such as `minecraft:in_fire`.

#### Returns

`boolean`

***

### javaDamageTypeOf()

> **javaDamageTypeOf**(`cause`, `damageType?`): `string`

Defined in: [packages/prismarine/src/entity/damageTypes.ts:113](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/damageTypes.ts#L113)

The Java damage type a blow stands for: the one it names, else the one its cause stands for,
else `minecraft:generic`.

#### Parameters

##### cause

`string`

The cause name the blow carries.

##### damageType?

`string`

The Java damage type the blow names, when it names one.

#### Returns

`string`
