Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-1530

Player.getInventory returns armor and offhand

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • None
    • None
    • Spigot 1.9

      Calling Player.getInventory now returns an inventory with 41 items in it. I assume it includes armor and the offhand slots.

      This might be ok if intentional, but PlayerInventory.setContents won't allow more than 36 items- making saving and restoring an inventory troublesome:

      java.lang.IllegalArgumentException: Invalid inventory size; expected 36 or less

      Reproduction example:

      Inventory playerInventory = player.getInventory();
      ItemStack[] contents = playerInventory.getContents();
      contents = Arrays.copyOf(contents, contents.length);
      // Modify player inventory, later want to restore it:
      player.getInventory.setContents(contents);
      

      If I had to suggest an expectation, it would be that the inventory returned would have 37 slots (to include the offhand item) but not the armor, since it did not include armor before. And setContents ought to let you set 37 items, including that offhand. But mainly it should be symmetrical no matter what is returned or set.

            Unassigned Unassigned
            NathanWolf Nathan Wolf
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: