public class SimpleInventory extends Object implements Inventory, RecipeInputProvider
Modifier and Type | Field and Description |
---|---|
private List<InventoryChangedListener> |
listeners |
private int |
size |
private DefaultedList<ItemStack> |
stacks |
Constructor and Description |
---|
SimpleInventory(int size) |
SimpleInventory(ItemStack[] items) |
Modifier and Type | Method and 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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
containsAny, count, getMaxCountPerStack, isValid, onClose, onOpen
private final int size
private final DefaultedList<ItemStack> stacks
private List<InventoryChangedListener> listeners
public SimpleInventory(int size)
public SimpleInventory(ItemStack[] items)
public void addListener(InventoryChangedListener listener)
public void removeListener(InventoryChangedListener listener)
public ItemStack getStack(int slot)
ItemStack.EMPTY
.public List<ItemStack> clearToList()
public ItemStack removeStack(int slot, int amount)
removeStack
in interface Inventory
public ItemStack removeItem(Item item, int count)
public boolean canInsert(ItemStack stack)
public ItemStack removeStack(int slot)
removeStack
in interface Inventory
public void setStack(int slot, ItemStack stack)
public boolean canPlayerUse(PlayerEntity player)
canPlayerUse
in interface Inventory
public void provideRecipeInputs(RecipeFinder finder)
provideRecipeInputs
in interface RecipeInputProvider
private void addToNewSlot(ItemStack stack)
private void addToExistingSlot(ItemStack stack)
public void readTags(ListTag tags)
public ListTag getTags()