Interface Container

All Superinterfaces:
Clearable
All Known Subinterfaces:
ContainerEntity, ContainerSingleItem, ContainerSingleItem.BlockContainerSingleItem, CraftingContainer, Hopper, RandomizableContainer, WorldlyContainer
All Known Implementing Classes:
AbstractFurnaceBlockEntity, AbstractMinecartContainer, BarrelBlockEntity, BaseContainerBlockEntity, BlastFurnaceBlockEntity, BrewingStandBlockEntity, ChestBlockEntity, ChestBoat, ChiseledBookShelfBlockEntity, ComposterBlock.EmptyContainer, ComposterBlock.InputContainer, ComposterBlock.OutputContainer, CompoundContainer, CrafterBlockEntity, DecoratedPotBlockEntity, DispenserBlockEntity, DropperBlockEntity, FurnaceBlockEntity, HopperBlockEntity, Inventory, JukeboxBlockEntity, MerchantContainer, MinecartChest, MinecartHopper, PlayerEnderChestContainer, RandomizableContainerBlockEntity, RecipeBookExtensionTest.RecipeBookTestContainer, ResultContainer, ShulkerBoxBlockEntity, SimpleContainer, SmokerBlockEntity, TransientCraftingContainer, TrappedChestBlockEntity

public interface Container extends Clearable
  • Field Details

  • Method Details

    • getContainerSize

      int getContainerSize()
    • isEmpty

      boolean isEmpty()
    • getItem

      ItemStack getItem(int pSlot)
      Returns the stack in the given slot.
    • removeItem

      ItemStack removeItem(int pSlot, int pAmount)
      Removes up to a specified number of items from an inventory slot and returns them in a new stack.
    • removeItemNoUpdate

      ItemStack removeItemNoUpdate(int pSlot)
      Removes a stack from the given slot and returns it.
    • setItem

      void setItem(int pSlot, ItemStack pStack)
      Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
    • getMaxStackSize

      default int getMaxStackSize()
    • getMaxStackSize

      default int getMaxStackSize(ItemStack pStack)
    • setChanged

      void setChanged()
    • stillValid

      boolean stillValid(Player pPlayer)
      Don't rename this method to canInteractWith due to conflicts with Container
    • startOpen

      default void startOpen(Player pPlayer)
    • stopOpen

      default void stopOpen(Player pPlayer)
    • canPlaceItem

      default boolean canPlaceItem(int pSlot, ItemStack pStack)
      Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For guis use Slot.isItemValid
    • canTakeItem

      default boolean canTakeItem(Container pTarget, int pSlot, ItemStack pStack)
      Returns true if the given stack can be extracted into the target inventory.
      Parameters:
      pTarget - the container into which the item should be extracted
      pSlot - the slot from which to extract the item
      pStack - the item to extract
      Returns:
      true if the given stack can be extracted into the target inventory
    • countItem

      default int countItem(Item pItem)
      Returns the total amount of the specified item in this inventory. This method does not check for nbt.
    • hasAnyOf

      default boolean hasAnyOf(Set<Item> pSet)
      Returns true if any item from the passed set exists in this inventory.
    • hasAnyMatching

      default boolean hasAnyMatching(Predicate<ItemStack> pPredicate)
    • stillValidBlockEntity

      static boolean stillValidBlockEntity(BlockEntity pBlockEntity, Player pPlayer)
    • stillValidBlockEntity

      static boolean stillValidBlockEntity(BlockEntity pBlockEntity, Player pPlayer, float pDistance)