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.
| Call | What it does |
|---|---|
menu_open | Opens a menu for a player: a chest-like screen of rows (1 to 6) rows of nine, titled title, with these slots filled. |
menu_set | Changes slots of a menu this plugin opened, while the player still has it open; answers whether it was still open. |
menu_close | Shuts a menu this plugin opened; answers whether it was still open. |
menu_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
| Field | Type | Required |
|---|---|---|
player | player id (integer) | yes |
items | list of {slot, item, count?, components?} | no |
rows | whole number | yes |
title | string | no |
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}
menu_set
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
| Field | Type | Required |
|---|---|---|
player | player id (integer) | yes |
items | list of {slot, item, count?, components?} | no |
menu | whole number | yes |
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}
menu_close
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
| Field | Type | Required |
|---|---|---|
player | player id (integer) | yes |
menu | whole number | yes |
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.