Creating a simple GUI
Setting up the GUI
public class MyGuiClass {
public static Gui create() {
return new Gui.Builder(MenuType.GENERIC_9x6, Component.text("title"))
.addFlags(GuiFlag.DISABLE_ADVANCEMENTS, GuiFlag.DISABLE_ITEM_PICKUP)
.set(SlotPosition.top(3), GuiButton.of(ItemStack, (view, clickType) -> {
// Logic
}))
.set(SlotPosition.top(7), GuiButton.of(ItemStack, (view, clickType))
.build();
}
}
Afterwards open it any time like so:
GuiManager.open(Player, MyGuiClass.create());
Adding a Paginated Elements Layer:
public static Gui create() {
int[] slots = {
1, 2, 4, 5, 6, 8, 9
};
PaginatedElements elems = new PaginatedElements(elementsList, slots, GuiView.Segment.TOP);
return new Gui.Builder(MenuType.GENERIC_9x6, Component.text("title"))
.addFlags(GuiFlag.DISABLE_ADVANCEMENTS, GuiFlag.DISABLE_ITEM_PICKUP)
.addLayer(elems)
.set(SlotPosition.top(3), GuiButton.of(ItemStack, (view, clickType) -> {
// Logic
}))
.set(SlotPosition.top(7), GuiButton.of(ItemStack, (view, clickType))
.build();
}
You can also extend AbstractGui in case you dont want to use builder.
public class MyGui extends AbstractGui {
public MyGui() {
super(MenuType.FURNACE, Component.text("title"));
}
@Override
protected void init() {
/*
set(..)
addFlag(..)
etc
*/
}
@Override
protected void onOpen() {}
@Override
protected void onClose() {}
}
03 October 2025