Jump to content

wernon

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by wernon

  1. I ended but with extremly bad solution, but it's better, that something, that does not work. @SubscribeEvent public void onKeyPress(InputEvent.KeyInputEvent event) { KeyBinding te1 = TEST; int t1 = te1.getKey().getKeyCode(); if(event.getKey() == t1 && event.getAction() == 1){ if(TEST.isPressed()){ Minecraft.getInstance().player.sendChatMessage("lol"); } } I still trying to figure out how to make thing with TickEvent work and if I manage to find better solution, I'll post code here.
  2. This method is private, so I cant call it w/o class rewrite. I tried #setPressed(false) and executing my event only once per tick, not twice, but there were no results.
  3. Huge thanks! That solves my problem, but in my case i dont want command to keep spamming while button is pressed. If I use InputEvent.KeyInputEvent, I can use #getAction, but I found no way to do this on ClientTickEvent (I looked through KeyBinding source code but found no method that can help me). Docs says that isPressed should work only once, but it is not working that way. @SubscribeEvent public void onKeyPress(TickEvent.ClientTickEvent event) { if(TEST.isPressed()){ Minecraft.getInstance().player.sendChatMessage("looool"); } } I initialise TEST as public static final KeyBinding TEST = new KeyBinding("key.test", KeyConflictContext.IN_GAME, InputMappings.Type.KEYSYM, GLFW.GLFW_KEY_Z, "test"); I feel like I am doing something stupid and sorry if that really is so, but I tried as much, as I could and this still does not work. Maybe should I write custom KeyConflictContest?
  4. Hello, guys! I'm trying to do some simple mod, which will be an addition to my vanilla spigot server, so this mod should be client-side only. The feature I've tried to implement is executing commands on keypress. I came up with this solution: @SubscribeEvent public void onKeyPress(InputEvent.KeyInputEvent event) { KeyBinding te1 = KEYBIND; //was ofk initialised before int t1 = te1.getKey().getKeyCode(); if(event.getKey() == t1 && event.getAction() == 1){ Minecraft.getInstance().player.sendChatMessage("/command"); } This works fine, but it also toggles when player is in menu or in chat. How can I make behavior of these buttons similar to vanilla WASD?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.