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

# inventory/EntityInventory

## Classes

- [EntityInventory](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/EntityInventory/classes/EntityInventory.md)

## Interfaces

### EntityInventoryObserver

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L49)

Hears every write to what an entity carries, which is how it reaches the change log.

#### Methods

##### handSlot()

> **handSlot**(`before`, `after`): `void`

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

The hand moved from one hotbar slot to another.

###### Parameters

###### before

`number`

###### after

`number`

###### Returns

`void`

##### slot()

> **slot**(`container`, `slot`, `before`, `after`): `void`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:51](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L51)

One slot of one container changed, from `before` to `after`.

###### Parameters

###### container

[`InventoryContainer`](#inventorycontainer)

###### slot

`number`

###### before

[`SlotValue`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#slotvalue)

###### after

[`SlotValue`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#slotvalue)

###### Returns

`void`

***

### InventoryLayout

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:38](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L38)

Which containers an entity has, and how big each one is.

#### Type Parameters

##### C

`C` *extends* [`InventoryContainer`](#inventorycontainer)

#### Properties

##### containers

> `readonly` **containers**: readonly (readonly \[`C`, `number`\])[]

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L40)

Each container's name and number of slots.

##### hotbar?

> `readonly` `optional` **hotbar?**: `number`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:45](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L45)

How many of the first `inventory` slots the hand can point at, which is a player's hotbar.
Without it the main hand is the `mainhand` container's one slot.

***

### SlotAddress

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:32](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L32)

One slot of one container of an [EntityInventory](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/EntityInventory/classes/EntityInventory.md).

#### Properties

##### container

> `readonly` **container**: [`InventoryContainer`](#inventorycontainer)

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L33)

##### slot

> `readonly` **slot**: `number`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:34](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L34)

## Type Aliases

### InventoryContainer

> **InventoryContainer** = `Exclude`\<[`EntityContainer`](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/slotLog/index.md#entitycontainer), `"crafting"`\>

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:29](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L29)

The containers an [EntityInventory](https://jsprismarine.dev/api/@jsprismarine/prismarine/inventory/EntityInventory/classes/EntityInventory.md) holds: every entity container but the crafting grid.

***

### MobInventoryContainer

> **MobInventoryContainer** = `ReturnType`\<*typeof* [`mobLayout`](#moblayout)\>\[`"containers"`\]\[`number`\]\[`0`\]

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

The containers a mob layout has.

***

### PlayerInventoryContainer

> **PlayerInventoryContainer** = *typeof* [`PLAYER_LAYOUT`](#player-layout)\[`"containers"`\]\[`number`\]\[`0`\]

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:85](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L85)

The containers a player layout has.

## Variables

### ARMOR\_SLOTS

> `const` **ARMOR\_SLOTS**: `4` = `4`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L23)

Helmet, chestplate, leggings, boots: the `armor` container's slots, in the order the client numbers them.

***

### HOTBAR\_SIZE

> `const` **HOTBAR\_SIZE**: `9` = `9`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:26](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L26)

Slots the hotbar reaches, and so the range a player's hand slot may name.

***

### PLAYER\_LAYOUT

> `const` **PLAYER\_LAYOUT**: `object`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:73](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L73)

The containers a player carries, besides the crafting grid.

- `inventory` is the 36 main slots, hotbar first. The hand slot names one of the first nine.
- `armor` is a container of its own rather than four more main slots, because the client
  addresses it as one (`ContainerUiId.ARMOR_CONTAINER`) and because everything that walks the
  inventory looking for space would otherwise offer to put a pickaxe on your head.
- `offhand` is one slot, for a shield or a torch.
- `ender_chest` is on the player and not on a block for the reason vanilla puts it there:
  every `minecraft:ender_chest` in every dimension shows the same 27 slots to one player.
- `cursor` is the stack held by the pointer between picking it up and putting it down. A drag
  is two requests, one that moves a stack onto the pointer and a later one that moves it off,
  so the stack needs somewhere to be in between.

#### Type Declaration

##### containers

> `readonly` **containers**: readonly \[readonly \[`"inventory"`, `36`\], readonly \[`"armor"`, `4`\], readonly \[`"offhand"`, `1`\], readonly \[`"ender_chest"`, `27`\], readonly \[`"cursor"`, `1`\]\]

##### hotbar

> `readonly` **hotbar**: `9` = `HOTBAR_SIZE`

## Functions

### mobEquipmentAddress()

> **mobEquipmentAddress**(`slot`): [`SlotAddress`](#slotaddress)

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:110](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L110)

The container slot an equipment slot reads in a layout with no hotbar, before any alias: a
mob's own `mainhand`, `offhand` and `body` slot, or its `armor` slot.

#### Parameters

##### slot

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

#### Returns

[`SlotAddress`](#slotaddress)

***

### mobLayout()

> **mobLayout**(`inventorySize`): `object`

Defined in: [packages/prismarine/src/inventory/EntityInventory.ts:92](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/EntityInventory.ts#L92)

A mob's layout: one slot each for the main hand, the off hand and the body, four armor slots
and an inventory of the size its `minecraft:inventory` component gives.

#### Parameters

##### inventorySize

`number`

The `inventory` container's number of slots, 0 for a mob with none.

#### Returns

`object`

##### containers

> `readonly` **containers**: readonly \[readonly \[`"mainhand"`, `1`\], readonly \[`"offhand"`, `1`\], readonly \[`"armor"`, `4`\], readonly \[`"body"`, `1`\], readonly \[`"inventory"`, `number`\]\]
