Ids
The rules for screen and entry ids, what they are used for, and the derived ids that dropdowns, color pickers and list editors reserve.
On this page
Every screen and every entry has an id. Players never see ids; tests and logs use them.
The rules#
- An id matches
[A-Za-z0-9_.-]+: letters, digits,_,.and-. A bad id throwsIllegalArgumentExceptionfrombuilder(id)at once. - Entry ids are unique within one
MenuScreen: list entries, section children and footer entries together. A duplicate makesbuild()throwIllegalStateException. - Screen ids need not be unique, but a distinct id per screen makes tests and logs easier to read.
- The mod id you pass to
registerfollows stricter rules (see Register your menu).
What ids are for#
- Tests find entries by id:
host.click("save"),host.current().id(). - Your code can reach a typed entry from the screen:
(TextInput) screen.entry("name"). - Logs name the entry whose code failed, for example
Toggle 'sounds' value.
Derived ids#
Composite widgets build their parts from ordinary entries, with ids derived from their own. Keep these free on the same screen:
Widget with id x |
Reserves |
|---|---|
| Dropdown | x.picker (picker screen), x.list, x.cancel |
| ColorPicker | x.editor (editor screen), x.preview, x.red, x.green, x.blue, x.alpha, x.hex, x.done, x.cancel |
| StringListEditor | x.list, x.input, x.add, x.remove |
| Section | none: the header uses x itself |
A good habit is to use dotted ids for your own related entries too, such as zoomKey and zoomKey.reset.
Next steps#
- Test menus without Minecraft: ids in practice.