Skip to main content

Cookbook

Four patterns to adapt. Each lists the layouts involved and the fields to set in the Open GUI entry.

1. Scrollable list with arrows​

Layouts: composite, scrollable, two simple.

  1. Create a simple layout list_content holding the rows of the list. It can be taller than the window: put items at y 0 to 14.
  2. Create a scrollable layout list_scroll with innerId list_content, virtualWidth 9 and virtualHeight 15.
  3. In its buttons, add a direction UP button at x 8, y 0 and a DOWN button at x 8, y 5, each with step 1 and an arrow item.
  4. Create a simple layout border with a glass pane at x 8, y 1, count 4, direction down, displayName a single space.
  5. Create a composite layout main with children list_scroll then border, and set mainLayoutId to main.

The buttons stay anchored to the window and disappear when there is nothing left to scroll in their direction.

2. Paginated list​

Layouts: composite, simple, paginated.

  1. Create a paginated layout shop with itemsPerPage 21 and slots 10 to 16, 19 to 25 and 28 to 34.
  2. Add one item per product to items, with a LEFT_CLICK interaction that runs your command or trigger.
  3. In navigationButtons, add a PREVIOUS button at x 0, y 5, a NEXT button at x 8, y 5 and an INDICATOR at x 4, y 5 with the name <gray>{page_indicator}.
  4. Put a simple layout with the border in a composite below it.

For a real shop with prices and stock, use Shops, which fills a paginated layout for you.

3. Confirmation menu​

Shows closeMenu, executeReturn and the session history.

  1. Open the confirmation from the dangerous button: add a gui:open <confirm menu entry id> command to its interaction, or link the Open GUI entry in triggers.
  2. Create an Open GUI with guiType CUSTOM, size SIZE_27 and a simple layout.
  3. Add a green wool at x 2, y 1 with a LEFT_CLICK interaction running the command and closeMenu enabled.
  4. Add a red wool at x 6, y 1 with a LEFT_CLICK interaction and executeReturn enabled. It returns to whichever menu opened this one.

4. Quota deposit​

Shows storage slots, a required item and a trigger.

  1. Create a GUI Storage artifact.
  2. In the Open GUI storagePool, add a configuration with an id such as iron_bank, the artifact in entry, requiredItem an iron ingot, requiredAmount 32 and the unlock entry in onReachRequired. Set placeholder to a gray glass pane.
  3. In a simple layout, add an item at x 4, y 1 with storageId iron_bank. Its name and lore can use {stored_name}, {stored_amount} and {stored_max}.

Leave group empty for per-player storage, or choose a group entry (an island, a guild) to share the storage.

Tips​

  • Layer order in a composite is draw order: background first, buttons last.
  • Give every scrollable and paginated layout a unique id.
  • Use criteria on items to show or hide buttons per player.
  • Set the displayName of decorative panes to a single space to hide the vanilla item name.