Package net.neoforged.neoforge.items
Class StackCopySlot
java.lang.Object
net.minecraft.world.inventory.Slot
net.neoforged.neoforge.items.StackCopySlot
- Direct Known Subclasses:
ItemHandlerCopySlot
Slot to handle immutable itemstack storages (Ex:
ComponentItemHandler
).
For an implementation for use with an IItemHandler
see ItemHandlerCopySlot
.
Vanilla MC code modifies the stack returned by `getStack()` directly, but it
calls setChanged()
when that happens, so we just cache the returned stack,
and set it when setChanged()
is called.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ItemStack
getItem()
protected abstract ItemStack
Gets the itemstack from the storage.final ItemStack
remove
(int amount) Decrease the size of the stack in slot (first int arg) by the amount of the second int arg.final void
Helper method to put a stack in the slot.final void
protected abstract void
setStackCopy
(ItemStack stack) Sets the itemstack from the storage.Methods inherited from class net.minecraft.world.inventory.Slot
allowModification, checkTakeAchievements, getContainerSlot, getMaxStackSize, getMaxStackSize, getNoItemIcon, getSlotIndex, hasItem, isActive, isFake, isHighlightable, isSameInventory, mayPickup, mayPlace, onQuickCraft, onQuickCraft, onSwapCraft, onTake, safeInsert, safeInsert, safeTake, setBackground, setByPlayer, setByPlayer, tryRemove
-
Field Details
-
emptyInventory
-
cachedReturnedStack
-
-
Constructor Details
-
StackCopySlot
public StackCopySlot(int x, int y)
-
-
Method Details
-
getStackCopy
Gets the itemstack from the storage.- Returns:
- the stack in this slot
-
setStackCopy
Sets the itemstack from the storage.- Parameters:
stack
- the stack to put into this slot
-
getItem
-
set
Description copied from class:Slot
Helper method to put a stack in the slot. -
setChanged
public final void setChanged()- Overrides:
setChanged
in classSlot
-
remove
Description copied from class:Slot
Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack.
-