SlotWidget
The SlotWidget
represents an interactive item slot within a container GUI. This widget supports configurable properties such as whether items can be taken or placed, customizable hover overlays and tooltips, and integration with JEI/REI/EMI systems for displaying ingredient details. It can be configured to represent a slot in either a standard inventory container or via an item transfer handler.
Note
You cannot modify slot widget size.
Basic Properties
Field | Description |
---|---|
canTakeItems | Indicates if items can be extracted from the slot (modifiable via setter) |
canPutItems | Indicates if items can be inserted into the slot (modifiable via setter) |
drawHoverOverlay | Determines whether a hover overlay is drawn when the mouse is over the slot |
drawHoverTips | Determines whether tooltips are shown when the mouse hovers over the slot |
lastItem | Item stored in the last tick. |
APIs
setContainerSlot
Associates the widget with an inventory container by specifying the slot index. e.g. player inventory.
setHandlerSlot
Configures the widget to use an item transfer handler with the specified slot index.
Java
For Java User !!!
If you want to use the handler of ItemStackHandler
(from forge) or Storage<ItemVariant>
(from fabric), you need one more line. Because Forge and Fabric has different APIs, you need to convert the handler into the LDLib one, which can be found in ItemTransferHelperImpl
.
KubeJS
KubeJS user do not need to do such mess. We have already convert them into a item transfer internal already.
setItem
Set the internal itemstack with/without notify.
getItem
Get the internal itemstack stored.
setChangeListener
Configures additional slot location information, such as whether it belongs to the player container or hotbar. It will affect the shift move behaviour.
canPutStack
Whether can put stack into the slot.
canTakeStack
Whether can take stack from the slot.
setLocationInfo
Configures additional slot location information, such as whether it belongs to the player container or hotbar. It will affect the shift move behaviour.