Package net.minecraft.inventory
Interface Inventory
- All Superinterfaces:
Clearable
- All Known Subinterfaces:
Hopper
,SidedInventory
- All Known Implementing Classes:
AbstractFurnaceBlockEntity
,BarrelBlockEntity
,BlastFurnaceBlockEntity
,BrewingStandBlockEntity
,ChestBlockEntity
,ChestMinecartEntity
,ComposterBlock.ComposterInventory
,ComposterBlock.DummyInventory
,ComposterBlock.FullComposterInventory
,CraftingInventory
,CraftingResultInventory
,DispenserBlockEntity
,DoubleInventory
,DropperBlockEntity
,EnderChestInventory
,FurnaceBlockEntity
,HopperBlockEntity
,HopperMinecartEntity
,LockableContainerBlockEntity
,LootableContainerBlockEntity
,MerchantInventory
,PlayerInventory
,ShulkerBoxBlockEntity
,SimpleInventory
,SmokerBlockEntity
,StorageMinecartEntity
,TrappedChestBlockEntity
public interface Inventory extends Clearable
-
Method Summary
Modifier and Type Method Description boolean
canPlayerUse(PlayerEntity player)
default boolean
containsAny(Set<Item> items)
Determines whether this inventory contains any of the given candidate items.default int
count(Item item)
Returns the number of times the specified item occurs in this inventory across all stored stacks.default int
getMaxCountPerStack()
Returns the maximum number of items a stack can contain when placed inside this inventory.ItemStack
getStack(int slot)
Fetches the stack currently stored at the given slot.boolean
isEmpty()
default boolean
isValid(int slot, ItemStack stack)
Returns whether the given stack is a valid for the indicated slot position.void
markDirty()
default void
onClose(PlayerEntity player)
default void
onOpen(PlayerEntity player)
ItemStack
removeStack(int slot)
Removes the stack currently stored at the indicated slot.ItemStack
removeStack(int slot, int amount)
Removes a specific number of items from the given slot.void
setStack(int slot, ItemStack stack)
int
size()
-
Method Details
-
size
int size() -
isEmpty
boolean isEmpty() -
getStack
Fetches the stack currently stored at the given slot. If the slot is empty, or is outside the bounds of this inventory, returns seeItemStack.EMPTY
. -
removeStack
Removes a specific number of items from the given slot.- Returns:
- the removed items as a stack
-
removeStack
Removes the stack currently stored at the indicated slot.- Returns:
- the stack previously stored at the indicated slot.
-
setStack
-
getMaxCountPerStack
default int getMaxCountPerStack()Returns the maximum number of items a stack can contain when placed inside this inventory. No slots may have more than this number of items. It is effectively the stacking limit for this inventory's slots.- Returns:
- the max
count
of item stacks in this inventory
-
markDirty
void markDirty() -
canPlayerUse
-
onOpen
-
onClose
-
isValid
Returns whether the given stack is a valid for the indicated slot position. -
count
Returns the number of times the specified item occurs in this inventory across all stored stacks. -
containsAny
Determines whether this inventory contains any of the given candidate items.
-