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

# entity/equipment

## Interfaces

### MobEquipmentRollOptions

Defined in: [packages/prismarine/src/entity/equipment.ts:147](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L147)

What [rollMobEquipment](#rollmobequipment) reads.

#### Properties

##### content

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

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

The running content: the tables to roll and the items to resolve against.

##### itemOf

> `readonly` **itemOf**: (`drop`) => [`Item`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/classes/Item.md) \| `null`

Defined in: [packages/prismarine/src/entity/equipment.ts:153](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L153)

Resolves one rolled drop to an item, so this module does not reach into the inventory.

###### Parameters

###### drop

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)

###### Returns

[`Item`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/classes/Item.md) \| `null`

##### report?

> `readonly` `optional` **report?**: (`message`) => `void`

Defined in: [packages/prismarine/src/entity/equipment.ts:155](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L155)

Where a drop that resolves to no item is reported.

###### Parameters

###### message

`string`

###### Returns

`void`

##### table

> `readonly` **table**: `string`

Defined in: [packages/prismarine/src/entity/equipment.ts:151](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L151)

The `minecraft:equipment.table` the entity's active components name.

## Type Aliases

### MobEquipmentSet

> **MobEquipmentSet** = `Readonly`\<`Partial`\<`Record`\<[`MobEquipmentSlot`](#mobequipmentslot), [`ContentItemDrop`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentitemdrop)\>\>\>

Defined in: [packages/prismarine/src/entity/equipment.ts:79](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L79)

What a mob has in each slot, with a slot it has nothing in left out.

***

### MobEquipmentSlot

> **MobEquipmentSlot** = *typeof* [`MOB_EQUIPMENT_SLOTS`](#mob-equipment-slots)\[`number`\]

Defined in: [packages/prismarine/src/entity/equipment.ts:76](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L76)

One of [MOB\_EQUIPMENT\_SLOTS](#mob-equipment-slots).

## Variables

### BEDROCK\_EQUIPMENT\_SLOT\_NAMES

> `const` **BEDROCK\_EQUIPMENT\_SLOT\_NAMES**: `object`

Defined in: [packages/prismarine/src/entity/equipment.ts:86](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L86)

Bedrock's fully qualified name for each equipment slot, which components such as
`minecraft:on_equipment_changed` and `minecraft:burns_in_daylight` use, and which
`/replaceitem` names the slot's group by.

#### Type Declaration

##### body

> `readonly` **body**: `"slot.armor.body"` = `'slot.armor.body'`

##### chest

> `readonly` **chest**: `"slot.armor.chest"` = `'slot.armor.chest'`

##### feet

> `readonly` **feet**: `"slot.armor.feet"` = `'slot.armor.feet'`

##### head

> `readonly` **head**: `"slot.armor.head"` = `'slot.armor.head'`

##### legs

> `readonly` **legs**: `"slot.armor.legs"` = `'slot.armor.legs'`

##### mainhand

> `readonly` **mainhand**: `"slot.weapon.mainhand"` = `'slot.weapon.mainhand'`

##### offhand

> `readonly` **offhand**: `"slot.weapon.offhand"` = `'slot.weapon.offhand'`

***

### MOB\_EQUIPMENT\_SLOTS

> `const` **MOB\_EQUIPMENT\_SLOTS**: readonly \[`"mainhand"`, `"offhand"`, `"head"`, `"chest"`, `"legs"`, `"feet"`, `"body"`\]

Defined in: [packages/prismarine/src/entity/equipment.ts:65](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L65)

The slots a mob's equipment reaches a client in.

The keys of [ViewableEquipment](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/predicateView/index.md#viewableequipment), which is the record the rest of the server already
passes around as "items by slot", so the enchantment views and this agree by construction
rather than by being kept in step. `satisfies` is the tie: a slot added or renamed there
fails to compile here until this tuple lists it.

`body` is the fifth positional slot in `MobArmorEquipmentPacket`; entity interactions can
equip horse armor, llama carpet and wolf armor there.

## Functions

### mobEquipmentSlotOf()

> **mobEquipmentSlotOf**(`name`): `"head"` \| `"chest"` \| `"feet"` \| `"mainhand"` \| `"offhand"` \| `"body"` \| `"legs"` \| `undefined`

Defined in: [packages/prismarine/src/entity/equipment.ts:112](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L112)

The slot a `minecraft:equipment.slot_drop_chance` entry names.

A behavior pack spells these `slot.weapon.mainhand` and `slot.armor.head`, while an item
component uses the bare slot name. Both forms resolve through the same slot list.

#### Parameters

##### name

`string`

The slot as the component spells it.

#### Returns

`"head"` \| `"chest"` \| `"feet"` \| `"mainhand"` \| `"offhand"` \| `"body"` \| `"legs"` \| `undefined`

The slot, or undefined for an unsupported name such as `slot.armor.saddle`.

***

### rollMobEquipment()

> **rollMobEquipment**(`options`): [`MobEquipmentSet`](#mobequipmentset)

Defined in: [packages/prismarine/src/entity/equipment.ts:168](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L168)

Rolls one equipment table and sorts what it produced into slots.

A later entry wins a slot an earlier one filled, which is the order the pools are written in.
A rolled item goes where [slotForItem](#slotforitem) puts it, and a nautilus shell to the off hand.

#### Parameters

##### options

[`MobEquipmentRollOptions`](#mobequipmentrolloptions)

#### Returns

[`MobEquipmentSet`](#mobequipmentset)

What the mob holds and wears. Empty when the registry has no such table, and empty
  for a roll whose every pool failed its chance gate, which is what a zombie spawning bare
  is.

***

### sameDrop()

> **sameDrop**(`left`, `right`): `boolean`

Defined in: [packages/prismarine/src/entity/equipment.ts:217](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L217)

Whether two drops are the same item in the same condition, counts included.

#### Parameters

##### left

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

##### right

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

#### Returns

`boolean`

***

### sameEquipmentItems()

> **sameEquipmentItems**(`left`, `right`): `boolean`

Defined in: [packages/prismarine/src/entity/equipment.ts:213](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L213)

Whether two sets of resolved items would reach a client as the same bytes.

Compared as what the packets carry rather than field by field, which is the same test
`blockentity/blockEntityWrite.ts` applies to a block entity compound and for the same reason:
two items that encode identically are the same item to a client however they were built, and
an item rebuilt from a saved drop has been through a round trip the one it is compared
against has not.

#### Parameters

##### left

[`ViewableEquipment`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/predicateView/index.md#viewableequipment)

##### right

[`ViewableEquipment`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/predicateView/index.md#viewableequipment)

#### Returns

`boolean`

***

### slotForItem()

> **slotForItem**(`item`): `"head"` \| `"chest"` \| `"feet"` \| `"mainhand"` \| `"offhand"` \| `"body"` \| `"legs"`

Defined in: [packages/prismarine/src/entity/equipment.ts:137](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L137)

Where one rolled item goes.

`minecraft:equippable` is the game's own answer and the only one that stays right as the item
set changes; a table of identifiers here would go stale the first time a pack added a helmet.
An item without the component is a weapon rather than nothing, so a bow, a crossbow and the
fox's emerald all reach the main hand.

#### Parameters

##### item

`Pick`\<[`Item`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/classes/Item.md), `"getEquipmentSlot"`\>

The rolled item, resolved against the running content. Only its declared slot
  is read, which is the whole of what this needs an item for.

#### Returns

`"head"` \| `"chest"` \| `"feet"` \| `"mainhand"` \| `"offhand"` \| `"body"` \| `"legs"`

The slot it occupies.

***

### wornArmorOf()

> **wornArmorOf**(`equipment`): `object`

Defined in: [packages/prismarine/src/entity/equipment.ts:268](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/entity/equipment.ts#L268)

The armor points and toughness a set of worn items gives, summed over the five armor slots.

#### Parameters

##### equipment

[`ViewableEquipment`](https://jsprismarine.dev/api/@jsprismarine/prismarine/entity/predicateView/index.md#viewableequipment)

#### Returns

`object`

##### defensePoints

> `readonly` **defensePoints**: `number`

##### toughness

> `readonly` **toughness**: `number`
