Negative `tintindex` in block models causes `ArrayIndexOutOfBoundsException`
A custom block model with a negative tintindex causes an ArrayIndexOutOfBoundsException if the player try to render said block in an inventory.
Steps to Reproduce:
- Start the game;
- Load the attached resource pack;
- Open or create a world in creative;
- Search for "leaves" in the creative inventory;
- The game will freeze, then crash.
Context
This bug was encountered by some forum users playing on modified servers, but still reproduces on the vanilla single-player game:
- https://www.minecraftforum.net/forums/support/java-edition-support/3211567-exit-code-1-the-game-crashed-whilst-rendering (Dec 21, 2024)
- https://minecraft.fr/forum/threads/crash-fréquent-sur-un-serveur-en-ligne.276694/ (Jan 3, 2025) (french)
Suggested Fix
// net.minecraft.client.renderer.entity.ItemRenderer private static int getLayerColorSafe(int[] tintLayers, int index) { return index >= tintLayers.length ? -1 : tintLayers[index]; // ^ index < 0 || }
2025-01-03, 10:04 PM
2025-01-07, 08:31 AM
2025-01-07, 08:31 AM
0
1