Interface Container

All Superinterfaces:
Inventory, ValueContainer

public interface Container extends Inventory
A Container is effectively a ViewModel for a particular set of Inventory objects used to allow players to interact with the Inventories, usually via a GUI (the View).
  • Method Details

    • isViewedSlot

      boolean isViewedSlot(Slot slot)
      Returns whether given slot is part of the viewed inventories but not part of the viewers own inventory.

      Examples for viewed inventory slots:

      All the slots of the opened chest and not the player grid below.

      The slots of the crafting grid in the opened player inventory.

      slot - The slot to check.
      true when the slot is part of the viewed inventories.
    • viewed

      List<Inventory> viewed()
      Returns the list of viewed inventories.

      This is usually at least the inventory a player opened and the players inventory.

      It is not necessary, that all slots of the viewed inventories are visible or interactable with.

      the list of viewed inventories.
    • setCursor

      boolean setCursor(ItemStack item)
      Sets the viewing players cursor item.

      Returns false when the container is no longer open.

      item - The item to set.
      true if the cursor was set.
    • cursor

      Optional<ItemStack> cursor()
      Gets the viewing players cursor item.

      Returns Optional.empty() when the container was closed.

      The players cursor item.
    • viewer

      ServerPlayer viewer()
      Gets the viewing player.
      The viewing player
    • isOpen

      boolean isOpen()
      Returns whether this Container is open.
      Whether this Container is open.
    • type

      Returns the ContainerType of this container.
      the ContainerType of this container.
    • currentMenu

      Optional<InventoryMenu> currentMenu()
      Returns the InventoryMenu if this container has been opened by one.
      the current InventoryMenu if present