Package net.minecraft.inventory
Class SimpleInventory
java.lang.Object
net.minecraft.inventory.SimpleInventory
- All Implemented Interfaces:
Inventory,RecipeInputProvider,Clearable
- Direct Known Subclasses:
ComposterBlock.ComposterInventory,ComposterBlock.DummyInventory,ComposterBlock.FullComposterInventory,EnderChestInventory
public class SimpleInventory extends Object implements Inventory, RecipeInputProvider
-
Field Summary
Fields Modifier and Type Field Description private List<InventoryChangedListener>listenersprivate intsizeprivate DefaultedList<ItemStack>stacks -
Constructor Summary
Constructors Constructor Description SimpleInventory(int size)SimpleInventory(ItemStack[] items) -
Method Summary
Modifier and Type Method Description voidaddListener(InventoryChangedListener listener)ItemStackaddStack(ItemStack stack)private voidaddToExistingSlot(ItemStack stack)private voidaddToNewSlot(ItemStack stack)booleancanInsert(ItemStack stack)booleancanPlayerUse(PlayerEntity player)voidclear()List<ItemStack>clearToList()Clears this inventory and return all the non-empty stacks in a list.ItemStackgetStack(int slot)Fetches the stack currently stored at the given slot.ListTaggetTags()booleanisEmpty()voidmarkDirty()voidprovideRecipeInputs(RecipeFinder finder)voidreadTags(ListTag tags)ItemStackremoveItem(Item item, int count)Searches this inventory for the specified item and removes the given amount from this inventory.voidremoveListener(InventoryChangedListener listener)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()StringtoString()private voidtransfer(ItemStack source, ItemStack target)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.inventory.Inventory
containsAny, count, getMaxCountPerStack, isValid, onClose, onOpen
-
Field Details
-
size
private final int size -
stacks
-
listeners
-
-
Constructor Details
-
SimpleInventory
public SimpleInventory(int size) -
SimpleInventory
-
-
Method Details
-
addListener
-
removeListener
-
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. -
clearToList
Clears this inventory and return all the non-empty stacks in a list. -
removeStack
Removes a specific number of items from the given slot.- Specified by:
removeStackin interfaceInventory- Returns:
- the removed items as a stack
-
removeItem
Searches this inventory for the specified item and removes the given amount from this inventory.- Returns:
- the stack of removed items
-
addStack
-
canInsert
-
removeStack
Removes the stack currently stored at the indicated slot.- Specified by:
removeStackin interfaceInventory- Returns:
- the stack previously stored at the indicated slot.
-
setStack
-
size
public int size() -
isEmpty
public boolean isEmpty() -
markDirty
public void markDirty() -
canPlayerUse
- Specified by:
canPlayerUsein interfaceInventory
-
clear
public void clear() -
provideRecipeInputs
- Specified by:
provideRecipeInputsin interfaceRecipeInputProvider
-
toString
-
addToNewSlot
-
addToExistingSlot
-
transfer
-
readTags
-
getTags
-