Skip to content

API reference / @jsprismarine/prismarine / inventory/persistence

inventory/persistence ​

Interfaces ​

StoredInventory ​

Defined in: packages/prismarine/src/inventory/persistence.ts:147

Every container a player carries, by the slot numbering each one uses.

Properties ​

armor ​

readonly armor: readonly (StoredItemStack | null)[]

Defined in: packages/prismarine/src/inventory/persistence.ts:153

Helmet, chestplate, leggings, boots.

enderChest ​

readonly enderChest: readonly (StoredItemStack | null)[]

Defined in: packages/prismarine/src/inventory/persistence.ts:157

The player's own 27 ender chest slots.

handSlot ​

readonly handSlot: number

Defined in: packages/prismarine/src/inventory/persistence.ts:151

Which hotbar slot the hand points at.

items ​

readonly items: readonly (StoredItemStack | null)[]

Defined in: packages/prismarine/src/inventory/persistence.ts:149

The 36 main slots; the first nine are the hotbar.

offhand ​

readonly offhand: readonly (StoredItemStack | null)[]

Defined in: packages/prismarine/src/inventory/persistence.ts:155

One slot.


StoredItemStack ​

Defined in: packages/prismarine/src/inventory/persistence.ts:30

One stack as a player data record holds it.

Properties ​

canDestroy? ​

readonly optional canDestroy?: readonly string[]

Defined in: packages/prismarine/src/inventory/persistence.ts:59

The Bedrock block identifiers the stack may destroy, which adventure mode reads.

canPlaceOn? ​

readonly optional canPlaceOn?: readonly string[]

Defined in: packages/prismarine/src/inventory/persistence.ts:57

The Bedrock block identifiers the stack may be placed on, which adventure mode reads.

components? ​

readonly optional components?: Readonly<Record<string, unknown>>

Defined in: packages/prismarine/src/inventory/persistence.ts:72

The stack's other Java components in Java's JSON form, such as minecraft:trim or minecraft:firework_explosion; see Item.getComponents.

contents? ​

readonly optional contents?: readonly (StoredItemStack | null)[]

Defined in: packages/prismarine/src/inventory/persistence.ts:55

What a container item holds, one entry per slot, which is a shulker box's inventory.

Null for an empty slot rather than undefined, for the reason the module comment gives: JSON.stringify turns an undefined array element into null, so the two forms would not match across the fallback path.

count ​

readonly count: number

Defined in: packages/prismarine/src/inventory/persistence.ts:33

customName? ​

readonly optional customName?: string

Defined in: packages/prismarine/src/inventory/persistence.ts:44

damage? ​

readonly optional damage?: number

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

Durability spent, which is Java's minecraft:damage and Bedrock's tag.Damage.

Spent rather than remaining, so a stack of an item whose maximum durability changed between versions comes back as damaged by the same amount instead of as a different fraction of a different total.

dynamicProperties? ​

readonly optional dynamicProperties?: Readonly<Record<string, Readonly<Record<string, ItemDynamicPropertyValue>>>>

Defined in: packages/prismarine/src/inventory/persistence.ts:65

The script dynamic properties set on the stack, by pack UUID and then by property id.

enchantments? ​

readonly optional enchantments?: Readonly<Record<string, number>>

Defined in: packages/prismarine/src/inventory/persistence.ts:47

Namespaced Java enchantment id to level, which is minecraft:enchantments.

keepOnDeath? ​

readonly optional keepOnDeath?: boolean

Defined in: packages/prismarine/src/inventory/persistence.ts:61

Whether the stack stays with its owner when they die.

lockMode? ​

readonly optional lockMode?: "slot" | "inventory"

Defined in: packages/prismarine/src/inventory/persistence.ts:63

Where the stack is locked: in its slot or in the inventory.

lore? ​

readonly optional lore?: readonly string[]

Defined in: packages/prismarine/src/inventory/persistence.ts:45

mapId? ​

readonly optional mapId?: number

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

Which saved map a filled map shows, Java's minecraft:map_id.

meta? ​

readonly optional meta?: number

Defined in: packages/prismarine/src/inventory/persistence.ts:35

The aux value, which is Bedrock's top-level Damage.

name ​

readonly name: string

Defined in: packages/prismarine/src/inventory/persistence.ts:32

The item identifier, namespaced.

Functions ​

dropOfItem() ​

dropOfItem(item): ItemDrop | undefined

Defined in: packages/prismarine/src/inventory/persistence.ts:236

An item stack as a block behavior's drop, which is itemOfDrop backwards.

Parameters ​

item ​

Item | null

Returns ​

ItemDrop | undefined

The drop, or undefined for an empty slot, air or an empty stack.


isStoredItemStack() ​

isStoredItemStack(value): value is StoredItemStack

Defined in: packages/prismarine/src/inventory/persistence.ts:88

Whether an unknown value, such as JSON read from actor NBT, has the shape of a stored stack.

Parameters ​

value ​

unknown

Returns ​

value is StoredItemStack


itemDropOf() ​

itemDropOf(stored): ItemDrop

Defined in: packages/prismarine/src/inventory/persistence.ts:125

The same stack as a block behavior carries one.

ItemDrop and StoredItemStack describe the same thing and differ in one name: a drop calls the item identifier and a stored stack calls it name. Neither can be renamed - the drop's spelling is @jsprismarine/block-behaviors' published interface, and the stored one's is in every player file already written - so the rename happens here, once, for both directions.

Parameters ​

stored ​

StoredItemStack

Returns ​

ItemDrop


itemOfDrop() ​

itemOfDrop(drop, content?): Item | null

Defined in: packages/prismarine/src/inventory/persistence.ts:229

A block behavior's drop as the item stack it names, or null when the drop is empty.

Parameters ​

drop ​

ItemDrop

content? ​

ServerContent

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

Returns ​

Item | null


restoreInventory() ​

restoreInventory(inventory, stored, content?): void

Defined in: packages/prismarine/src/inventory/persistence.ts:271

Puts a stored record back into a player's containers.

Parameters ​

inventory ​

HumanInventory

stored ​

StoredInventory | undefined

content? ​

ServerContent

Returns ​

void


restoredItem() ​

restoredItem(stored, content?): Item | null

Defined in: packages/prismarine/src/inventory/persistence.ts:197

One stored stack back as an item, or null when the record held nothing.

Parameters ​

stored ​

StoredItemStack | null | undefined

content? ​

ServerContent

The content build, so a pack that redefines an item decides its maximum durability rather than Java's committed table doing it.

Returns ​

Item | null


storedInventory() ​

storedInventory(inventory): StoredInventory

Defined in: packages/prismarine/src/inventory/persistence.ts:262

Everything a player carries, ready to be written to a player data record.

Parameters ​

inventory ​

HumanInventory

Returns ​

StoredInventory


storedItem() ​

storedItem(item): StoredItemStack | null

Defined in: packages/prismarine/src/inventory/persistence.ts:161

One stack as a record holds it, or null for air or an empty stack, which a record never holds.

Parameters ​

item ​

Item

Returns ​

StoredItemStack | null


storedItemDrop() ​

storedItemDrop(drop): StoredItemStack

Defined in: packages/prismarine/src/inventory/persistence.ts:137

The same drop as a player data record stores one, which is itemDropOf backwards.

Parameters ​

drop ​

ItemDrop

Returns ​

StoredItemStack