-
Bug
-
Resolution: Fixed
-
Minecraft 1.9.4, Minecraft 1.10
-
None
-
Windows 7 Java 8 64 bit
-
Confirmed
If the chat key is bound to a unicode char, opening the creative inventory GUI and pressing a key causes java.lang.IndexOutOfBoundsException
I expect that pressing the chat button opens the inventory filter field to allow me to type
what happens instead is pressing any key (not just the chat key) causes an immediate crash.
Steps to Reproduce:
- bind chat to a unicode char (non US keyboard needed, or edit options.txt to include the line "key_key.chat:427")
- load a creative world
- open your inventory
- press any key
Code explanation for this follows.
Using MCP names, undoubtedly different from the names used in the code internally. Sorry. Obfuscation
This happens due to GuiContainerCreative.keyTyped(char, int) calling GameSettings.isKeyDown(this.mc.gameSettings.keyBindChat)
That method is as follows:
public static boolean isKeyDown(KeyBinding key) { return key.getKeyCode() == 0 ? false : (key.getKeyCode() < 0 ? Mouse.isButtonDown(key.getKeyCode() + 100) : Keyboard.isKeyDown(key.getKeyCode())); }
keyBindChat.getKeyCode() in my instance is 427. Point being it is something greater than 256.
Keyboard.isKeyDown(int) method is as follows:
public static boolean isKeyDown(int key) { synchronized (OpenGLPackageAccess.global_lock) { if (!created) throw new IllegalStateException("Keyboard must be created before you can query key state"); return keyDownBuffer.get(key) != 0; } }
keyDownBuffer was created so:
private static final ByteBuffer keyDownBuffer = BufferUtils.createByteBuffer(KEYBOARD_SIZE);
where KEYBOARD_SIZE is defined as 256.
so keyDownBuffer.get(427) of course causes IndexOutOfBoundsException
Description: Updating screen events java.lang.IndexOutOfBoundsException: 427 at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:253) at org.lwjgl.input.Keyboard.isKeyDown(Keyboard.java:407) at bcf.a(SourceFile:385) at bga.a(SourceFile:327) at bez.l(SourceFile:420) at bez.p(SourceFile:387) at bcd.t(SourceFile:1582) at bcd.av(SourceFile:969) at bcd.a(SourceFile:399) at net.minecraft.client.main.Main.main(SourceFile:124)