This might be the only working solution that I discovered for newer versions.
// Disclaimer: This is just an example of a non-abstracted code to only demonstrate the workaround.
public static Screen currentScreen = null;
@SubscribeEvent
public static void onChangeGUI(GuiOpenEvent event)
{
currentScreen = event.getGui();
}
@SubscribeEvent
public static void onKeyInput(final InputEvent.KeyInputEvent e)
{
if(currentScreen == null && e.getAction() == GLFW.GLFW_PRESS && e.getKey() == 'R')
Weapon.reload();
}
I'm posting it so people wouldn't struggle with deprecated code from 1.12.2 and old threads like I did at first. (Cause Minecraft::currentScreen was removed for some reason)
Is there a simpler solution?
Edit: I discovered that we could also include our keys bindings into the settings of the user too through FMLClientSetupEvent which is cool.
Yet that doesn't simplify anything. I still have to use GuiOpenEvent to check for null screen.
Is there something I'm missing in the documentation? Can you point me to it?
I'm new to Forge. Like actually telling me how to use that built-in functionality you're talking about to do proper key bindings would be highly appreciated.