Fix: Add a check to the index

This fixes some mods like galacticraft trying to get unexisting keyboard keys
This commit is contained in:
Boulay Mathias 2022-10-31 19:51:28 +01:00
parent 804d349b2e
commit b98c012c29

View File

@ -393,9 +393,10 @@ public class Keyboard {
* @return true if the key is down according to the last poll()
*/
public static boolean isKeyDown(int key) {
if (!created)
throw new IllegalStateException("Keyboard must be created before you can query key state");
return keyDownBuffer.get(key) != 0;
if (!created)
throw new IllegalStateException("Keyboard must be created before you can query key state");
if(key >= KEYBOARD_SIZE) return false;
return keyDownBuffer.get(key) != 0;
}
/**