Class ResourceHandlerSlot
java.lang.Object
net.minecraft.world.inventory.Slot
net.neoforged.neoforge.world.inventory.StackCopySlot
net.neoforged.neoforge.transfer.item.ResourceHandlerSlot
Base implementation for a
Slot backed by a ResourceHandler<ItemResource>.
Requires the handler to expose a direct mutation function,
such as StacksResourceHandler.set(int, T, int).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ResourceHandler<ItemResource> private final intprivate final IndexModifier<ItemResource> -
Constructor Summary
ConstructorsConstructorDescriptionResourceHandlerSlot(ResourceHandler<ItemResource> handler, IndexModifier<ItemResource> slotModifier, int index, int xPosition, int yPosition) -
Method Summary
Modifier and TypeMethodDescriptionintintgetMaxStackSize(ItemStack stack) protected ItemStackGets the itemstack from the storage.booleanisSameInventory(Slot other) Checks if the other slot is in the same inventory, by comparing the inventory reference.booleanReturn whether this slot's stack can be taken from this slot.booleanCheck if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel.voidonQuickCraft(ItemStack oldStackIn, ItemStack newStackIn) if par2 has more items than par1, onCrafting(item,countIncrease) is calledprotected voidsetStackCopy(ItemStack stack) Sets the itemstack from the storage.Methods inherited from class net.neoforged.neoforge.world.inventory.StackCopySlot
getItem, remove, set, setChangedMethods inherited from class net.minecraft.world.inventory.Slot
allowModification, checkTakeAchievements, getContainerSlot, getNoItemIcon, getSlotIndex, hasItem, isActive, isFake, isHighlightable, onQuickCraft, onSwapCraft, onTake, safeInsert, safeInsert, safeTake, setBackground, setByPlayer, setByPlayer, tryRemove
-
Field Details
-
handler
-
slotModifier
-
index
private final int index
-
-
Constructor Details
-
ResourceHandlerSlot
public ResourceHandlerSlot(ResourceHandler<ItemResource> handler, IndexModifier<ItemResource> slotModifier, int index, int xPosition, int yPosition)
-
-
Method Details
-
mayPlace
Description copied from class:SlotCheck if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel. -
getStackCopy
Description copied from class:StackCopySlotGets the itemstack from the storage.- Specified by:
getStackCopyin classStackCopySlot- Returns:
- the stack in this slot
-
setStackCopy
Description copied from class:StackCopySlotSets the itemstack from the storage.- Specified by:
setStackCopyin classStackCopySlot- Parameters:
stack- the stack to put into this slot
-
onQuickCraft
Description copied from class:Slotif par2 has more items than par1, onCrafting(item,countIncrease) is called- Overrides:
onQuickCraftin classSlot
-
getMaxStackSize
public int getMaxStackSize()- Overrides:
getMaxStackSizein classSlot
-
getMaxStackSize
- Overrides:
getMaxStackSizein classSlot
-
mayPickup
Description copied from class:SlotReturn whether this slot's stack can be taken from this slot. -
getResourceHandler
-
isSameInventory
Description copied from class:SlotChecks if the other slot is in the same inventory, by comparing the inventory reference.- Overrides:
isSameInventoryin classSlot- Parameters:
other-- Returns:
- true if the other slot is in the same inventory
-