Skip to content

API reference / @jsprismarine/prismarine / inventory/slotLog

inventory/slotLog ​

Type Aliases ​

EntityContainer ​

EntityContainer = typeof ENTITY_CONTAINERS[number]

Defined in: packages/prismarine/src/inventory/slotLog.ts:43

One of the containers an entity carries.


SlotObserver ​

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

Defined in: packages/prismarine/src/inventory/slotLog.ts:21

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

Parameters ​

slot ​

number

before ​

SlotValue

after ​

SlotValue

Returns ​

void


SlotValue ​

SlotValue = PlainRecord | null

Defined in: packages/prismarine/src/inventory/slotLog.ts:18

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

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

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 | null

Defined in: packages/prismarine/src/inventory/slotLog.ts:67

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

Parameters ​

value ​

PlainData

content? ​

ServerContent

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

Returns ​

Item | 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

Defined in: packages/prismarine/src/inventory/slotLog.ts:58

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

Parameters ​

item ​

Item | null

Returns ​

SlotValue