SebasTheGreat Posted February 11, 2015 Posted February 11, 2015 Hey so, as the title has stated, I'm trying to open a GUI by pressing a key. I have the key handler set up but I don't know how to link it to the GUI. I've tried different combinations of things including using packets and just telling the onKeyImput method directly to open the GUI but nothing has worked. If anyone can point me in the right direction I would be very appreciated. Quote
brandon3055 Posted February 11, 2015 Posted February 11, 2015 What kind of gui is it? If it involves a container you will need to send a packet to the server and open the gui from there. The same way you would open a gui for a block. If its a client side gui you can just open it from your key input handler. If you cant get it to work please show what you tried. Quote I am the author of Draconic Evolution
SebasTheGreat Posted February 11, 2015 Author Posted February 11, 2015 It is a client side GUI and the code I could come up with seems logical (to me) but doesn't work. @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if(!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { int key = Keyboard.getEventKey(); boolean isDown = Keyboard.getEventKeyState(); if(isDown && key == keyValues[AAA_KEY]) { Minecraft.getMinecraft().thePlayer.openGui(MineGrades.instance,MineGrades.guiAAA, Minecraft.getMinecraft().thePlayer.worldObj, (int)Minecraft.getMinecraft().thePlayer.posX, (int)Minecraft.getMinecraft().thePlayer.posY, (int)Minecraft.getMinecraft().thePlayer.posZ); } } } Quote
Abastro Posted February 11, 2015 Posted February 11, 2015 You have to set up your own Gui Handler.. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
brandon3055 Posted February 11, 2015 Posted February 11, 2015 You have to set up your own Gui Handler.. What makes you think he hasnt? @SebasTheGreat Have you? If so please show it and your gui class. Also have you checked to see if that code is actually being run? Quote I am the author of Draconic Evolution
SebasTheGreat Posted February 11, 2015 Author Posted February 11, 2015 I'm so dumb I forgot to put the GUI I made into the handler. All works now thanks! Quote
Recommended Posts
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.