Skip to content

ItemSlot ​

Since 2.2.1
Empty and populated ItemSlot examples beside fluid slots
The populated item slot renders an apple stack using the normal slot pipeline.

ItemSlot is a Minecraft item slot that integrates with the vanilla container system. It renders the held ItemStack, shows a hover highlight, and registers itself with the open AbstractContainerMenu for standard click-to-transfer behaviour. It also hooks into JEI, REI, and EMI when those mods are present.

INFO

Everything documented on UIElement (layout, styles, events, data bindings, etc.) applies here too.


Usage ​

java
// Bind to an item handler
var slot = new ItemSlot();
slot.bind(itemHandler, 0); // IItemHandlerModifiable + slot index
parent.addChild(slot);

// Or bind to a vanilla Slot directly
var slot2 = new ItemSlot(new Slot(inventory, 0, 0, 0));

// Phantom slot (XEI drag-drop support)
slot.xeiPhantom();

XML ​

xml
<!-- Basic slot (no handler — uses LocalSlot) -->
<item-slot/>

<!-- With an item pre-set for display in the editor -->
<item-slot id="minecraft:diamond" count="1"/>

<!-- Disable XEI recipe lookup -->
<item-slot allow-xei-Lookup="false"/>
XML AttributeTypeDescription
allow-xei-LookupbooleanWhether clicking the slot triggers XEI (JEI/REI/EMI) recipe lookup. Default: true.
id / count / NBT—Item attributes used to pre-fill the slot for editor display only.

Slot Style ​

INFO

hover-overlay

​

Texture drawn over the slot when the mouse hovers over it.

Default: ColorRectTexture(0x80FFFFFF) (semi-transparent white)

java
slot.slotStyle(style -> style.hoverOverlay(myTexture));

INFO

slot-overlay

​

Texture drawn over the slot background (always, or only when empty — see show-slot-overlay-only-empty).

Default: none (empty)

java
slot.slotStyle(style -> style.slotOverlay(myOverlay));

INFO

show-slot-overlay-only-empty

​

When true, the slot-overlay is drawn only when the slot is empty.

Default: true

java
slot.slotStyle(style -> style.showSlotOverlayOnlyEmpty(false));

INFO

show-item-tooltips

​

Whether hovering the slot shows the standard item tooltip.

Default: true

java
slot.slotStyle(style -> style.showItemTooltips(false));

INFO

is-player-slot

​

Marks this slot as a player inventory slot (used by the quick-move system).

Default: false

java
slot.slotStyle(style -> style.isPlayerSlot(true));

INFO

accept-quick-move / quick-move-priority

​

Whether this slot participates in shift-click quick-move, and its priority when multiple slots compete.

Defaults: true / 0

java
slot.slotStyle(style -> style.acceptQuickMove(true).quickMovePriority(1));

Value Binding ​

ItemSlot extends BindableUIElement&lt;ItemStack&gt;:

java
slot.bind(DataBindingBuilder.itemStack(
    () -> handler.getStackInSlot(0),
    stack -> handler.setStackInSlot(0, stack)
).build());

See Data Bindings for full details.


Fields ​

NameTypeAccessDescription
slotStyleSlotStyleprivate (getter)Current slot style.
slotSlotprivate (getter)The bound Slot.

Methods ​

MethodReturnsDescription
bind(IItemHandlerModifiable, int)ItemSlotBinds to an item handler at the given slot index.
bind(Slot)ItemSlotBinds to an existing vanilla Slot.
setItem(ItemStack)ItemSlotSets the displayed item and notifies listeners.
setItem(ItemStack, boolean)ItemSlotSets the displayed item; second param controls notification.
slotStyle(Consumer&lt;SlotStyle&gt;)ItemSlotConfigures style fluently.
xeiPhantom()ItemSlotEnables XEI (JEI/REI/EMI) phantom drag-drop on this slot.
xeiRecipeIngredient(IngredientIO)ItemSlotMarks this slot as a recipe ingredient in XEI recipe views.
xeiRecipeSlot()ItemSlotMarks this slot as a recipe slot with default IngredientIO.NONE.
xeiRecipeSlot(IngredientIO, float)ItemSlotMarks as recipe slot with given I/O type and chance.
getFullTooltipTexts()List&lt;Component&gt;Returns the combined item and custom tooltip lines.

Released under the MIT License.