Building chest UIs and inventory menus
"Chest UI" means two methods. The form method draws a script ActionFormData as a chest through a resource pack; no items move and the slots are only buttons. The real container method opens the chest window of an invisible entity, and the engine draws the real items in its slots. This page gathers only the facts needed to choose one and build it.
When to use it
| Goal | Method | When it does not fit, and the alternative |
|---|---|---|
| A screen with nothing put in or taken out, such as a shop or a choice menu, opened directly by the script | Form method (ActionFormData reskin) | If icons of custom items from other packs are needed, the entity inventory menu |
| Real items move, as in storage or trading | Real container (entity chest) | None. A form cannot move items |
| Draw any item icon (custom, other packs, 3D, glint) and change content without closing | Entity inventory menu (InvUI): an entity chest screen redrawn by a resource pack as a menu | If it must open with no player action, the form method |
| A script forces a chest window open for a player | Not possible on the release {code} | The form method, or the virtual container of the 26.70 preview (version conditions) |
| Show item icons on the HUD | Outside this guide | Showing server data on the HUD |
The two methods differ as follows.
| Topic | Form method | Entity inventory menu |
|---|---|---|
| Opening | The script opens it directly | One player action, pressing the entity, is needed |
| Icons | Texture path or numeric item ID | The engine draws the slot items. No numbers are needed |
| Changing content | Close and reopen the form | Slot changes by the script show at once in the open screen |
| Input that reaches the script | Button index | Slot actions only. Buttons are imitated with slot moves |
| Text, conditions, bars | Passed as form text | Passed as slot item names, lore and durability |
Minimal example
A menu with nine hotbar swap buttons on one entity chest slot. A player whose 36 inventory slots are all full can still press them. It comes from the example add-on hotbar-swap-buttons v1.0.0 (measured in a Windows 1.26.65.1 local world). The entity and UI files are the add-on's as they are, without the comparison drop button and the launcher item, and main.js keeps only the swap button part of the add-on script. Use the add-on's manifests (the behavior pack depends on the resource pack uuid and @minecraft/server 2.0.0, and scripts/main.js is the entry).
bp/entities/hotbar_swap_buttons_box.json:
{
"format_version": "1.21.90",
"minecraft:entity": {
"description": {
"identifier": "bwiki:hotbar_swap_buttons_box",
"is_spawnable": false,
"is_summonable": true
},
"components": {
"minecraft:inventory": {
"container_type": "container",
"inventory_size": 27,
"private": false,
"can_be_siphoned_from": false
},
"minecraft:collision_box": { "width": 1.2, "height": 1.2 },
"minecraft:physics": { "has_gravity": false, "has_collision": false },
"minecraft:pushable": { "is_pushable": false, "is_pushable_by_piston": false },
"minecraft:damage_sensor": { "triggers": { "cause": "all", "deals_damage": "no" } },
"minecraft:health": { "value": 1, "max": 1 }
}
}
}
bp/scripts/main.js:
import { world, system, ItemStack } from "@minecraft/server";
const BOX = "bwiki:hotbar_swap_buttons_box";
const TITLE = "Hotbar Swap Buttons";
const SWAP_MARK = "Swap button";
const SWAP_SLOT = 0;
const sessions = new Map();
const inventory = (entity) => entity.getComponent("inventory")?.container;
const say = (player, text) => player.sendMessage(`[HSB] ${text}`);
function marked(typeId, mark, line) {
const item = new ItemStack(typeId, 1);
item.nameTag = `${mark}: ${line}`;
return item;
}
const isMark = (item, mark) => item?.nameTag?.startsWith(`${mark}: `) ?? false;
function spotInFront(player) {
const view = player.getViewDirection();
const loc = player.location;
return { x: loc.x + view.x * 2, y: loc.y + 0.2, z: loc.z + view.z * 2 };
}
function startSession(player) {
const old = sessions.get(player.id);
if (old?.box.isValid) old.box.remove();
const box = player.dimension.spawnEntity(BOX, spotInFront(player));
box.nameTag = TITLE;
inventory(box).setItem(SWAP_SLOT, marked("minecraft:paper", SWAP_MARK, "not pressed"));
sessions.set(player.id, { box, swaps: 0 });
say(player, "Box spawned in front of you. Use it to open the screen.");
}
function watchSwap(player, session) {
const storage = inventory(session.box);
if (isMark(storage.getItem(SWAP_SLOT), SWAP_MARK)) return;
const bag = inventory(player);
for (let k = 0; k < 9; k++) {
if (!isMark(bag.getItem(k), SWAP_MARK)) continue;
const other = storage.getItem(SWAP_SLOT);
session.swaps += 1;
bag.setItem(k, other);
storage.setItem(SWAP_SLOT, marked("minecraft:paper", SWAP_MARK, `slot_${k + 1} pressed, total ${session.swaps}`));
say(player, `button.slot_${k + 1} pressed.`);
return;
}
storage.setItem(SWAP_SLOT, marked("minecraft:paper", SWAP_MARK, "lost and restored"));
}
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const session = sessions.get(player.id);
if (!session) continue;
if (!session.box.isValid) {
sessions.delete(player.id);
continue;
}
watchSwap(player, session);
}
}, 1);
system.afterEvents.scriptEventReceive.subscribe((event) => {
const player = event.sourceEntity;
if (player?.typeId !== "minecraft:player") return;
if (event.id === "bwiki:hotbar_swap_buttons") system.run(() => startSession(player));
});
rp/entity/hotbar_swap_buttons_box.entity.json:
{
"format_version": "1.10.0",
"minecraft:client_entity": {
"description": {
"identifier": "bwiki:hotbar_swap_buttons_box",
"materials": { "default": "entity_alphatest" },
"textures": { "default": "textures/entity/minecart" },
"geometry": { "default": "geometry.bwiki.hotbar_swap_buttons_empty" },
"render_controllers": [ "controller.render.default" ]
}
}
}
rp/models/entity/hotbar_swap_buttons_box.geo.json:
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.bwiki.hotbar_swap_buttons_empty",
"texture_width": 16,
"texture_height": 16,
"visible_bounds_width": 1,
"visible_bounds_height": 1,
"visible_bounds_offset": [ 0, 0.5, 0 ]
},
"bones": [ { "name": "root", "pivot": [ 0, 0, 0 ] } ]
}
]
}
rp/ui/_ui_defs.json:
{
"ui_defs": [
"ui/hsb_box.json"
]
}
rp/ui/chest_screen.json:
{
"namespace": "chest",
"small_chest_panel": {
"modifications": [
{
"array_name": "controls",
"operation": "insert_back",
"value": [ { "hsb_box_overlay@hsb_box.overlay": {} } ]
}
]
}
}
rp/ui/hsb_box.json:
{
"namespace": "hsb_box",
"face": {
"type": "image", "texture": "textures/ui/White", "size": [ "100%", "100%" ], "layer": 40, "color": "$face_color", "alpha": 0.85,
"controls": [
{ "n": { "type": "label", "layer": 41, "localize": false, "color": [ 1, 1, 1 ], "text": "$n", "font_scale_factor": 0.8 } }
]
},
"slot_button": {
"type": "button", "size": [ 18, 18 ], "anchor_from": "top_left", "anchor_to": "top_left", "focus_enabled": false,
"default_control": "default", "hover_control": "hover", "pressed_control": "pressed",
"bindings": [ { "binding_type": "collection_details", "binding_collection_name": "container_items" } ],
"button_mappings": [
{ "from_button_id": "button.menu_select", "to_button_id": "$to", "mapping_type": "pressed", "consume_event": false },
{ "to_button_id": "button.container_slot_hovered", "mapping_type": "pressed" }
],
"controls": [
{ "default@hsb_box.face": { "$face_color": [ 0.2, 0.25, 0.55 ] } },
{ "hover@hsb_box.face": { "$face_color": [ 0.3, 0.45, 0.85 ] } },
{ "pressed@hsb_box.face": { "$face_color": [ 0.2, 0.7, 0.3 ] } }
]
},
"slot_name": {
"type": "label", "size": [ 160, 10 ], "layer": 40, "localize": false, "color": [ 0.1, 0.1, 0.1 ], "text": "#text",
"anchor_from": "top_left", "anchor_to": "top_left",
"bindings": [
{ "binding_type": "collection", "binding_collection_name": "container_items", "binding_name": "#hover_text", "binding_condition": "always" },
{ "binding_type": "view", "source_property_name": "('slot: ' + #hover_text)", "target_property_name": "#text" }
]
},
"cell": {
"type": "stack_panel", "collection_name": "container_items", "size": [ 18, 18 ], "anchor_from": "top_left", "anchor_to": "top_left",
"controls": [ { "b@hsb_box.slot_button": { "collection_index": "$i" } } ]
},
"name_cell": {
"type": "stack_panel", "collection_name": "container_items", "size": [ 170, 10 ], "anchor_from": "top_left", "anchor_to": "top_left",
"controls": [ { "t@hsb_box.slot_name": { "collection_index": "$i" } } ]
},
"buttons": {
"type": "panel", "size": [ 280, 66 ],
"anchor_from": "top_left", "anchor_to": "top_left", "offset": [ 7, 100 ],
"controls": [
{ "s1@hsb_box.cell": { "offset": [ 0, 0 ], "$i": 0, "$to": "button.slot_1", "$n": "1" } },
{ "s2@hsb_box.cell": { "offset": [ 24, 0 ], "$i": 0, "$to": "button.slot_2", "$n": "2" } },
{ "s3@hsb_box.cell": { "offset": [ 48, 0 ], "$i": 0, "$to": "button.slot_3", "$n": "3" } },
{ "s4@hsb_box.cell": { "offset": [ 0, 24 ], "$i": 0, "$to": "button.slot_4", "$n": "4" } },
{ "s5@hsb_box.cell": { "offset": [ 24, 24 ], "$i": 0, "$to": "button.slot_5", "$n": "5" } },
{ "s6@hsb_box.cell": { "offset": [ 48, 24 ], "$i": 0, "$to": "button.slot_6", "$n": "6" } },
{ "s7@hsb_box.cell": { "offset": [ 0, 48 ], "$i": 0, "$to": "button.slot_7", "$n": "7" } },
{ "s8@hsb_box.cell": { "offset": [ 24, 48 ], "$i": 0, "$to": "button.slot_8", "$n": "8" } },
{ "s9@hsb_box.cell": { "offset": [ 48, 48 ], "$i": 0, "$to": "button.slot_9", "$n": "9" } },
{ "name0@hsb_box.name_cell": { "offset": [ 80, 4 ], "$i": 0 } }
]
},
"gate": {
"type": "panel", "size": [ "100%", "100%" ],
"ignored": "(not ($t = 'Hotbar Swap Buttons'))",
"controls": [ { "buttons@hsb_box.buttons": {} } ]
},
"overlay": {
"type": "panel", "size": [ "100%", "100%" ], "layer": 30,
"$t": "$container_title",
"controls": [ { "gate@hsb_box.gate": {} } ]
}
}
Run /scriptevent bwiki:hotbar_swap_buttons to spawn an invisible chest entity in front of you, and press that spot to open it. Pressing buttons 1 to 9 prints the pressed button in chat, changes the slot name label, and the hotbar returns to its place. This example inserts the window only into the PC screen (chest.small_chest_panel), because the hotbar swap sends no request on touch (INP-45).
Must match
Entity chest screen
- The entity
minecraft:inventoryhascontainer_type: "container"andprivate: false. Only then does it open throughchest_screen.json. Withinventory_sizeabove 27 only 27 cells are drawn, but the other slots are still read by bindings (the examples use up to 243) (HOST-16). - Do not redeclare
small_chest_screen; insert the window into thecontrolsofchest.small_chest_panel(PC) andpocket_containers.panel(touch) with amodificationsinsert_back. The file paths are the vanilla ones,ui/chest_screen.jsonandui/pocket_containers.json(HOST-49, MOD-02). - The window title
$container_titleis the entity nameTag. A direct comparison in a binding expression is always false (HOST-19). - To pick a window by name, put a copy variable
"$t": "$container_title"on the parent control and compare it in the child'signored.ignoredis evaluated in the parent scope (HOST-48, FILE-34). - A control that reads a slot is a direct child of a
stack_panelwithcollection_name: "container_items"and hascollection_index. On a deeper child it givesUnknown property [collection_index](COL-06). - Keep the sum of the pack's ancestor
layervalues at 94 or less for a window holding item renderers. From 99 only the icons stopped drawing (ANI-38). - To hide the vanilla cells, add to the
bindingsof each vanilla control to hide a view binding that reads#entity_ui_vanilla_visiblefrom the marker controlentity_ui_hide_vanilla, and put the marker inside the window picked withignored. Keep these names to coexist with packs outside the wiki (MOD-08, BND-25).
Receiving presses in the script
- A hotbar swap button has all of: a
collection_detailsbinding, apressedmapping frombutton.menu_selecttobutton.slot_N(N is 1 to 9), and a mapping{ "to_button_id": "button.container_slot_hovered", "mapping_type": "pressed" }without a source.button.slot_0sends no request (INP-42, INP-45). - For several buttons on one slot, wrap each button in its own
stack_panelwithcollection_name, and leave a 6 GUI pixel gap between buttons (INP-43). - A quick move button sends
button.menu_selecttobutton.container_auto_placewithconsume_event: false. The script counts a press when the marker item in the slot is gone. - With a drop button (
button.drop_one), do not set the#visibleof that button or its ancestors by binding. Hide its look with the#visibleof a sibling, block it with#enabledor#alpha, and pick pages withignored(INP-46).
Reading values from slots
- A data item that carries a value is paper with only a name, not locked (paper has no vanilla description line). Read the name with
(#hover_text - '§o' - '§f' - '§r')(HOST-17). - A value read from a slot name that became an integer shows as text only with
'v'or'§r'in front. Durability values never show as text, so put them in the name or lore as text{measured}. - A real literal starts with a dot (
.1).0.1is 0 (EXP-27). Give#clip_ratiothrough a binding that reads a slot value. Fixed values left the bar empty. #hover_textempties for about 50 to 100 ms on every slot press, so read data slots shown on screen through a BND-18 latch and test empty slots with(#item_id_aux < 1)(HOST-50).
Item icons (form method)
- The
#item_id_auxvalue isnumeric ID * 65536 + data value, and the enchantment glint adds 32768 (ANI-06, ANI-23{unverified}). - Convert the button icon string to a number with
(#form_button_texture - 0).* 1gives an empty string and%is not an operator (EXP-16, EXP-31, EXP-02).
{ "binding_type": "view", "source_property_name": "(#form_button_texture - 0)", "target_property_name": "#item_id_aux" }
- Per slot, build an image when the first 8 bytes of the icon string are
textures, and aninventory_item_rendererotherwise (PAT-11, PAT-14). - Pick the screen size with a marker at the very start of the title that puts
§before every character (§c§h§e§s§t§2§7§rand so on), and do not build unused size templates, usingignored. The cells aregrid+collection_name: form_buttons(PAT-14). - For an icon fixed in the resource pack, put
#item_name(the identifier written literally) together with#item_id_auxin theproperty_bag. A numeric constant alone of 257 or more is read as an old numeric ID and draws a different item (ANI-51).
Slot decoration (badges over vanilla slots)
- Put an invisible marker starting with
§k§rinside the item name and find it in the slot's#hover_textwith a contains test. Example:(not ((#hover_text - '§k§l§r§1§r') = #hover_text)) * 1{record}. - Insert into both slot templates with
insert_front:container_item(ui_common.json) andinventory_container_item(inventory_screen.json). The slot background is layer 1 and the item 7, so a back decoration goes at 6 and a front one at 9{record}.
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| Form slot icons are empty | * 1 on the icon string. String * number is an empty string | (#form_button_texture - 0) (EXP-16, EXP-31) |
An Invalid expression assert when the screen opens, or a condition is ignored | % was used | Make remainders with (a - ((a / b) * b)) (EXP-02, EXP-38) |
| A different item is drawn | A numeric ID table from another version, or a number shifted by the custom item count | Rebuild the table for the target version and add C. Draw custom and other-pack items with texture paths or entity slots (HOST-17, C-33) |
A numeric icon written in property_bag is wrong | A numeric constant of 257 or more is read as an old numeric ID | Write the identifier literally in #item_name (ANI-51) |
| With another server form pack on, only one shows | Both redeclare long_form at the same path | Switch to wrapping or modifications only (MOD-21) |
| The chest screen does not open | container_type is not container, or private: true | The values of HOST-16 |
| The vanilla chest screen opens instead of my window | Another pack redeclared small_chest_screen, or the name was compared in a binding expression | Insert with modifications and pick with a copy variable and ignored (HOST-49, HOST-48) |
| Names and counts show in the window but icons do not | The ancestor layer sum is high | Keep the sum at 94 or less (ANI-38) |
| Buttons do nothing for a player with a full inventory | Quick move sends no request when the inventory is full | Hotbar swap (INP-41, INP-42) |
| A hotbar swap button sends no request even on PC | No collection_details or no sourceless container_slot_hovered mapping, or the target is slot_0 | Set all three (INP-45) |
| Buttons do not react on a phone | On touch a button.slot_N target sends no request | Take touch presses with quick move or drop (INP-45) |
| Every slot label disappears after a drop | The #visible of the drop button or an ancestor is set by binding | Use #enabled, #alpha and ignored (INP-46) |
| Labels or figures flicker on every press | #hover_text empties briefly on every press | BND-18 latch, empty slots by (#item_id_aux < 1) (HOST-50) |
| A grey grid flickers when a slot item changes | The vanilla cells were hidden with visible: false | Put a container_items grid of 27 empty panel cells behind the window (HOST-50) |
| A bar is always empty or always full | A decimal with a leading digit such as 0.1 or 1.0 is an integer | Start with a dot such as .1 (EXP-27) |
| Some presses of the nine buttons get lost | The buttons touch each other | A 6 pixel gap (INP-43) |
| Esc or back does not close the window | button.menu_cancel is mapped globally | Map only the keys needed and keep a separate close button |
Items come out of entity slots despite lockMode | Locks work only in the player inventory | Cover the slot with a toggle, or have the script restore it every tick (HOST-20) |
| Badges do not show on bag slots | inventory_container_item has its own controls | Insert into both templates |
Version conditions
- Numeric item IDs (measured on 1.26.63): custom items are inserted at 853. Vanilla items at 853 and above shift by C, the custom item count of all packs; custom items start at 853, and custom blocks go down from -9745. The vanilla numbers of 1.26.6x match
vanilla_items.nbtof gophertunnel 1.63.0. The boundary on other versions differs by source (C-33 is open), and the numbers themselves change (apple is 883 on 1.26.65.1 and 887 on Preview 26.70.26). A script cannot read the game version, so fit a numeric table to one target version. - The numeric constants in vanilla
beacon_screen.json(diamond 264 and so on) are old numeric IDs. A number of 257 or more written in aproperty_bagis read as an old ID on world entry and rewritten to the current number, so vanilla draws them right (ANI-51). Values put in through bindings are current numbers. So do not copy these constants into bound values. - Opening a container screen from a script: there is no way on the release up to 1.26.63
{code}. Betas from@minecraft/server2.13.0-beta.1.26.70-preview.24in the 26.70 preview haveworld.virtualContainerManager(1 to 54 slots, needs the "Beta APIs" experiment), and its screen file isui/virtual_container_screen.json. The changelog says this file will change and should not be edited. This wiki has not tested it in game{unverified}. - Custom block containers: on Windows 1.26.65 with the experiment "Upcoming Creator Features" on, a block with
container: { "slot_count": 3 }inminecraft:block_entityopened a three-slot chest UI when used{measured}. It was not tested as a block menu.
How to check
- Turn on the Content Log GUI in the Creator item of settings and enter the world. Check that there is no
Unknown property [collection_index],UI control reference not foundorExpected variable not found in ancestor tree. The Windows release client does not logInvalid expressionfor%expressions, so check expressions separately even when the log is clean. - Newly added files and files newly registered in
_ui_defs.jsonare read only after entering the world again. Edits to files already read apply on a UI reload. The#item_nameicon conversion runs only once when entering the world (ANI-51). If the UI does not change, restart the game. - Open the menu entity and check that your window appears, then open an unnamed ordinary chest and check that the vanilla screen is unchanged.
- Press the buttons one by one and check that the script chat or the slot name label changes. Press with a full inventory and with free slots, and on PC and on a phone, separately.
- After many presses, check that every slot label is still there. If they disappear, see INP-46.
- Compare a numeric ID icon with the same item drawn next to it through a texture path or an entity slot. To see a number range directly, draw a range such as 840 to 903 with the
item-aux-probeadd-on (turn other add-ons off).
Further reading
- Chest UI: Chest-UI structure, icon expressions, numeric ID tables, entity chests opened by a server
- Inventory-style menus and slot decoration: vanilla screen values, slot badges, block workstation windows
- Reskinning server forms: entry structure and fixed indexes of the form method
- Building menu screens from an entity inventory: screen routing, reading slot values, ways to open, example add-ons
- Chest slot buttons with the hotbar swap, Comparing chest slot press methods, Intercepting user input in InvUI
- Inferring numeric item IDs (aux) from the Script API: number layout rules and drawing from slots without numbers
- Item renderer, Conflict table (C-33)
- Rules: HOST-16, HOST-17, HOST-19, HOST-20, HOST-48, HOST-49, HOST-50, INP-41, INP-42, INP-43, INP-45, INP-46, ANI-06, ANI-23, ANI-38, ANI-51, EXP-02, EXP-16, EXP-27, EXP-31, EXP-38, COL-06, BND-18, BND-25, FILE-34, MOD-02, MOD-08, MOD-21, PAT-11, PAT-14
| id | Source | License | Commit | Accessed |
|---|---|---|---|---|
repo-guide | JSON UI comprehensive guide (this repository) (guide/) | This project's material | 2026-11-13 | |
private-research | Private research (-) | - | 2026-11-13 | |
repo-chest-ui | Chest-UI analysis (this repository) (chest-ui/) | This project's material | 2026-11-13 | |
chest-ui | Chest-UI | CC BY 4.0 (confirmed in the repository License file) | 115d95c | 2026-11-13 |
bedrock-wiki | Bedrock Wiki | CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) | 0930b39 | 2026-11-13 |
bedrock-samples | Mojang bedrock-samples | Minecraft EULA applies, (c) Mojang AB. All rights reserved | 15701fa9 (guide baseline 46ba6ea) | 2026-11-13 |
repo-ore-ui-loading | Ore UI loading research (this repository) (ore-ui-loading/) | This project's material | 2026-11-13 |