From 80b454c2996584962429d0a3ac92208f049e9179 Mon Sep 17 00:00:00 2001 From: Matthias Luger Date: Wed, 10 Apr 2024 15:35:42 +0200 Subject: [PATCH] handle mouse keybindings --- .../de/torui/coflsky/handlers/EventRegistry.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/torui/coflsky/handlers/EventRegistry.java b/src/main/java/de/torui/coflsky/handlers/EventRegistry.java index 3ebd168..59a6ea2 100644 --- a/src/main/java/de/torui/coflsky/handlers/EventRegistry.java +++ b/src/main/java/de/torui/coflsky/handlers/EventRegistry.java @@ -33,12 +33,14 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import static de.torui.coflsky.CoflSky.config; import static de.torui.coflsky.handlers.DescriptionHandler.*; @@ -60,12 +62,24 @@ public void onDisconnectedFromServerEvent(ClientDisconnectionFromServerEvent eve public static long LastClick = System.currentTimeMillis(); public static Boolean LastHotkeyState; + public static Boolean LastEventButtonState; private DescriptionHandler descriptionHandler; @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) - public void onKeyEvent(KeyInputEvent event) { + public void onMouseEvent(InputEvent.MouseInputEvent event) { + + + if (LastEventButtonState != null && Mouse.getEventButtonState() == LastEventButtonState) { + return; + } + LastEventButtonState = Mouse.getEventButtonState(); + onAfterKeyPressed(); + } + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) + public void onKeyEvent(KeyInputEvent event) { if (LastHotkeyState != null && Keyboard.getEventKeyState() == LastHotkeyState) { return; }