Skip to content

PhantomSlotWidget

The PhantomSlotWidget is a UI widget representing a "phantom" item slot, commonly used for ghost ingredient inputs in recipe configurations. Unlike regular slots, it does not interact with real inventories but allows setting, modifying, and clearing items for visual or configurational purposes.

Features

  • Does not allow item taking or putting from real inventories.
  • Supports setting items via UI clicks or API calls.
  • Allows right-click clearing (clearSlotOnRightClick).
  • Supports integration with JEI/EMI for ghost ingredient handling.

Basic Properties

FieldDescription
maxStackSizeMaximum allowed stack size in this phantom slot.
clearSlotOnRightClickWhether right-clicking clears the slot.

APIs

It owns all APIs from SlotWidget, and you can get or set item by its APIs.

setClearSlotOnRightClick

Configures whether right-clicking on the slot clears its contents.

java
phantomSlot.setClearSlotOnRightClick(true);

setMaxStackSize

Sets the maximum allowed stack size in the phantom slot.

java
phantomSlot.setMaxStackSize(64);

Mouse Interactions

Phantom slots handle different types of mouse interactions:

Mouse ActionEffect
Left-click on empty slot with an itemSets the item to the slot
Left-click on filled slot with an itemReplaces the item in the slot
Right-click on filled slotDecreases stack size
Shift + ClickAdjusts stack size dynamically
Right-click on empty slotClears the slot (if clearSlotOnRightClick is enabled)

Released under the MIT License.