Skip to content

Commit

Permalink
handle mouse keybindings (#118)
Browse files Browse the repository at this point in the history
* handle mouse keybindings

* remove empty spaces
  • Loading branch information
matthias-luger authored Apr 10, 2024
1 parent 3321274 commit 79e2183
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/de/torui/coflsky/handlers/EventRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -60,12 +62,22 @@ 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;
}
Expand Down

0 comments on commit 79e2183

Please sign in to comment.