Subsections of GUI

Creating a GUI

Creating a new GUI

Creates a new GUI and puts it in the result of the expression last created GUI

create [a] [new] gui with %inventory% [(and|with) ([re]move[e]able|stealable) items] [(and|with) shape %strings%]
create a gui with chest inventory with 3 rows named "My GUI":
  make all gui slots with air
open last created gui to player

empty gui
empty gui

The final argument lets you use templates to define the arrangement of interactive elements in your GUI.
These templates are strings, where each character represents a slot in the inventory:

  • "x" marks a slot to be filled with a specific element.
  • "-" leaves the slot empty.

For example, using the template "xxixx" with a funnel inventory will fill the first, second, fourth, and fifth slots with the element for "x", and the third slot with the element for "i".
This gives you detailed control over your GUI’s layout.

create a gui with chest inventory with 3 rows named "My GUI" with shape "xxxxxxxxx","x-------x","xxxxxxxxx":
  make gui slot "x" with dirt
open last created gui to player
Explanation:

Each string in the shape corresponds to a row in the GUI, and each character in the string represents a slot.

For example, “x” marks a slot to be filled with the specified element, while “-” leaves the slot empty.

In this case:

Row 1: All slots are filled (“xxxxxxxxx”).

Row 2: Only the first and last slots are filled (“x——-x”).

Row 3: All slots are filled again (“xxxxxxxxx”).

After creating the GUI, open last created gui to player displays the most recently created GUI to the player.

Finally, this will result in the following GUI:

gui shape
gui shape

Tutorial written by @GuavaDealer

Edit an already created GUI

Allows you to redefine interactive elements inside an already created GUI, including modifying existing elements, changing the layout, or adding new ones. When you click on an interactive GUI element (e.g., a slot in the GUI), the code inside the section will be executed. For example, clicking on a slot with a stone item could broadcast a message or perform an action. Here’s an example: The expression below creates an interactive element on the next empty inventory slot, which refers to the first available slot in the inventory that is not occupied by any item. For example, if slots 1, 2, and 3 are filled, the next empty inventory slot would be slot 4.

(change|edit) [gui] %gui%

Create an interactive element

Clicking this element triggers the execution of the code within its section. The expression below creates an interactive element on the next empty inventory slot.

(make|format) [the] next gui [slot] (with|to) [([re]mov[e]able|stealable)] %itemtype%

The following expression allows you to specify the value from the template or the slot number to create the element.

(make|format) gui [slot[s]] %strings/numbers% (with|to) [([re]mov[e]able|stealable)] %itemtype%
create a gui with chest inventory with 3 rows named "My GUI":
  make gui slot 1 with stone named "Click for hello world!":
    broadcast "Hello world!"

Delete an interactive element

(un(make|format)|remove) [the] next gui [slot]
(un(make|format)|remove) gui [slot[s]] %strings/numbers%
(un(make|format)|remove) all [[of] the] gui [slots]

When opening the GUI

The code inside this section will be executed after opening the GUI to the player.

run (when|while) open[ing] [[the] gui]
run (when|while) [the] gui opens
run on gui open[ing]

On gui close

The code inside this section will be executed after the GUI is closed by the player.

run (when|while) clos(e|ing) [[the] gui]
run (when|while) [the] gui closes
run on gui clos(e|ing)

Last created GUI

Returns the most recently created or edited GUI, depending on the context of the operation.

[the] last[ly] [(created|edited)] gui

Processing the results

The player’s open GUI

Returns the player’s currently open GUI.
If the player does not have a GUI open, it will return <none>.

%players%'s gui
gui of %player%'s

Check whether any GUI is open or not for the player

%players% (has|have) a gui [open]
%players% do[es](n't| not) have a gui [open]

The next GUI slot

Returns the number or letter of the template of the next GUI slot

%guis%'[s] next gui slot[s]
[the] next gui slot[s] of %guis%

Subsequent expressions can only be used in the GUI creation sections and creating an interactive element

[the] next gui slot

The name GUI inventory

%gui%'s gui(-| )name
gui(-| )name of %gui%

GUI Inventory Size

%gui%'s gui(-| )size
gui(-| )size of %gui%

GUI Template

%gui%'s gui(-| )shape
gui(-| )shape of %gui%

The ability to take items in the GUI

%gui%'s gui(-| )lock(-| )status
gui(-| )lock(-| )status of %gui%

Current, editable GUI

[the] gui

Clicked Slot

[the] gui(-| )raw(-| )slot

The hotkey of the clicked slot

[the] gui(-| )hotbar(-| )slot

GUI inventory that is being edited

[the] gui(-| )inventory

Action inside the GUI

For example, a player made a double click, which caused things to gather in the cursor slot.

[the] gui(-| )inventory(-| )action

Type of click

For example, a player made a click with the Shift key held down.

[the] gui(-| )click(-| )(type|action)

Cursor slot

[the] gui(-| )cursor[(-| )item]

The type of clicked slot

[the] gui(-| )slot(-| )type

The clicked item

[the] gui[(-| )(clicked|current)](-| )item

The expression used instead of the player inside the GUI section

[the] gui(-| )player

Be sure to use this expression inside the GUI or interactive element creation section instead of player, otherwise your code will not work as you expect it to.
Using player outside these sections may result in referencing the wrong player or causing unexpected behavior in your GUI logic.

Players who have a GUI open

[the] gui(-| )(viewer|player)s

ID of the clicked slot

[the] gui(-| )slot(-| )id

Subsequent expressions can only be used in the closing GUI section

Cancel the closure

Prevents the player from closing the GUI by automatically reopening it, preserving the GUI’s parameters

cancel [the] gui clos(e|ing)

Allow closure

Allows the player to close the GUI

uncancel [the] gui close(e|ing)