Jump to content

Suggestion: KeyInputEvent() should fire on GuiScreens


Recommended Posts

Posted

My problem is that I have a hotkey set up to do something in the player's chest inventory when pressed. This worked in 1.6, but in 1.7 the new key handler event system does not allow the event to be fired when the user is looking at a GuiScreen. In Minecraft.java in the the runTick() method, then FMLCommonHandler.instance().fireKeyInput(); on line 1969 is not reached.

 

I suggest changing it so that:

 

1) this event still fires even if the player is looking at a GuiScreen

or

2) create a new KeyGuiInputEvent that fires when a key is pressed inside a GuiScreen

Posted

It depends on the gui actually, since each GuiScreen has a flag to allow key input or not.

 

Plus, you can use ClientTickEvent. It is run really close to the KeyInputEvent.

  • 2 weeks later...
Posted

Even if I do mc.currentScreen.allowUserInput = true on every game tick, Forge's hotkey event still does not fire when I look at a GuiChest and press the button.

 

I know I have my hotkey setup correctly because I do a System.out.println() for each time it is pressed and that fires when I am not looking at a GuiScreen.

Posted

To resolve my issue, I ended up using the ClientTickEvent event. In it, I basically wrote my own key handler:

 

private static boolean keyDown = false;

public static void MyKeyTickHandler(ClientTickEvent event)
{
if(Keyboard.getEventKey() == Keyboard.KEY_X)
{
	if(Keyboard.getEventKeyState())
	{
		if(keyDown == false)
			OnKeyDown();
		keyDown = true;
	}
	else
	{
		if(keyDown == true)
			OnKeyUp();
		keyDown = false;
	}
}

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.