Aller au contenu
galdurdocs

GaldurItemGrid

classclient uniquementdepuis 0.1.0

com.galdurstudio.galdurui.api.widget.GaldurItemGrid

Pas encore traduit : texte d’origine en anglais.

Themed scrolling item grid, to show thousands of items with their amounts: a storage network's contents, a catalogue, a recipe list...

These are not real menu slots: the grid only shows a list of Entry and reports clicks. The mod keeps the list up to date (from server packets, for instance), filters and sorts it, and sends the server what the player wants to do with a click. The list is read every frame: it can change at any time without rebuilding the widget.

Example.java
List<GaldurItemGrid.Entry> contents = ...;   // kept up to date by the modGaldurItemGrid grid = GaldurItemGrid.of(9, 6, () -> contents)        .onClick((index, entry, button, shift) -> askServer(entry, button, shift));
  • Rendering: only the visible rows are drawn (columns × rows cells), whatever the list size. Each cell uses the slot sprite and the short amount of GaldurItemSlot ("64", "1,2k", "64k").
  • Scrolling: by whole rows, with the wheel (one row per notch) or the scrollbar, which can be grabbed and dragged. The scrollbar only shows when the items do not fit.
  • Hover: accent_hover outline, accent veil and the item tooltip, with the exact amount above 1,000.
  • Click: left or right, with the Shift state, on an occupied cell.
  • Disabled (active = false): muted amounts, no click or hover; scrolling still works for browsing.
  • JEI / EMI: when one is installed, hovering an item and pressing R or U shows its recipes, on any screen.

Sizes from the theme: spacing.scrollbar_width. A cell is 18 × 18 pixels, like a vanilla slot.

public class GaldurItemGrid extends AbstractWidget
PAQUETapi.widget
CÔTÉclient uniquement
HÉRITE DEAbstractWidget

Champs 1

CELL_SIZE

static
public static final int CELL_SIZE

Side of a cell, frame included.

Constructeurs 1

GaldurItemGrid

protected
protected GaldurItemGrid(int columns, int rows, Supplier<List<Entry>> entries)

Prefer of().

PARAMÈTRES

columnsintnumber of columns (at least 1)
rowsintnumber of visible rows (at least 1)
entriesSupplier<List<Entry>>supplier of the item list, called every frame

Méthodes 7

of

static
public static GaldurItemGrid of(int columns, int rows, Supplier<List<Entry>> entries)

PARAMÈTRES

columnsintnumber of columns (at least 1)
rowsintnumber of visible rows (at least 1)
entriesSupplier<List<Entry>>supplier of the item list, called every frame

RENVOIEGaldurItemGrid — a grid of columns × rows visible cells, scrollbar included, at (0, 0) for a layout to place

onClick

public GaldurItemGrid onClick(ClickHandler onClick)

Sets the action triggered by a click on an occupied cell. Only one action is kept.

PARAMÈTRES

onClickClickHandlerreceives the index, the item, the button and the Shift state

RENVOIEGaldurItemGrid — this grid, for chaining

onScroll

public GaldurItemGrid onScroll(IntConsumer onScroll)

Sets the action called when the first visible row changes, to keep it when the widget is rebuilt (resize). Only one action is kept.

PARAMÈTRES

onScrollIntConsumerreceives the new first visible row

RENVOIEGaldurItemGrid — this grid, for chaining

getScrollRow

public int getScrollRow()

RENVOIEint — the first visible row

setScrollRow

public void setScrollRow(int row)

Scrolls the grid, clamped between the first and the last possible row.

PARAMÈTRES

rowintthe first row to show

getEntryAt

public Entry getEntryAt(double mouseX, double mouseY)

PARAMÈTRES

mouseXdoublemouse x
mouseYdoublemouse y

RENVOIEEntry — the item under the mouse, or null

getCellAreaAt

public Rect2i getCellAreaAt(double mouseX, double mouseY)

PARAMÈTRES

mouseXdoublemouse x
mouseYdoublemouse y

RENVOIERect2i — the screen-space bounds of the occupied cell under this point, or null

Types imbriqués 2

Entry

public record Entry(ItemStack stack, long amount)

An item shown by the grid.

ClickHandler

public interface ClickHandler

Action triggered by a click on an occupied cell.

© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyProduit non officiel. Non approuvé par Mojang ou Microsoft, ni associé à eux.