Host calls

Menus (GUI)

Chest-like screens of buttons that a plugin opens for one player.

Generated by tools/gen_api_docs.py; do not edit by hand. See host calls for how a call is made and how values are encoded. Each example shows the shape of a Wasm request with its required fields; the values in it are illustrative.

CallWhat it does
menu_openOpens a menu for a player: a chest-like screen of rows (1 to 6) rows of nine, titled title, with these slots filled.
menu_setChanges slots of a menu this plugin opened, while the player still has it open; answers whether it was still open.
menu_closeShuts a menu this plugin opened; answers whether it was still open.
fn menu_open(plugin: &str, player: PlayerId, rows: u8, title: &str, items: &[crate::menu::MenuItem]) -> Result<i32, String>

Opens a menu for a player: a chest-like screen of rows (1 to 6) rows of nine, titled title, with these slots filled. Answers the menu's id. Its clicks and its close reach this plugin as bus calls from rustmc:menu; nothing in it can be taken (see menu). It replaces whatever screen the player had open.

Wasm request

FieldTypeRequired
playerplayer id (integer)yes
itemslist of {slot, item, count?, components?}no
rowswhole numberyes
titlestringno

Shape and limits, as the router words its errors: "rows should be 1 to 6".

Router notes: plugin is never sent by a Wasm guest: the server fills it in from the manifest name.

Reply: {"ok": ...} holding the Rust return value Result<i32, String>, encoded as in conventions. An Err arrives as {"error": "..."}.

{"call": "menu_open", "player": 7, "rows": 3}
fn menu_set(plugin: &str, player: PlayerId, menu: i32, items: &[crate::menu::MenuItem]) -> Result<bool, String>

Changes slots of a menu this plugin opened, while the player still has it open; answers whether it was still open.

Wasm request

FieldTypeRequired
playerplayer id (integer)yes
itemslist of {slot, item, count?, components?}no
menuwhole numberyes

Router notes: plugin is never sent by a Wasm guest: the server fills it in from the manifest name.

Reply: {"ok": ...} holding the Rust return value Result<bool, String>, encoded as in conventions. An Err arrives as {"error": "..."}.

{"call": "menu_set", "player": 7, "menu": 1}
fn menu_close(plugin: &str, player: PlayerId, menu: i32) -> Result<bool, String>

Shuts a menu this plugin opened; answers whether it was still open.

Wasm request

FieldTypeRequired
playerplayer id (integer)yes
menuwhole numberyes

Router notes: plugin is never sent by a Wasm guest: the server fills it in from the manifest name.

Reply: {"ok": ...} holding the Rust return value Result<bool, String>, encoded as in conventions. An Err arrives as {"error": "..."}.

{"call": "menu_close", "player": 7, "menu": 1}

From docs/api/reference/host-calls/menus.md in the RustMC repository at bbd81209ad.