GaldurMenu
abstract classclient & serversince 0.1.0com.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.
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.
Fields 2
SLOT_SIZE
staticDistance between two neighbouring slots: 16 for the item and 2 for the frames.
HOTBAR_GAP
staticVertical gap between the three inventory rows and the hotbar.
Constructors 1
GaldurMenu
protectedPARAMETERS
Methods 4
addSlotGrid
protectedAdds a grid of slots, row by row, left to right.
PARAMETERS
THROWSIllegalStateException — if the player inventory was already added
addPlayerInventory
protectedAdds the player inventory: three rows of nine, then the hotbar 4 pixels
lower. Call once, after the container slots.
PARAMETERS
y + 3 * 18 + 4THROWSIllegalStateException — if the player inventory was already added
getContainerSlotCount
RETURNSint — the number of container slots, or -1 until the player inventory is added
quickMoveStack
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