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 Details

  • Constructor Details

    • SimpleInventory

      public SimpleInventory​(int size)
    • SimpleInventory

      public SimpleInventory​(ItemStack[] items)
  • Method Details

    • addListener

      public void addListener​(InventoryChangedListener listener)
    • removeListener

      public void removeListener​(InventoryChangedListener listener)
    • getStack

      public ItemStack getStack​(int slot)
      Fetches the stack currently stored at the given slot. If the slot is empty, or is outside the bounds of this inventory, returns see ItemStack.EMPTY.
      Specified by:
      getStack in interface Inventory
    • clearToList

      public List<ItemStack> clearToList()
      Clears this inventory and return all the non-empty stacks in a list.
    • removeStack

      public ItemStack removeStack​(int slot, int amount)
      Removes a specific number of items from the given slot.
      Specified by:
      removeStack in interface Inventory
      Returns:
      the removed items as a stack
    • removeItem

      public ItemStack removeItem​(Item item, int count)
      Searches this inventory for the specified item and removes the given amount from this inventory.
      Returns:
      the stack of removed items
    • addStack

      public ItemStack addStack​(ItemStack stack)
    • canInsert

      public boolean canInsert​(ItemStack stack)
    • removeStack

      public ItemStack removeStack​(int slot)
      Removes the stack currently stored at the indicated slot.
      Specified by:
      removeStack in interface Inventory
      Returns:
      the stack previously stored at the indicated slot.
    • setStack

      public void setStack​(int slot, ItemStack stack)
      Specified by:
      setStack in interface Inventory
    • size

      public int size()
      Specified by:
      size in interface Inventory
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Inventory
    • markDirty

      public void markDirty()
      Specified by:
      markDirty in interface Inventory
    • canPlayerUse

      public boolean canPlayerUse​(PlayerEntity player)
      Specified by:
      canPlayerUse in interface Inventory
    • clear

      public void clear()
      Specified by:
      clear in interface Clearable
    • provideRecipeInputs

      public void provideRecipeInputs​(RecipeFinder finder)
      Specified by:
      provideRecipeInputs in interface RecipeInputProvider
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addToNewSlot

      private void addToNewSlot​(ItemStack stack)
    • addToExistingSlot

      private void addToExistingSlot​(ItemStack stack)
    • canCombine

      private boolean canCombine​(ItemStack one, ItemStack two)
    • transfer

      private void transfer​(ItemStack source, ItemStack target)
    • readTags

      public void readTags​(ListTag tags)
    • getTags

      public ListTag getTags()