Skip to content

Commit

Permalink
handle mouse keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-luger committed Apr 10, 2024
1 parent 185a00d commit 80b454c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 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,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;
}
Expand Down

0 comments on commit 80b454c

Please sign in to comment.