use of dev.hypnotic.event.events.EventKeyPress in project Hypnotic-Client by Hypnotic-Development.
the class KeyboardMixin method onKey.
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info) {
if (key != GLFW.GLFW_KEY_UNKNOWN) {
/*
* action == GLFW.GLFW_PRESS is important
* so the module does not toggle twice
*/
KeyUtils.setKeyState(key, action != GLFW.GLFW_RELEASE);
for (Mod mod : ModuleManager.INSTANCE.modules) {
if (mod.getKey() == key && action == GLFW.GLFW_PRESS && MinecraftClient.getInstance().currentScreen == null)
mod.toggle();
}
EventKeyPress event = new EventKeyPress(key, scancode, action);
event.call();
if (event.isCancelled())
info.cancel();
if (client.currentScreen == null && key == KeyUtils.getKey(CommandManager.INSTANCE.getPrefix()) && action == GLFW.GLFW_PRESS)
client.setScreen(new ChatScreen(""));
}
}
Aggregations