Posted August 15, 201312 yr I just made a TickHandler and registered it. Not sure if detecting a key press is supposed to be placed inside a TickHandler, hopefully it's the right way. My TickHandler: package deathman12e3.legendaryutilities; import java.util.EnumSet; import org.lwjgl.input.Keyboard; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class TickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if(Keyboard.isKeyDown(Keyboard.KEY_R)) { System.out.println("HIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"); } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return null; } @Override public String getLabel() { return null; } } My problem is that it never prints anything. Kain
August 15, 201312 yr you can also make a class that extends KeyHandler and regsiter that class, will probably be easier how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
August 15, 201312 yr Author Is there an easier way to detect a key press? Packet Handlers and all those seem like a lot of work just to detect when a key is pressed. Kain
August 15, 201312 yr why would you need a packet handler ? its a key press example: import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.TickType; public class HBKeyHandler extends KeyHandler { public HBKeyHandler() { super(new KeyBinding[]{new KeyBinding("configure health bar", Keyboard.KEY_C)}, new boolean[]{false}); } @Override public String getLabel() { return "hbkh"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if(Minecraft.getMinecraft().inGameHasFocus){ Minecraft.getMinecraft().thePlayer.openGui(MainMod.instance, 0, Minecraft.getMinecraft().theWorld, 0, 0, 0); } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } @Override public EnumSet<TickType> ticks() { return null; } } also, your TickHandler is not working because you are not returning null in "public EnumSet<TickType> ticks()" how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
August 15, 201312 yr Author Nah, I'll just stick with a TickHandler. I think I'll need it later in a little bit. And what do you mean by my TickHandler is not returning null in "public EnumSet<TickType> ticks()"? Kain
August 15, 201312 yr Nah, I'll just stick with a TickHandler. I think I'll need it later in a little bit. *hydroflame goes suspicisous mode.... hmmmm* anyway hum you are returning null @Override public EnumSet<TickType> ticks(){ return null; } and you should be returning something : @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
August 15, 201312 yr Author Small little question, do you happen to know where the Minecraft stores it's key bindings? I'm trying to get what key is used in the binding for the inventory. Kain
August 15, 201312 yr yeah in Minecraft.gameSettings.keyBindings how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
August 15, 201312 yr Author Sorry if I keep bothering you, but is there a iskeyPress method? There's only a isKeyDown method in Keyboard. Kain
August 15, 201312 yr well if you were using a keyhandler you wouldnt have to worry about that, but no there isnt how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
August 15, 201312 yr Author Ok, I just made my KeyHandler. I'll just set a boolean to toggle when the key is down and up. Kain
August 15, 201312 yr Author Also, what's this? if(Minecraft.getMinecraft().inGameHasFocus){ Minecraft.getMinecraft().thePlayer.openGui(mod_LegendaryUtilities.instance, 0, Minecraft.getMinecraft().theWorld, 0, 0, 0); } Kain
August 15, 201312 yr code to open a gui how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
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.