Index out of bounds (When connecting to server) 1.17.1
campbebj opened this issue ยท 3 comments
there are two Errors (very similar) they only seem to happen when i connect to a server, when running locally its fine.
java.lang.IndexOutOfBoundsException: Index 46 out of bounds for length 46
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
at net.minecraft.class_2371.get(class_2371.java:47) ~[intermediary-minecraft-1.17.1-client.jar:?]
at net.minecraft.class_1703.method_7611(class_1703.java:275) ~[intermediary-minecraft-1.17.1-client.jar:?]
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at de.guntram.mcmod.durabilityviewer.client.gui.GuiItemDurability.onRenderGameOverlayPost(GuiItemDurability.java:182)
at net.minecraft.class_329.handler$bii000$beforeRenderDebugScreen(class_329.java:3492)
at net.minecraft.class_329.method_1753(class_329.java:304)
Tried to pull the code down and debug but i couldnt figure out how to make it build as the gradle doesnt seem to run for me.
Running gradle: Seems I didn't update the COMPILING.md file when I updated to java 16 and MC 1.17. Sorry. You need to install gradle 7.0.2 or later; it doesn't come with the mod because I don't want to pollute each of my 10+ mod's namespaces with the same gradle installation. (Myself, I'm using gradle 7.1.1 because that works for Fabric and Forge).
First Error: Do you have a longer stack trace? Unfortunately, the classes (2371 and 1703) are DefaultedList and ScreenHandler, so I can't pinpoint the location in my code.
Second Error: This is, where, in my code, I'm trying to list the player's trinkets. Index 0 hints at trinkets saying there's no trinket slots earlier, and the player wearing at least one trinket later, which shouldn't happen. However, the trinkets API changed in 1.17 and much of the trinkets support was rewritten, so there might be bugs lurking here. Do you know if the server you're connecting to is running trinkets? If so, can I connect to it to debug?
the error is happening in the same place. i got a tweak compiled to make it not error but its not the right fix im sure.
https://github.com/gbl/DurabilityViewer/blob/fabric_1_17/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java#L182 for some reason the two arrays trinkets and trinketWarners are not the same length. i put in an extra check against the trinketWarners array in the if statement. Ive no idea why they are out of sync when it comes to length.
Yes i am running trinkets but i dont have a safe way of exposing the server for you to be able to debug as it runs on my private internal network. i can try and setup debug and get you some data if you need it.
Here are full log data.
https://pastebin.com/WLBBJuj2