Class StackCopySlot
java.lang.Object
net.minecraft.world.inventory.Slot
net.neoforged.neoforge.world.inventory.StackCopySlot
- Direct Known Subclasses:
ItemHandlerCopySlot,ResourceHandlerSlot
Slot to handle immutable itemstack storages (Ex:
ItemAccessItemHandler).
For an implementation for use with a ResourceHandler see ResourceHandlerSlot.
Vanilla MC code modifies the stack returned by getItem() 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 ItemStackgetItem()protected abstract ItemStackGets the itemstack from the storage.final ItemStackremove(int amount) Decrease the size of the stack in slot (first int arg) by the amount of the second int arg.final voidHelper method to put a stack in the slot.final voidprotected abstract voidsetStackCopy(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:SlotHelper method to put a stack in the slot. -
setChanged
public final void setChanged()- Overrides:
setChangedin classSlot
-
remove
Description copied from class:SlotDecrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack.
-