Class PlayerInventory

java.lang.Object
fr.fidorial.inventory.SimpleContainer
fr.fidorial.inventory.PlayerInventory
All Implemented Interfaces:
Container

public class PlayerInventory extends SimpleContainer
The inventory a player carries.

Slots are laid out as follows: the hotbar from 0 to 8, the main inventory from 9 to 35, the armor from 36 (feet) to 39 (head), then the off hand at 40. The remaining slots are reserved.

Since:
0.1.0
See Also:
  • Field Details

    • SIZE

      public static final int SIZE
      The number of slots of a player inventory, reserved ones included.
      Since:
      0.1.0
      See Also:
    • HOTBAR_START

      public static final int HOTBAR_START
      The first hotbar slot.
      Since:
      0.1.0
      See Also:
    • HOTBAR_SIZE

      public static final int HOTBAR_SIZE
      The number of hotbar slots.
      Since:
      0.1.0
      See Also:
    • MAIN_START

      public static final int MAIN_START
      The first slot of the main inventory, right after the hotbar.
      Since:
      0.1.0
      See Also:
    • STORAGE_SIZE

      public static final int STORAGE_SIZE
      The number of slots of the hotbar and the main inventory together, from 0.
      Since:
      0.1.0
      See Also:
    • FEET

      public static final int FEET
      The boots slot.
      Since:
      0.1.0
      See Also:
    • LEGS

      public static final int LEGS
      The leggings slot.
      Since:
      0.1.0
      See Also:
    • CHEST

      public static final int CHEST
      The chestplate slot.
      Since:
      0.1.0
      See Also:
    • OFF_HAND

      public static final int OFF_HAND
      The off hand slot.
      Since:
      0.1.0
      See Also:
  • Constructor Details

    • PlayerInventory

      public PlayerInventory()
      Creates an empty inventory.
      Since:
      0.1.0
  • Method Details

    • slotOf

      public static int slotOf(EquipmentSlot slot)
      Where a piece of equipment sits in this inventory.
      Parameters:
      slot - the equipment slot
      Returns:
      the inventory slot, -1 for the main hand (it follows the selected hotbar slot) and for the slots a player does not have
      Since:
      0.1.0
    • equipmentSlotAt

      public static @Nullable EquipmentSlot equipmentSlotAt(int slot)
      The other way round from slotOf(EquipmentSlot).
      Parameters:
      slot - an inventory slot
      Returns:
      the equipment slot it holds, null for the hotbar, the main inventory and the reserved slots
      Since:
      0.1.0