Posted April 2, 201411 yr Hi, I currently have a GUI which opens when a key is pressed. But the key binding also intercepts the key when the player write in the chat. Which condition should i impose to check if the chat is used and avoid opening my GUI ? thanks. NB : current code is package PLCmods.robotica.commands; import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.input.Keyboard; import PLCmods.robotica.Robotica; import PLCmods.trashbin.LoggerKeyTickHandler; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; public class LoggerKeys extends KeyHandler { private EnumSet tickType = EnumSet.of(TickType.CLIENT); private boolean open; public static final KeyBinding[] key = {new KeyBinding("Logger GUI", Keyboard.KEY_L), new KeyBinding("Logger switch", Keyboard.KEY_O)}; public static final boolean[] repeat = {false,false}; public LoggerKeys() { super(key,repeat); KeyBindingRegistry.registerKeyBinding(this); open = false; } @Override public String getLabel() { return "Logger Key"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if(!tickEnd) { EntityClientPlayerMP e = Minecraft.getMinecraft().thePlayer; if(kb.keyCode == Keyboard.KEY_L) { if(open) e.closeScreen(); else e.openGui(Robotica.modInstance, Robotica.GUI.LogControl, e.worldObj, 0, 0, 0); open = !open; } else if(kb.keyCode == Keyboard.KEY_O) e.sendChatMessage("/log switch"); } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {} @Override public EnumSet<TickType> ticks() { return tickType; } }
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.