Aller au contenu
galdurdocs

GaldurItemSlot

classclient uniquementdepuis 0.1.0

com.galdurstudio.galdurui.api.widget.GaldurItemSlot

Pas encore traduit : texte d’origine en anglais.

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
PAQUETapi.widget
CÔTÉclient uniquement
HÉRITE DEAbstractWidget

Champs 1

SIZE

static
public static final int SIZE

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

Constructeurs 1

GaldurItemSlot

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

Prefer of() or of().

PARAMÈTRES

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

Méthodes 4

of

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

PARAMÈTRES

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

RENVOIEGaldurItemSlot — 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.

PARAMÈTRES

onPressIntConsumerreceives the mouse button: 0 left, 1 right

RENVOIEGaldurItemSlot — this cell, for chaining

isValidClickButton

protected
protected boolean isValidClickButton(int button)

Accepts left and right clicks.

PARAMÈTRES

buttonint—

playDownSound

public void playDownSound(SoundManager handler)

An item cell does not play the button sound.

PARAMÈTRES

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