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 booleancanPlayerUse(PlayerEntity player)default booleancontainsAny(Set<Item> items)Determines whether this inventory contains any of the given candidate items.default intcount(Item item)Returns the number of times the specified item occurs in this inventory across all stored stacks.default intgetMaxCountPerStack()Returns the maximum number of items a stack can contain when placed inside this inventory.ItemStackgetStack(int slot)Fetches the stack currently stored at the given slot.booleanisEmpty()default booleanisValid(int slot, ItemStack stack)Returns whether the given stack is a valid for the indicated slot position.voidmarkDirty()default voidonClose(PlayerEntity player)default voidonOpen(PlayerEntity player)ItemStackremoveStack(int slot)Removes the stack currently stored at the indicated slot.ItemStackremoveStack(int slot, int amount)Removes a specific number of items from the given slot.voidsetStack(int slot, ItemStack stack)intsize()
-
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
countof 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.
-