Skip to content

Commit

Permalink
Hack around broken forge input events
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Sep 13, 2023
1 parent 538362a commit ec8270f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/cam72cam/mod/event/ClientEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public MouseGuiEvent(MouseAction action, int x, int y, int button) {
@Mod.EventBusSubscriber(modid = ModCore.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public static class ClientEventBusForge {
private static Vec3d dragPos = null;
private static boolean skipNextMouseInputEvent = false;

@SubscribeEvent
public static void onClientTick(TickEvent.ClientTickEvent event) {
Expand All @@ -103,6 +104,9 @@ private static void onGuiMouse(GuiScreenEvent.MouseInputEvent event, int btn, Mo
MouseGuiEvent mevt = new MouseGuiEvent(action, (int) event.getMouseX(), (int) event.getMouseY(), btn);
if (!MOUSE_GUI.executeCancellable(h -> h.apply(mevt))) {
event.setCanceled(true);
// Apparently cancelling this input event only cancels it for the *GUI* handlers, not all input handlers
// Therefore we need to track that ourselves. Thanks for changing that from 1.12.2-forge
skipNextMouseInputEvent = true;
}
}

Expand All @@ -121,6 +125,10 @@ public static void onGuiRelease(GuiScreenEvent.MouseReleasedEvent.Pre event) {

@SubscribeEvent
public static void onClick(InputEvent.MouseInputEvent event) {
if (skipNextMouseInputEvent) {
skipNextMouseInputEvent = false;
return;
}
int attackID = Minecraft.getInstance().gameSettings.keyBindAttack.getKey().getKeyCode();
int useID = Minecraft.getInstance().gameSettings.keyBindUseItem.getKey().getKeyCode();

Expand Down

0 comments on commit ec8270f

Please sign in to comment.