One item slot model, and command storage
Started 2026-11-21 for #3567. The issue reports two garbled command refusals. The cause behind both is that commands could reach a player's slots and nothing else, and /data had no NBT to read. This plan gives every entity one slot model, puts every slot name behind one parser, and adds Java Edition's command storage.
What we know
Facts gathered on 2026-11-21, before any slice landed.
Three slot stores
Players keep
HumanInventory(inventory/HumanInventory.ts). It extendsInventory, a map ofContainerEntry, and owns three moreInventorys (armor 4, offhand 1, ender chest 27), a cursorItem, a hand slot and a stack network id counter.- A
ContainerEntryholds anItemand a count, and theItemholds a count too. About 20 sites pick one or the other, andItemStackRequestHandler.itemOrNullwrites the entry's count onto the live item to bring them back in step. - An empty slot holds an air
Item. - Each write logs one
inventory-slotchange entry, addressed{entity, container, slot}. Undo restores throughHumanInventory.restoreSlot. - About 50 source files and 43 test files use these classes.
- A
Mobs keep three logged fields on
MobBody(entity/data/DataEntity.ts), each holdingContentItemDroprecords:equipment, keyedmainhand,offhand,head,chest,legs,feetandbody;containerSlots, theminecraft:inventorycontainer;inventory, a flat list of identifiers with no counts, which villager pickup writes.
equipmentInventorySlotsmaps an equipment slot to a container index, so a horse's armor is stored twice, once in its container and once inequipment.body. Each write logs the whole field. The record saves the same four fields as JSON in the actor'sjsprismarine:entitytag.Blocks keep their slots in the block entity.
inventory/containerStore.tsreads them for a screen or a command.
Slot names are parsed in many places
Each of these keeps its own table: command/host/inventory.ts and command/host/loot.ts (commands), entity/equipment.ts, entity/data/EntityRuntime.ts (COMPONENT_EQUIPMENT_SLOTS), entity/data/live.ts and entity/data/filterView.ts (filter domains), item/actorPort.ts, packages/items/src/projection.ts, and packages/entities (hooks.ts, sensors.ts, hazards.ts). They have already drifted apart. /loot replace … container.0 writes main slot 9, because loot.ts maps Java's container to Bedrock's slot.inventory, which starts after the hotbar.
Commands
/replaceitemand/loot replacereach players and blocks. A mob target reachesunsupported("item slots on anything but a player, which this server's inventories"), which prints the garbled sentence in the issue.- No command path sends a storage target to
setSlot. The NBT storage refusal there is unreachable from the command tree. - Every NBT-by-path verb (
getData,countData,mergeData,modifyData,removeData) refuses for every target.execute store … storagepasses a bare number with no type suffix.execute store … bossbarwrites into a storage namedbossbar/<id>instead of the boss bar./function … withis missing.
Decisions
A slot holds an
Itemor nothing. The count lives on theItemalone.ContainerEntryand the air placeholder go. Code that needs air on the wire builds it at the wire.One container class.
ItemContainerreplacesInventory. It has a fixed size, which an owner can change (a llama's capacity follows its strength). Eachsetreplaces the item and reportsbeforeandafterto one observer.One inventory per entity.
EntityInventoryholds named containers from a layout:Container Player Mob inventory36, hotbar first the minecraft:inventorysizearmor4 4 bodynone 1 offhand1 1 mainhandnone, the hand slot names an inventoryslot1 ender_chest27 none cursor1 none Equipment is a view over the containers:
equipment('mainhand')reads the hand slot for a player andmainhandfor a mob. A mount's equippable slots are aliases.equipment('body')on a horse reads its container slot, rather than a second copy of the stack. The crafting grid keepsCraftingInput, which already storesItem | nulland logs per slot.One change entry kind. Mob slots log
inventory-slotentries the way player slots do, and undo restores them through the same path. The whole-fieldequipment,containerSlotsandinventoryentries go. The alias map stays a logged field.The saved form stays readable. A mob's record keeps the
equipment,containerSlotsandequipmentInventorySlotskeys, written from the inventory. A record's legacyinventoryidentifiers andcarriedload into the container and the main hand. Player records do not change.One slot name parser.
inventory/slotAddress.tsreads Bedrock groups with an index (slot.hotbar 3,slot.saddle 0,slot.chest 2) and Java slot names (hotbar.3,container.12,armor.*,horse.saddle,horse.4,villager.2,player.cursor,contents) into{container, slot}addresses on one entity's inventory or a block. Every other table in the server reads its equipment slot names from here.Command storage is per level, outside the change log.
world/CommandStorage.tsmaps a resource location to an NBT compound, the way the scoreboard keeps plain data and logs nothing. The save writes it under the LevelDB keyjsprismarine:command_storageas a compound of SNBT strings, since BDS has no such record and none of its tools read it.Typed NBT lives in
@jsprismarine/nbt. The tag model, SNBT and paths are in that package, where the binary codec already is.Entity and block NBT by path stay out.
/data get entityneeds each entity's whole NBT form, which is its own project. It refuses with a sentence that reads correctly, and #3575 tracks it.The player inventory stays
HumanInventory. It is a subclass ofEntityInventoryoverPLAYER_LAYOUT, which sits besidemobLayoutininventory/EntityInventory.ts, and adds only the stack network id counter (assignStackNetworkId,assignStackNetworkIds) andisHotbarSlot. Keeping the name keeps theinventory/HumanInventoryentry point and every import of it, where a rename would touch each one for no change in behavior. The armor sums are onEntityInventory, since a mob's armor sits in the same container.EntityInventorytakes the layout's container names as a type parameter, soinventory.container('armor')on a player is never undefined, andcontainerNamedserves a name read off the change log or the wire.
Slices
| Slice | Change | Packages |
|---|---|---|
| 1 | Typed tags, SNBT and NBT paths | nbt, errors |
| 2 | Command storage: the level store and its save, /data … storage, /function … with, typed execute store, getData's result | commands, prismarine |
| 3 | ItemContainer and EntityInventory for players. Inventory and ContainerEntry go | prismarine |
| 4 | Mobs on EntityInventory, with per-slot log entries, the record kept readable, and replication from slot entries | prismarine, entity-goals, script-host as needed |
| 5 | slotAddress.ts, with /replaceitem, /loot replace and /item for players, mobs and blocks. setSlot takes no storage target. The other slot tables read from it | commands, prismarine, items, entities |
| 6 | Parity scenarios, user docs and an ADR for the slot model | parity, docs |
Slice 2 is independent of 3 to 5. Slices 3, 4 and 5 touch the same files and land in order.
Status
| Slice | State |
|---|---|
| 1 | Landed |
| 2 | Landed |
| 3 | Landed |
| 4 | Landed |
| 5 | Landed |
| 6 | Landed |
Slice 4: how mobs carry items
Recorded when slice 4 landed, on 2026-11-21.
- Every mob has an
EntityInventory.MobBody.inventoryis built frommobLayout(0), and the runtime sizes itsinventorycontainer from the activeminecraft:inventoryat spawn, at restore and on each tick. A store player's body has one too and leaves it empty, since the player's slots are the store player'sHumanInventory. - The main hand replaced
carried, and the container replaced the flat list. The goals'heldItem,carriedItemandsetCarriedItemread and writeequipment('mainhand')throughEntityRuntime.setHeldItem, which writes one of the item and nothing when the hand already holds it. The goals'inventory()andshareInventory()list theinventorycontainer one identifier per item (entity/data/mobInventory.ts), and villager work edits that list and writes back only the difference, so a stack the work did not touch keeps its name and enchantments. Pickups, gifts and crafts put stacks into the container. A mob takes off the ground only what its hand and its container can keep, and a stack handed to it that does not fit drops at its feet. A mob with nominecraft:inventoryno longer keeps an unbounded list. - Aliases replace the second copy.
MobBody.equipmentInventorySlotsstays the logged alias map, and every change to it pointsEntityInventory.setAliasat theinventoryslot. A horse's armor is one stack ininventoryslot 1, whichequipment('body')reads; its ownbodyslot stays empty while the alias is set. - A capacity change is logged.
inventorySizeis a logged body field. A shrink empties the slots it takes away first, each aninventory-slotentry, and logs the size after them, so an undo restores the size before it writes the stacks back. The runtime drops what a shrink took at the mob's feet, where Java'sAbstractHorse.createInventorywould lose it. - Equipment changes come from slot writes. A write to a slot an equipment slot reads, or a change of alias, moves
equipmentRevisionand callsonEquipmentChanged(slot, equipped), which fires the components'on_equipevents. An undo moves the revision and calls nothing. - Replication reads slot entries. A mob's membership entry derives its slots from the record's
containerSlotsandequipment, and its alias map fromequipmentInventorySlots.EntityReplica.equipmentAddressesresolves where each equipment slot reads, and replication sends equipment packets when a tick writes one of those slots or the alias map.EntityViewno longer carries equipment. - The record keeps its keys.
equipment,containerSlotsandequipmentInventorySlotsare written from the inventory in their old shapes, with an aliased slot in bothequipmentandcontainerSlotsas before.carriedandinventoryare no longer written. A legacycarriedfills the main hand whenequipmenthas none, and legacyinventoryidentifiers go into the container after its saved slots. A record that holds more than the container takes grows it on load, and the first tick's resize drops the rest at the mob's feet. - A hopper minecart fills slot by slot.
suckInItemskeepsinsertStack, Java'sHopperBlockEntity.addItemorder, becauseItemContainer.addtops up every matching stack before it takes an empty slot.
What slice 5 reads from a mob
mainhand,offhandandbodyare one-slot containers.armoris head, chest, legs, feet.- A mount's
inventorycontainer is theminecraft:inventoryof its tamed group: the horse's 2 slots (saddle 0, armor 1), the donkey's 16 (saddle 0, chest slots after it), the llama's 16 less 3 for each strength point it lacks (carpet in slot 1), and the camel's one saddle slot, sized from itsminecraft:equippable. An untamed horse has no container. - Equipping horse armor or a carpet into its container slot aliases
bodyto that slot, soequipment('body')andinventoryslot 1 are the same stack. The saddle has no equipment slot: it isinventoryslot 0 and nothing else. A parser that writesequipment('body')writes the container slot whenever the alias is set.
Slice 5: how commands reach slots
Recorded when slice 5 landed, on 2026-11-21.
- A Java name is a number, and the holder reads it.
inventory/slotAddress.tskeeps Java 26.3'sSlotRangestable: each name stands for the numbers Java gives it (hotbar.0is 0,inventory.0is 9,enderchest.0is 200,armor.feetis 100), and the holder answers a number the way Java'sgetSlotdoes. Socontainer.0is a player's hotbar slot 0 and a chest minecart's first slot, and/loot replace … <count>walks on from the number, as Java'sLootCommanddoes. The parity suite reads the table off Java's class file.villager.Nandhorse.saddle, which 26.3 renamed, read asmob.inventory.Nandsaddle. - A mob's container means what its
container_typesays.horseis a mount's, whose chest slots are the container slots itsminecraft:equippabledoes not claim, there only while it hasminecraft:is_chested.inventory, the default, is a villager's or a piglin's pocket,mob.inventory.N. Any other type, such asminecart_chest, is a containercontainer.Nreaches. Bedrock'sslot.inventory Nis a mob's whole container, andslot.equippable NtheNth slot itsminecraft:equippablelists. - A mount's armor goes where its screen shows it.
armor.bodyon a horse or a llama resolves to the container slot of its first non-saddle equippable entry and sets thebodyalias there, so the armor is one stack, as equipping it by hand leaves it. - The command seam takes every target.
SlotTargetis a block or an entity, with no storage form.setSlot,copySlotsandapplyItemModifiertake every target a line names, and a target without the slot is skipped; the line fails only when none had it./loot replacerolls once for all its targets.setSlotreturns the slots it wrote and takes Java'sfillandoverridebeside Bedrock's modes. - Equipment slot names keep one home each. The parser reads equipment names from
entity/equipment.ts, which now holdsBEDROCK_EQUIPMENT_SLOT_NAMESbesideMOB_EQUIPMENT_SLOTS, rather than holding them itself:equipment.tsimports nothing from the inventory, so the parser can import it without a cycle.EntityRuntime's event names andactorPort's armor index read from there and frommobEquipmentAddress. A player's and a mob's filter domains sharefilterDomainStackinentity/data/filterView.ts.@jsprismarine/entitiesholds its seven component slot names once, asENTITY_EQUIPMENT_SLOT_NAMES. Two tables stay:@jsprismarine/items'WEARABLE_SLOTS, since that package depends on neither, and@jsprismarine/commands'ENTITY_EQUIPMENT_SLOTS, which is the client's enum. - Three gaps have issues. Item modifiers on
/item(#3607),horse.chestandplayer.crafting.N(#3608), andexecute if items, which reads its slots as an NBT path (#3609). - Read from the class files, not confirmed by a run. That
/item replacewith one stack writes only the first slot a wildcard covers (ItemProvider.of), thatoverrideempties the rest (orElseProvide(EMPTY)), and that each target gets the stacks from the start. That/item … fromcopies empty source slots, whichSlotCollection.itemCopiessuggests. Thatslot.equippable Ncounts the equippable list in order; a llama declares its one carpet slot asslot: 1.
Open questions
- Bedrock sends a mob's inventory screen (
ContainerOpenwithWindowTypes.HORSE) and has anItemStackRequestcontainer for it. The server sends neither, so a Bedrock player cannot open a horse. A Java player can:player_command's inventory action opens the screen of the tamed mount it rides, whose saddle and armor slots take what itsminecraft:equippableaccepts and whose chest slots take any stack. - An
Itemhas no keep-on-death flag, item lock or script dynamic properties, so a script that puts a stack carrying them into a mob's container gets it back without them, as a player's inventory already did. AContentItemDropcarried them before slice 4. - Stack network ids are written onto the stored
Item. They are Bedrock wire state, and a per-session table keyed by container and slot would keep them out of the world model. This plan leaves them where they are.