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
readonlyarmor: readonly (StoredItemStack|null)[]
Defined in: packages/prismarine/src/inventory/persistence.ts:153
Helmet, chestplate, leggings, boots.
enderChest
readonlyenderChest: readonly (StoredItemStack|null)[]
Defined in: packages/prismarine/src/inventory/persistence.ts:157
The player's own 27 ender chest slots.
handSlot
readonlyhandSlot:number
Defined in: packages/prismarine/src/inventory/persistence.ts:151
Which hotbar slot the hand points at.
items
readonlyitems: readonly (StoredItemStack|null)[]
Defined in: packages/prismarine/src/inventory/persistence.ts:149
The 36 main slots; the first nine are the hotbar.
offhand
readonlyoffhand: 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?
readonlyoptionalcanDestroy?: readonlystring[]
Defined in: packages/prismarine/src/inventory/persistence.ts:59
The Bedrock block identifiers the stack may destroy, which adventure mode reads.
canPlaceOn?
readonlyoptionalcanPlaceOn?: readonlystring[]
Defined in: packages/prismarine/src/inventory/persistence.ts:57
The Bedrock block identifiers the stack may be placed on, which adventure mode reads.
components?
readonlyoptionalcomponents?: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?
readonlyoptionalcontents?: 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
readonlycount:number
Defined in: packages/prismarine/src/inventory/persistence.ts:33
customName?
readonlyoptionalcustomName?:string
Defined in: packages/prismarine/src/inventory/persistence.ts:44
damage?
readonlyoptionaldamage?: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?
readonlyoptionaldynamicProperties?: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?
readonlyoptionalenchantments?:Readonly<Record<string,number>>
Defined in: packages/prismarine/src/inventory/persistence.ts:47
Namespaced Java enchantment id to level, which is minecraft:enchantments.
keepOnDeath?
readonlyoptionalkeepOnDeath?:boolean
Defined in: packages/prismarine/src/inventory/persistence.ts:61
Whether the stack stays with its owner when they die.
lockMode?
readonlyoptionallockMode?:"slot"|"inventory"
Defined in: packages/prismarine/src/inventory/persistence.ts:63
Where the stack is locked: in its slot or in the inventory.
lore?
readonlyoptionallore?: readonlystring[]
Defined in: packages/prismarine/src/inventory/persistence.ts:45
mapId?
readonlyoptionalmapId?:number
Defined in: packages/prismarine/src/inventory/persistence.ts:67
Which saved map a filled map shows, Java's minecraft:map_id.
meta?
readonlyoptionalmeta?:number
Defined in: packages/prismarine/src/inventory/persistence.ts:35
The aux value, which is Bedrock's top-level Damage.
name
readonlyname: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
Returns
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
content?
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
stored
StoredInventory | undefined
content?
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?
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
Returns
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
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.