Jump to content

[1.11 ~Solved] Check when a player press a hotkey in his inventory


Franckyi

Recommended Posts

Hi !

I'm still working on my Item Editor GUI mod. The mod is working well, but I need something else.

At the moment, the GUI opens when the player has an item in his mainhand and when he press the "I" hotkey.

What I also would like to do, is to detect when a player press the hotkey in his inventory while hovering an item.

The problem is, the event I use (KeyInputEvent) only fires when the player is out of a GUI (when he is "in game").

Does someone know how can I do that ?

Link to comment
Share on other sites

Thanks !

So now when I press a key the event fires, but I can't detect when my hotkey is pressed. This is what I've done :

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onGuiKeyPressed(KeyboardInputEvent e) {
System.out.println("Key pressed in GUI");
KeyBinding[] keyBindings = ClientProxy.keyBindings; // Registered in initialisation
if (keyBindings[0].isPressed()){ // The keybinding I use
	System.out.println("Binded key pressed in GUI");
}
}

I use my

keyBindings[0].isPressed()

condition in my

KeyInputEvent

and it works, but here it doesn't.

Link to comment
Share on other sites

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.