Class InventoryView

java.lang.Object
com.loohp.limbo.inventory.InventoryView

public class InventoryView extends Object
  • Field Details

  • Constructor Details

    • InventoryView

      public InventoryView(Player player, net.kyori.adventure.text.Component title, Inventory topInventory, Inventory bottomInventory)
  • Method Details

    • getCarriedItem

      public ItemStack getCarriedItem()
    • setCarriedItem

      public void setCarriedItem(ItemStack carriedItem)
    • getType

      public InventoryType getType()
    • getPlayer

      public Player getPlayer()
    • getTitle

      public net.kyori.adventure.text.Component getTitle()
    • getTopInventory

      public Inventory getTopInventory()
    • getBottomInventory

      public Inventory getBottomInventory()
    • getProperties

      public Map<InventoryView.Property,Integer> getProperties()
    • getInventory

      public Inventory getInventory(int rawSlot)
      Gets the inventory corresponding to the given raw slot ID. If the slot ID is OUTSIDE null will be returned, otherwise behaviour for illegal and negative slot IDs is undefined. May be used with convertSlot(int) to directly index an underlying inventory.
      Parameters:
      rawSlot - The raw slot ID.
      Returns:
      corresponding inventory, or null
    • convertSlot

      public int convertSlot(int rawSlot)
      Converts a raw slot ID into its local slot ID into whichever of the two inventories the slot points to.

      If the raw slot refers to the upper inventory, it will be returned unchanged and thus be suitable for getTopInventory().getItem(); if it refers to the lower inventory, the output will differ from the input and be suitable for getBottomInventory().getItem().

      Parameters:
      rawSlot - The raw slot ID.
      Returns:
      The converted slot ID.
    • getSlotType

      public InventoryType.SlotType getSlotType(int slot)
      Determine the type of the slot by its raw slot ID.

      If the type of the slot is unknown, then InventoryType.SlotType.CONTAINER will be returned.

      Parameters:
      slot - The raw slot ID
      Returns:
      the slot type
    • countSlots

      public int countSlots()
      Check the total number of slots in this view, combining the upper and lower inventories.

      Note though that it's possible for this to be greater than the sum of the two inventories if for example some slots are not being used.

      Returns:
      The total size
    • close

      public void close()
    • isSlot

      public boolean isSlot(int index)
    • getItem

      public ItemStack getItem(int index)
    • setItem

      public void setItem(int index, ItemStack itemStack)
    • setProperty

      public void setProperty(InventoryView.Property prop, int value)
    • updateView

      public void updateView()
    • getUnsafe

      @Deprecated public InventoryView.Unsafe getUnsafe()
      Deprecated.