How to Fix IndexOutOfBoundsException
IndexOutOfBoundsException means code asked for a position a list or buffer doesn't have. How to read the message and find the mod behind it.
Quick Fix
Open the crash report, read the lines under the exception to see which mod made the call, then update or remove that mod.
Error Message
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0How to Fix
Read the crash report from the exception down. The first lines that name a mod's package show where the bad index came from.
Update that mod, or remove it for a test to confirm it is the cause.
For an exceeds writerIndex error while joining or playing, give the client and server exactly the same mods and versions.
If it started after a mod update, move that mod's config file aside so the mod writes a fresh one.
If the newest version still crashes, send the full crash report to the mod's issue tracker.
Common Causes
- Code asked for an element that isn't there. ArrayList.get checks the index first and throws Index 0 out of bounds for length 0 when the list is empty.
- A network packet was shorter than the code reading it expected. Netty then reports something like readerIndex(4) + length(8) exceeds writerIndex(10) inside a DecoderException, which happens when client and server disagree about a packet, for example because a mod differs between them.
- A mod reads saved data or a config written by another version of that mod and finds fewer entries than it expects.
Diagnostic Steps
- Open the newest file in crash-reports, or latest.log.
- Find the IndexOutOfBoundsException line and the lines below it.
- Note the first mod package in the stack trace.
- Update or remove that mod and test again.
FAQ
What is the difference between ArrayIndexOutOfBounds and IndexOutOfBounds?
IndexOutOfBoundsException is the general one, used for lists and similar collections. ArrayIndexOutOfBoundsException and StringIndexOutOfBoundsException are its subclasses for arrays and strings.
What does Index 0 out of bounds for length 0 mean?
The code asked for the first element of something empty. Length is how many elements there were, and index is the position it asked for, counting from 0.
Will reinstalling Java fix it?
No. The exception comes from the code that asked for the index, so the fix is in that mod or plugin, not in Java.
Related Errors
How to Fix java.lang.NullPointerException
java.lang.NullPointerException
How to Fix ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
How to Fix Internal Exception: Decoder
Internal Exception: io.netty.handler.codec.DecoderException
How to Read Minecraft Crash Reports
---- Minecraft Crash Report ----