DevNatan / inventory-framework

Minecraft Inventory API framework
MIT License
120 stars 23 forks source link

ArrayIndexOutOfBoundsException when setting an item on the 27th slot in a 3-row container. #681

Open 2lay opened 1 month ago

2lay commented 1 month ago

Is there an existing issue for this?

🐛 Describe the bug

Plugin throws an ArrayIndexOutOfBoundsException error when trying to set an item on the 27'th / last slot.

Stack Trace:

[20:54:49 ERROR]: [CommandAPI] Unhandled exception executing '/opengold'
java.lang.ArrayIndexOutOfBoundsException: Index 27 out of bounds for length 27
        at java.base/java.util.Arrays$ArrayList.set(Arrays.java:4271) ~[?:?]
        at net.minecraft.core.NonNullList.set(NonNullList.java:50) ~[paper-1.21.1.jar:1.21.1-98-9b1ee0d]
        ...

✔️ Expected behavior

GUI is supposed to open and show an item on the 27'th / last slot.

👣 Steps to Reproduce

  1. Create a Container.
  2. Set an item to the 27 using render.slot or render.lastSlot method.
  3. GUI doesn't open and throws an ArrayIndexOutOfBoundsException error.

💻 Platform

⭐ Server Version

1.21.1

📚 Library Version

3.0.11

✍️ Additional context

No response

nicolube commented 1 week ago

@2lay Did u put it on index 27? Indexing starts at 0 so the 27th slot would be position 26...

2lay commented 1 week ago

No, I am using render.lastSlot, or setting it to the 26'th slot.