|
3 | 3 | import org.lwjgl.glfw.GLFW; |
4 | 4 | import org.spongepowered.asm.mixin.Mixin; |
5 | 5 | import org.spongepowered.asm.mixin.Shadow; |
| 6 | +import org.spongepowered.asm.mixin.Unique; |
6 | 7 | import org.spongepowered.asm.mixin.injection.At; |
7 | 8 | import org.spongepowered.asm.mixin.injection.Inject; |
8 | 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
|
11 | 12 | import net.minecraft.client.Minecraft; |
12 | 13 | import net.minecraft.client.gui.screens.LevelLoadingScreen; |
13 | 14 | import net.minecraft.client.gui.screens.Screen; |
| 15 | +import net.minecraft.client.gui.screens.DisconnectedScreen; |
14 | 16 | import net.minecraft.client.gui.screens.multiplayer.ServerReconfigScreen; |
15 | 17 |
|
16 | 18 | @Mixin(Screen.class) |
17 | 19 | public class ScreenMixin { |
18 | 20 | @Shadow |
19 | 21 | protected Minecraft minecraft; |
20 | 22 |
|
| 23 | + @Unique |
| 24 | + private static boolean skyblocker$isCursorHidden = false; |
| 25 | + |
21 | 26 | @Inject(method = "init(Lnet/minecraft/client/Minecraft;II)V", at = @At("TAIL")) |
22 | 27 | private void skyblocker$hideCursor(CallbackInfo ci) { |
23 | 28 | Object instance = this; |
24 | 29 |
|
| 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 | + |
25 | 34 | if ((instance instanceof LevelLoadingScreen || instance instanceof ServerReconfigScreen) && Utils.isOnHypixel()) { |
26 | 35 | //Prevents the mouse from being movable while we cancel the rendering of the screen |
27 | 36 | 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; |
28 | 40 | } |
29 | 41 | } |
30 | 42 |
|
|
0 commit comments