blob: 31eca7860f30b1206172fd0f8bbc18ac0e3b544a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package de.hysky.skyblocker.mixins;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.gui.screen.ReconfiguringScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.InputUtil;
@Mixin(Screen.class)
public class ScreenMixin {
@Shadow
protected MinecraftClient client;
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("TAIL"))
private void skyblocker$hideCursor(CallbackInfo ci) {
Object instance = (Object) this;
if ((instance instanceof DownloadingTerrainScreen || instance instanceof ReconfiguringScreen) && Utils.isOnHypixel()) {
//Prevents the mouse from being movable while we cancel the rendering of the screen
InputUtil.setCursorParameters(this.client.getWindow().getHandle(), GLFW.GLFW_CURSOR_DISABLED, this.client.mouse.getX(), this.client.mouse.getY());
}
}
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
private void skyblocker$hideReconfiguringScreen(CallbackInfo ci) {
if ((Object) this instanceof ReconfiguringScreen && Utils.isOnHypixel()) ci.cancel();
}
}
|