Skip to content

GaldurItemSlot

classclient onlysince 1.0.0

com.galdurstudio.galdurui.api.widget.GaldurItemSlot

Themed item cell: an item icon and its short amount ("64", "1,2k", "64k", "1,2M"), usable in vanilla layouts.

This is a display cell, not a real menu slot: it moves no item and does not talk to the server. It shows items in large numbers (a storage network's contents, a recipe) and tells the mod when it is clicked; the mod decides what to do.

Like GaldurCheckbox, the widget reads the item and the amount every frame from suppliers, so the cell follows the contents without being rebuilt. The amount is a long, separate from the stack size, so it can go past 64 and even Integer.MAX_VALUE.

Example.java
GaldurItemSlot iron = GaldurItemSlot.of(() -> new ItemStack(Items.IRON_INGOT), () -> network.amount(iron))        .onPress(button -> button == 0 ? takeStack() : takeHalf());
  • Amount: hidden when it is 1, as in vanilla.
  • Tooltip: the item's own, as in an inventory, followed by the exact amount when it is shortened.
  • Click: left (0) or right (1), passed to the mod; Enter or Space count as a left click.
  • Disabled (active = false): muted amount, no click; the tooltip stays.
  • Empty: an empty stack shows an empty cell, without tooltip.
public class GaldurItemSlot extends AbstractWidget
PACKAGEapi.widget
SIDEclient only
EXTENDSAbstractWidget

Fields 1

SIZE

static
public static final int SIZE

Side of a cell, frame included, in pixels: the size of a vanilla slot.

Constructors 1

GaldurItemSlot

protected
protected GaldurItemSlot(Supplier<ItemStack> stack, LongSupplier amount)

Prefer of() or of().

PARAMETERS

stackSupplier<ItemStack>supplier of the shown item, called every frame
amountLongSuppliersupplier of the shown amount, called every frame

Methods 4

of

static2 overloads
public static GaldurItemSlot of(Supplier<ItemStack> stack)
public static GaldurItemSlot of(Supplier<ItemStack> stack, LongSupplier amount)

PARAMETERS

stackSupplier<ItemStack>supplier of the shown item, called every frame
amountLongSuppliersupplier of the shown amount, called every frame

RETURNSGaldurItemSlot — a cell that shows the stack size as amount

onPress

public GaldurItemSlot onPress(IntConsumer onPress)

Sets the action called when the cell is clicked. Only one action is kept.

PARAMETERS

onPressIntConsumerreceives the mouse button: 0 left, 1 right

RETURNSGaldurItemSlot — this cell, for chaining

isValidClickButton

protected
protected boolean isValidClickButton(int button)

Accepts left and right clicks.

PARAMETERS

buttonint—

playDownSound

public void playDownSound(SoundManager handler)

An item cell does not play the button sound.

PARAMETERS

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