Menus
A Menu is an in-game GUI built from dialogs: pages of buttons, where each button runs Kotlin-declared commands on the server. Buttons work for every player, operator or not.
In game: kits.open(), "Help" opens its page and "Done" closes the menu
- Objectives:
<pack>.menu.<name>, with thetriggercriterion. - Storage: none.
- Entities: none.
- Forceloaded chunks: none.
- Every tick:
menu_<name>_tickenables the trigger for every player and runs the dispatcher for the players who clicked. - Load and files:
menu_<name>_loadcreates the objective. Each page is a dialog, each button a function called bymenu_<name>_dispatch.pauseScreenadds the menu to#minecraft:pause_screen_additions,smithedadds thesmithed:data_packsdialog and the#smithed:data_packstag.
Buttons
button(label) { ... } runs its block as the clicking player, at their position. reopen = true shows the page again afterwards, handy for counters or toggles.
tooltip sets the text shown on hover, buttonWidth and columns control the page layout.
Pages and links
page(title) { ... } adds a button opening a sub-page. Its exit button goes back to the parent page, the root page exit button closes the menu. link(label, url) opens a website after the game's confirmation screen.
Pages are generated at data/<namespace>/dialog/<menu>.json and data/<namespace>/dialog/<menu>_<page>.json.
Opening a menu
open(targets) shows the root page, to @s by default. Each page's dialog works anywhere a dialog is expected, such as dialogShow or a text click event.
Pause screen and Smithed menu
pauseScreen = true adds the menu to the pause screen through the #minecraft:pause_screen_additions dialog tag.
smithed = true lists the menu in the shared data pack menu of the Smithed convention, so every compatible pack sits behind a single "Data Packs..." pause screen button. The root exit button then goes back to that list.
How it works
A dialog button can only run commands with the clicking player's permissions, and /function needs operator rights. So every button runs trigger <namespace>.menu.<name> set <n> instead, which any player can use. The menu generates:
- one function per button,
- a
loadfunction creating the trigger objective, - a
tickfunction enabling the trigger for all players and running the matching button function for each player who clicked, then resetting their score.
A menu without buttons, only pages and links, generates no function at all.
