Skip to content

Commit a706cac

Browse files
committed
Fix stealing cursor forever (#2233)
(cherry picked from commit 30a9cf8)
1 parent daef5c2 commit a706cac

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/main/java/de/hysky/skyblocker/mixins/ScreenMixin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.lwjgl.glfw.GLFW;
44
import org.spongepowered.asm.mixin.Mixin;
55
import org.spongepowered.asm.mixin.Shadow;
6+
import org.spongepowered.asm.mixin.Unique;
67
import org.spongepowered.asm.mixin.injection.At;
78
import org.spongepowered.asm.mixin.injection.Inject;
89
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -11,20 +12,31 @@
1112
import net.minecraft.client.Minecraft;
1213
import net.minecraft.client.gui.screens.LevelLoadingScreen;
1314
import net.minecraft.client.gui.screens.Screen;
15+
import net.minecraft.client.gui.screens.DisconnectedScreen;
1416
import net.minecraft.client.gui.screens.multiplayer.ServerReconfigScreen;
1517

1618
@Mixin(Screen.class)
1719
public class ScreenMixin {
1820
@Shadow
1921
protected Minecraft minecraft;
2022

23+
@Unique
24+
private static boolean skyblocker$isCursorHidden = false;
25+
2126
@Inject(method = "init(Lnet/minecraft/client/Minecraft;II)V", at = @At("TAIL"))
2227
private void skyblocker$hideCursor(CallbackInfo ci) {
2328
Object instance = this;
2429

30+
if ((instance instanceof DisconnectedScreen) && Utils.isOnHypixel() && skyblocker$isCursorHidden) {
31+
InputConstants.grabOrReleaseMouse(this.minecraft.getWindow(), GLFW.GLFW_CURSOR_NORMAL, this.minecraft.mouseHandler.xpos(), this.minecraft.mouseHandler.ypos());
32+
}
33+
2534
if ((instance instanceof LevelLoadingScreen || instance instanceof ServerReconfigScreen) && Utils.isOnHypixel()) {
2635
//Prevents the mouse from being movable while we cancel the rendering of the screen
2736
InputConstants.grabOrReleaseMouse(this.minecraft.getWindow(), GLFW.GLFW_CURSOR_DISABLED, this.minecraft.mouseHandler.xpos(), this.minecraft.mouseHandler.ypos());
37+
skyblocker$isCursorHidden = true;
38+
} else {
39+
skyblocker$isCursorHidden = false;
2840
}
2941
}
3042

0 commit comments

Comments
 (0)