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

# inventory/slotLog

## Type Aliases

### EntityContainer

> **EntityContainer** = *typeof* [`ENTITY_CONTAINERS`](#entity-containers)\[`number`\]

Defined in: [packages/prismarine/src/inventory/slotLog.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L43)

One of the containers an entity carries.

***

### SlotObserver

> **SlotObserver** = (`slot`, `before`, `after`) => `void`

Defined in: [packages/prismarine/src/inventory/slotLog.ts:21](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L21)

Hears one write to a slot, with the slot's logged value before and after it.

#### Parameters

##### slot

`number`

##### before

[`SlotValue`](#slotvalue)

##### after

[`SlotValue`](#slotvalue)

#### Returns

`void`

***

### SlotValue

> **SlotValue** = [`PlainRecord`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/changelog/PlainData/index.md#plainrecord) \| `null`

Defined in: [packages/prismarine/src/inventory/slotLog.ts:18](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L18)

What a slot holds in the change log: the stack's saved form, or null for an empty slot.

## Variables

### ENTITY\_CONTAINERS

> `const` **ENTITY\_CONTAINERS**: readonly \[`"inventory"`, `"armor"`, `"body"`, `"offhand"`, `"mainhand"`, `"ender_chest"`, `"cursor"`, `"crafting"`\]

Defined in: [packages/prismarine/src/inventory/slotLog.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L31)

The containers an entity carries, as an `inventory-slot` entry names them.

One list for every entity. A player has `inventory`, `armor`, `offhand`, `ender_chest`,
`cursor` and `crafting`; a mob has `mainhand`, `offhand`, `armor`, `body` and `inventory`. The
crafting grid is a `CraftingInput` and every other name is an `ItemContainer` of an
`EntityInventory`.

## Functions

### entityContainerNamed()

> **entityContainerNamed**(`name`): `"crafting"` \| `"armor"` \| `"cursor"` \| `"ender_chest"` \| `"mainhand"` \| `"offhand"` \| `"inventory"` \| `"body"` \| `undefined`

Defined in: [packages/prismarine/src/inventory/slotLog.ts:46](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L46)

The container a logged entry names, or undefined for a name no entity container has.

#### Parameters

##### name

`string`

#### Returns

`"crafting"` \| `"armor"` \| `"cursor"` \| `"ender_chest"` \| `"mainhand"` \| `"offhand"` \| `"inventory"` \| `"body"` \| `undefined`

***

### itemOfSlotValue()

> **itemOfSlotValue**(`value`, `content?`): [`Item`](https://jsprismarine.dev/api/@jsprismarine/prismarine/item/Item/classes/Item.md) \| `null`

Defined in: [packages/prismarine/src/inventory/slotLog.ts:67](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L67)

The item a logged slot value describes, or null for an empty slot.

#### Parameters

##### value

[`PlainData`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/changelog/PlainData/index.md#plaindata)

##### content?

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

The content build, which decides the item's maximum durability.

#### Returns

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

#### Throws

When the value is not a stored stack. Only the inventory writes these
  values, so a wrong shape is a bug, and a store that cannot write an inverse stops its world.

***

### slotValueOf()

> **slotValueOf**(`item`): [`SlotValue`](#slotvalue)

Defined in: [packages/prismarine/src/inventory/slotLog.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/inventory/slotLog.ts#L58)

The logged value of a slot that holds `item`, or null for an empty slot.

#### Parameters

##### item

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

#### Returns

[`SlotValue`](#slotvalue)
