Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.15.2-forge' into 1.16.5-forge
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Sep 13, 2023
2 parents b284f81 + 691b19a commit 0911f3a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/cam72cam/mod/event/ClientEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,25 @@ public static void onGuiRelease(GuiScreenEvent.MouseReleasedEvent.Pre event) {
onGuiMouse(event, event.getButton(), MouseAction.RELEASE);
}

private static void hackInputState(InputEvent.MouseInputEvent event) {
int attackID = Minecraft.getInstance().options.keyAttack.getKey().getValue();
int useID = Minecraft.getInstance().options.keyUse.getKey().getValue();

// This prevents the event from firing
if (event.getButton() == attackID) {
Minecraft.getInstance().options.keyAttack.consumeClick();
}
if (event.getButton() == useID) {
Minecraft.getInstance().options.keyUse.consumeClick();
}
}

@SubscribeEvent
public static void onClick(InputEvent.MouseInputEvent event) {
if (skipNextMouseInputEvent) {
// This is the path from onGuiMouse
skipNextMouseInputEvent = false;
hackInputState(event);
return;
}
int attackID = Minecraft.getInstance().options.keyAttack.getKey().getValue();
Expand All @@ -141,10 +156,12 @@ public static void onClick(InputEvent.MouseInputEvent event) {
Player.Hand button = attackID == event.getButton() ? Player.Hand.SECONDARY : Player.Hand.PRIMARY;
if (!DRAG.executeCancellable(x -> x.apply(button))) {
//event.setCanceled(true);
hackInputState(event);
dragPos = new Vec3d(0, 0, 0);
}
if (!CLICK.executeCancellable(x -> x.apply(button))) {
//event.setCanceled(true);
hackInputState(event);
}
} else {
dragPos = null;
Expand Down

0 comments on commit 0911f3a

Please sign in to comment.