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, 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 slot)
      Returns the stack in the given slot.
    • removeItem

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

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

      void setItem(int slot, ItemStack stack)
      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 stack)
    • setChanged

      void setChanged()
    • stillValid

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

      default void startOpen(Player player)
    • stopOpen

      default void stopOpen(Player player)
    • canPlaceItem

      default boolean canPlaceItem(int slot, ItemStack stack)
      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 target, int slot, ItemStack stack)
      Returns true if the given stack can be extracted into the target inventory.
      Parameters:
      target - the container into which the item should be extracted
      slot - the slot from which to extract the item
      stack - the item to extract
      Returns:
      true if the given stack can be extracted into the target inventory
    • countItem

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

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

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

      static boolean stillValidBlockEntity(BlockEntity blockEntity, Player player)
    • stillValidBlockEntity

      static boolean stillValidBlockEntity(BlockEntity blockEntity, Player player, float distance)