Skip to main content

Chest slot buttons with the hotbar swap

InvUI, which uses an entity chest screen as a menu (Building menu screens from an entity inventory), receives slot presses as item move requests. But when all 36 slots of the player inventory are full, the usual move methods stop working or become hard to use. This design avoids the problem with the hotbar swap (button.slot_N) and, on the same principle, checks as a pure add-on how to put nine buttons on one chest slot.

1. Results per slot button method with a full inventory​

MethodWith a full inventoryRule
Quick move button.container_auto_placeNo request is sentINP-41
Drop button.drop_one, cursor take button.container_take_all_place_allA request is sent. In a setup where the server cancels it, #hover_text of every slot of the window empties a few seconds later, which breaks a menu drawn from slot namesINP-44
Hotbar swap button.slot_NA request is sent and the slot names stayINP-42

The quick move and drop results are measurements of a custom server menu (SG). The hotbar swap was confirmed with button.slot_1 on the same server, and this design extends the check to a pure add-on and slot_1 to slot_9.

2. Does a pure add-on work​

It does. With only a resource pack and a behavior pack (Script API @minecraft/server 2.0.0), without a custom server, it worked in a local world on Windows 1.26.65.1 (HSB).

The difference from a custom server is that the request cannot be cancelled. A server rejects the request and leaves the hotbar as it was, but in an add-on world the swap really happens: the button item in the chest slot goes to the hotbar and the hotbar item comes into the chest slot. So the script watches the chest slot every tick, and when the button item is gone it looks for that item in hotbar slots 0 to 8 of the player. The slot number found is the button pressed, and the script puts both items back. Until then a hotbar item may show in the chest slot for a moment.

After the items were put back, the slot names (#hover_text) of the same window kept reading and the same window could be pressed again. Even 20 seconds after pressing the drop button of the same add-on 13 times, the slot names were still there. The slot names emptying (INP-44) appeared only in the server setup that cancels requests.

3. Setup​

Put the button as a direct child of a stack_panel that has collection_name. To put several buttons on the same slot, wrap each button in its own such stack_panel. A first version with nine buttons under one collection_panel sent no request when pressed, and the cause was not isolated.

"slot_button": {
"type": "button", "size": [ 18, 18 ], "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" }
]
},
"cell": {
"type": "stack_panel", "collection_name": "container_items", "size": [ 18, 18 ],
"controls": [ { "b@hsb_box.slot_button": { "collection_index": "$i" } } ]
}

The script recognizes the button item in the chest slot by its name, and when it is gone looks for it in the hotbar.

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;
bag.setItem(k, storage.getItem(SWAP_SLOT));
storage.setItem(SWAP_SLOT, marked("minecraft:paper", SWAP_MARK, `slot_${k + 1} pressed`));
return;
}
}

If the cursor holds an item, that item becomes the source of the swap (INP-42), so use this in a menu where no item stays on the cursor.

4. Nine buttons on one slot​

Nine buttons pointing at chest slot 0 were given button.slot_1 to button.slot_9, one each. Each button sent the hotbar slot of its own number (0 to 8) as the destination, and the script told the buttons apart by the destination slot. The guess that one slot can make nine buttons holds (INP-43).

Nine hotbar swap buttons drawn on one slot and the slot name label

These are the results of the user pressing 36 times with a real mouse in the order 1~9, 1~9, 9~1, 9~1 (Windows 1.26.65.1, with all 36 inventory slots full).

LayoutPresses that sent a requestDestination
18x18 buttons touching in a 3x3 block19 of 36Every request went to the hotbar slot of the pressed button
A 6 GUI pixel gap between buttons (spacing 24)All 36In the pressed order: 0~8, 0~8, 8~0, 8~0

Why presses disappeared in the touching layout is unknown. With a gap they did not disappear, so leave a gap between buttons. Results measured with an automation tool were also erratic in the touching layout. That measurement left 0.15 s between press and release (DBG-35).

5. Example add-on​

Download: [bedrock-research]hotbar-swap-buttons_v1.0.0.mcaddon
[bedrock-research]hotbar-swap-buttons v1.0.0 · 6.4 KB · Test item bwiki:hotbar_swap_buttons
  1. Open the file to import it. In a new world, turn on the behavior pack whose name starts with [bedrock-research]hotbar-swap-buttons-bp. The resource pack turns on with it as a dependency.
  2. Take "Hotbar Swap Buttons" from the Items category of the creative inventory.
  3. Use the item while sneaking to fill every empty slot so the inventory is full (/scriptevent bwiki:hotbar_swap_buttons_fill does the same).
  4. Use it normally to spawn an invisible chest entity in front of you (/scriptevent bwiki:hotbar_swap_buttons). Right click that spot to open it.
  5. Pressing buttons 1 to 9 on the left prints the pressed button and hotbar slot in chat, and the slot name label changes to the last press. The hotbar comes back unchanged. The Q button is a drop button for comparison.

Version history​

VersionChangeMeasured
v1.0.0Nine hotbar swap buttons on one slot (6 pixel gap) and a drop buttonWindows 1.26.65.1 local world, full inventory: all 36 real mouse presses went to the right hotbar slot (2026-12-01)

6. Open items​

  • With phone touch the hotbar swap buttons sent no request (Comparing chest slot press methods, INP-45). The cause is unknown, and gamepads were not measured.
  • Why presses disappear when buttons touch is unknown.
  • slot_2 to slot_9 were not measured on a custom server (the setup that cancels requests). The server must be able to read the destination slot to tell the buttons apart.
  • Why slot names empty after a drop (INP-44) is unknown.
Sources
idSourceLicenseCommitAccessed
repo-guideJSON UI comprehensive guide (this repository) (guide/)This project's material2026-11-13
private-researchPrivate research (-)-2026-11-13