setHelmet() and setItem(EquipmentSlot.HEAD) disconnect the player with IndexOutOfBoundsException

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major
    • None
    • Affects Version/s: None
    • None
    • Environment:
    • 4509-Spigot-d5ca3f8-58bf15a (MC: 1.21.6) (Implementing API version 1.21.6-R0.1-SNAPSHOT)
    • Yes

      When using Player#getInventory().setHelmet(ItemStack) or Player#getInventory().setItem(EquipmentSlot.HEAD, ItemStack), the player is immediately disconnected from the server with the following error:

      Failed to handle packet adm@282ed343, disconnecting
      java.lang.IndexOutOfBoundsException: Index 46 out of bounds for length 46
      at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
      at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
      at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
      at java.base/java.util.Objects.checkIndex(Objects.java:385)
      at java.base/java.util.ArrayList.get(ArrayList.java:427)
      ... (stack trace continues)

      This issue does not occur when setting the helmet using the raw inventory index 39, for example:
      player.getInventory().setItem(39, new ItemStack(Material.DIAMOND_HELMET));

      But the following lines cause the player to disconnect:
      player.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
      player.getInventory().setItem(EquipmentSlot.HEAD, new ItemStack(Material.DIAMOND_HELMET));

      It also happens when setting an item in an ItemDisplay

            Assignee:
            Unassigned
            Reporter:
            favio rivarola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: