Class ContainerInventoryAccess<T extends net.minecraft.world.Container>
java.lang.Object
net.darkhax.bookshelf.api.inventory.ContainerInventoryAccess<T>
- All Implemented Interfaces:
IInventoryAccess
- Direct Known Subclasses:
WorldlyContainerInventoryAccess
public class ContainerInventoryAccess<T extends net.minecraft.world.Container>
extends Object
implements IInventoryAccess
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemStackextract(int slot, int amount, net.minecraft.core.Direction side, boolean modify) Attempts to extract items from the specified amount.int[]getAvailableSlots(net.minecraft.core.Direction side) Gets an array of accessible slot IDs for a given side of the inventory.intgetSlotSize(int slot) Get the amount of items that can be held by a given slot.net.minecraft.world.item.ItemStackgetStackInSlot(int slot) Gets the ItemStack in a given slot within the inventory.net.minecraft.world.item.ItemStackinsert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify) Attempts to insert an ItemStack into the given slot.net.minecraft.world.item.ItemStackinsert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify, boolean forceInsert) booleanisValidForSlot(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side) Checks if an ItemStack is the right type of item for a slot.protected voidupdateSlot(int slot, net.minecraft.world.item.ItemStack stack) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.darkhax.bookshelf.api.inventory.IInventoryAccess
canExtract, canExtract, canInsert, canInsert, extract, extract, forEachSlot, getAvailableSlots, insert, insert, isValidForSlot
-
Field Details
-
internal
-
-
Constructor Details
-
ContainerInventoryAccess
-
-
Method Details
-
getAvailableSlots
public int[] getAvailableSlots(net.minecraft.core.Direction side) Description copied from interface:IInventoryAccessGets an array of accessible slot IDs for a given side of the inventory.- Specified by:
getAvailableSlotsin interfaceIInventoryAccess- Parameters:
side- The side of the inventory being accessed. This is only relevant when accessing directional inventories.- Returns:
- An array of accessible slot IDs.
-
getStackInSlot
public net.minecraft.world.item.ItemStack getStackInSlot(int slot) Description copied from interface:IInventoryAccessGets the ItemStack in a given slot within the inventory. The resulting ItemStack should be considered immutable.- Specified by:
getStackInSlotin interfaceIInventoryAccess- Parameters:
slot- The ID of the slot to access.- Returns:
- The ItemStack in the given slot. This should be considered immutable.
-
insert
public net.minecraft.world.item.ItemStack insert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify) Description copied from interface:IInventoryAccessAttempts to insert an ItemStack into the given slot. If the ItemStack will not fully fit a partial insertion will be done instead.- Specified by:
insertin interfaceIInventoryAccess- Parameters:
slot- The ID of the slot to insert into.insertStack- The ItemStack to insert.side- The side of the inventory the item is being inserted through.modify- Should the contents of the inventory actually be modified?- Returns:
- The remaining ItemStack that was not inserted. An empty stack indicates that the item was fully inserted.
-
insert
public net.minecraft.world.item.ItemStack insert(int slot, net.minecraft.world.item.ItemStack insertStack, net.minecraft.core.Direction side, boolean modify, boolean forceInsert) -
extract
public net.minecraft.world.item.ItemStack extract(int slot, int amount, net.minecraft.core.Direction side, boolean modify) Description copied from interface:IInventoryAccessAttempts to extract items from the specified amount. You are not guaranteed to receive an item or as many of the item as you requested.- Specified by:
extractin interfaceIInventoryAccess- Parameters:
slot- The ID of the slot to extract from.amount- The amount of items to extract.side- The side the items are extracted from.modify- Should the contents of the inventory actually be modified?- Returns:
- The extracted items.
-
getSlotSize
public int getSlotSize(int slot) Description copied from interface:IInventoryAccessGet the amount of items that can be held by a given slot.- Specified by:
getSlotSizein interfaceIInventoryAccess- Parameters:
slot- The ID of the slot to query.- Returns:
- The amount of items that can be held by the slot.
-
isValidForSlot
public boolean isValidForSlot(int slot, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction side) Description copied from interface:IInventoryAccessChecks if an ItemStack is the right type of item for a slot. This only validates the item and not the state of the inventory itself. For example a brewing stand fuel slot will return true on blaze powder even if the slot is full.This check is performed automatically when inserting an item.
- Specified by:
isValidForSlotin interfaceIInventoryAccess- Parameters:
slot- The ID of the slot to query.stack- The stack to test.side- The side of the inventory being accessed.- Returns:
- Whether the item is valid for the slot or not.
-
updateSlot
protected void updateSlot(int slot, net.minecraft.world.item.ItemStack stack)
-