Skip to content

GaldurMenu

abstract classclient & serversince 0.1.0

com.galdurstudio.galdurui.api.menu.GaldurMenu

Base of a slot menu (logic side, client and server), ready to be shown by a GaldurContainerScreen. It places slot grids and the player inventory, and handles Shift-click between them.

Example.java
public class ChestMenu extends GaldurMenu {    private final Container chest;    public ChestMenu(int id, Inventory player, Container chest) {        super(MY_MENUS.CHEST.get(), id);        this.chest = chest;        addSlotGrid(chest, 0, 9, 3, 8, 18);   // 27 slots        addPlayerInventory(player, 8, 84);    // always last    }    public boolean stillValid(Player player) {        return chest.stillValid(player);    }}

Rule: add the container slots first (addSlotGrid or addSlot), then the player inventory (addPlayerInventory). Every slot added before the player inventory counts as a container slot for Shift-click.

Coordinates are Minecraft's: GUI pixels from the top-left corner of the menu panel, pointing at the top-left corner of the 16 × 16 item; the slot frame extends one pixel around it.

public abstract class GaldurMenu extends AbstractContainerMenu
PACKAGEapi.menu
SIDEclient & server
EXTENDSAbstractContainerMenu

Fields 2

SLOT_SIZE

static
public static final int SLOT_SIZE = 18

Distance between two neighbouring slots: 16 for the item and 2 for the frames.

HOTBAR_GAP

static
public static final int HOTBAR_GAP = 4

Vertical gap between the three inventory rows and the hotbar.

Constructors 1

GaldurMenu

protected
protected GaldurMenu(MenuType<?> type, int containerId)

PARAMETERS

typeMenuType<?>the menu type, registered by the mod
containerIdintthe window id given by Minecraft

Methods 4

addSlotGrid

protected
protected void addSlotGrid(Container container, int firstIndex, int columns, int rows, int x, int y)

Adds a grid of slots, row by row, left to right.

PARAMETERS

containerContainerthe container whose slots are shown
firstIndexintcontainer index of the first grid slot
columnsintnumber of columns
rowsintnumber of rows
xintx of the first slot (top-left of the item)
yinty of the first slot

THROWSIllegalStateException — if the player inventory was already added

addPlayerInventory

protected
protected void addPlayerInventory(Inventory inventory, int x, int y)

Adds the player inventory: three rows of nine, then the hotbar 4 pixels lower. Call once, after the container slots.

PARAMETERS

inventoryInventorythe player inventory
xintx of the first slot (top-left of the item)
yinty of the first row; the hotbar is at y + 3 * 18 + 4

THROWSIllegalStateException — if the player inventory was already added

getContainerSlotCount

public int getContainerSlotCount()

RETURNSint — the number of container slots, or -1 until the player inventory is added

quickMoveStack

public ItemStack quickMoveStack(Player player, int index)

Shift-click: moves the stack from the container to the player inventory (hotbar first), or from the player inventory to the container, like a vanilla chest. Moves nothing if the menu has no player inventory.

PARAMETERS

playerPlayer—
indexint—
© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyNot an official Minecraft product. Not approved by or associated with Mojang or Microsoft.