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>
listeners
private int
size
private DefaultedList<ItemStack>
stacks
-
Constructor Summary
Constructors Constructor Description SimpleInventory(int size)
SimpleInventory(ItemStack[] items)
-
Method Summary
Modifier and Type Method Description void
addListener(InventoryChangedListener listener)
ItemStack
addStack(ItemStack stack)
private void
addToExistingSlot(ItemStack stack)
private void
addToNewSlot(ItemStack stack)
private boolean
canCombine(ItemStack one, ItemStack two)
boolean
canInsert(ItemStack stack)
boolean
canPlayerUse(PlayerEntity player)
void
clear()
List<ItemStack>
clearToList()
Clears this inventory and return all the non-empty stacks in a list.ItemStack
getStack(int slot)
Fetches the stack currently stored at the given slot.ListTag
getTags()
boolean
isEmpty()
void
markDirty()
void
provideRecipeInputs(RecipeFinder finder)
void
readTags(ListTag tags)
ItemStack
removeItem(Item item, int count)
Searches this inventory for the specified item and removes the given amount from this inventory.void
removeListener(InventoryChangedListener listener)
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()
String
toString()
private void
transfer(ItemStack source, ItemStack target)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
removeStack
in 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:
removeStack
in 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:
canPlayerUse
in interfaceInventory
-
clear
public void clear() -
provideRecipeInputs
- Specified by:
provideRecipeInputs
in interfaceRecipeInputProvider
-
toString
-
addToNewSlot
-
addToExistingSlot
-
canCombine
-
transfer
-
readTags
-
getTags
-