The Meaning of Life, the Universe, and Everything.
Location:
North Dakota
Join Date:
6/27/2012
Posts:
199
Location:
In a galaxy far, far away
Minecraft:
Herpahermaderp
Member Details
So I've gotten my GUI to open with my custom keybind, but how do I get it to close once the key is released? Currently if you release the key that activates it, the GUI stays open, and the only way to close it is to press the Esc key. Here is my code:
public class KeyInputHandler {
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onKeyInput(InputEvent.KeyInputEvent event) {
if(!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(NKeyBinding.jutsuGui.isPressed() == true) {
player.openGui(NarutoMC.instance, 0, player.worldObj, (int)player.posX, (int) player.posY, (int) player.posZ);
}
}
}
}
It's recommended that you use packets when you open a GUI with keybind. Tutorial here: https://github.com/coolAlias/Forge_Tutorials/blob/master/CustomPlayerInventory.java . Almost at the end of tutorial is where the process, of making a packet and sending the packet in order to open the GUI with a keybind, is located. Hopes this helps.
It's recommended that you use packets when you open a GUI with keybind. Tutorial here: https://github.com/coolAlias/Forge_Tutorials/blob/master/CustomPlayerInventory.java . Almost at the end of tutorial is where the process, of making a packet and sending the packet in order to open the GUI with a keybind, is located. Hopes this helps.
So I've gotten my GUI to open with my custom keybind, but how do I get it to close once the key is released? Currently if you release the key that activates it, the GUI stays open, and the only way to close it is to press the Esc key. Here is my code:
#TeamRowlet
#TeamInstinct
#TeamIronMan
It's recommended that you use packets when you open a GUI with keybind. Tutorial here: https://github.com/coolAlias/Forge_Tutorials/blob/master/CustomPlayerInventory.java . Almost at the end of tutorial is where the process, of making a packet and sending the packet in order to open the GUI with a keybind, is located. Hopes this helps.