Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/22/18 in all areas

  1. Okay, I tried it out. The easiest way is to handle the InputEvent.MouseInputEvent and set the state of the keybind directly with code such as: @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public static void onEvent(InputEvent.MouseInputEvent event) { GameSettings gs = Minecraft.getMinecraft().gameSettings; if (gs.keyBindAttack.isPressed()) // add your additional conditions here { KeyBinding.setKeyBindState(gs.keyBindAttack.getKeyCode(), false); } } Note that it must be the InputEvent.MouseInputEvent not the MouseEvent because the latter is called before the keybindings are updated during the Minecraft tick. Also, note that due to the weird way that the set state is implemented you also need to call the isPressed() method to ensure that any pressed counter is also cleared out. This is because there is both a pressed and a pressTime field which have to be cleared but the pressTime is private and needs the call to isPressed() to decrement. (Alternatively you could use Java reflection to access it directly). I tested it and it works well. All left-clicks on entities and blocks were prevented, but GUI interaction still worked. However, I guess you might still want to allow clicking on entities so you could check the mouse over function to make sure it was clicking on a block. There are alternative ways to do it. Like Choonster said, you could handle and cancel all the related events. Yet another way would be to create your own KeyBinding subclass that considers your conditions for blocking the keys, and replace the instances in GameSettings with your own version.
    1 point
  2. https://github.com/mezz/JustEnoughItems/wiki/Getting-Started
    1 point
×
×
  • Create New...

Important Information

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