diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-09-27 16:00:59 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-09-27 16:01:05 +0200 |
| commit | 4bfe8900c21c911d87a4d2f312c317cc19a72c30 (patch) | |
| tree | 5193d94a749d13903ebd3f224738e2ed2218c75e | |
| parent | 02ee2c825a313a6bc5069ca7178e6e3385367062 (diff) | |
| download | Firmament-4bfe8900c21c911d87a4d2f312c317cc19a72c30.tar.gz Firmament-4bfe8900c21c911d87a4d2f312c317cc19a72c30.tar.bz2 Firmament-4bfe8900c21c911d87a4d2f312c317cc19a72c30.zip | |
fix: revert cursor saving changes
| -rw-r--r-- | src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java | 46 | ||||
| -rw-r--r-- | src/main/kotlin/features/inventory/SaveCursorPosition.kt | 8 |
2 files changed, 30 insertions, 24 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java index fd3adca..334463b 100644 --- a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java @@ -14,27 +14,27 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Mouse.class) public class SaveCursorPositionPatch { - @Shadow - private double x; - - @Shadow - private double y; - - @Inject(method = "lockCursor", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/Mouse;cursorLocked:Z")) - public void onLockCursor(CallbackInfo ci) { - SaveCursorPosition.saveCursorOriginal(x, y); - } - - @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) - public void onLockCursorAfter(CallbackInfo ci) { - SaveCursorPosition.saveCursorMiddle(x, y); - } - - @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) - public void onUnlockCursor(CallbackInfo ci) { - Pair<Double, Double> cursorPosition = SaveCursorPosition.loadCursor(this.x, this.y); - if (cursorPosition == null) return; - this.x = cursorPosition.getFirst(); - this.y = cursorPosition.getSecond(); - } + @Shadow + private double x; + + @Shadow + private double y; + + @Inject(method = "lockCursor", at = @At(value = "HEAD")) + public void onLockCursor(CallbackInfo ci) { + SaveCursorPosition.saveCursorOriginal(x, y); + } + + @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) + public void onLockCursorAfter(CallbackInfo ci) { + SaveCursorPosition.saveCursorMiddle(x, y); + } + + @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) + public void onUnlockCursor(CallbackInfo ci) { + Pair<Double, Double> cursorPosition = SaveCursorPosition.loadCursor(this.x, this.y); + if (cursorPosition == null) return; + this.x = cursorPosition.getFirst(); + this.y = cursorPosition.getSecond(); + } } diff --git a/src/main/kotlin/features/inventory/SaveCursorPosition.kt b/src/main/kotlin/features/inventory/SaveCursorPosition.kt index 3e55d02..5a54aca 100644 --- a/src/main/kotlin/features/inventory/SaveCursorPosition.kt +++ b/src/main/kotlin/features/inventory/SaveCursorPosition.kt @@ -3,6 +3,7 @@ package moe.nea.firmament.features.inventory import org.lwjgl.glfw.GLFW import kotlin.math.absoluteValue import kotlin.time.Duration.Companion.milliseconds +import net.minecraft.client.util.InputUtil import moe.nea.firmament.util.MC import moe.nea.firmament.util.TimeMark import moe.nea.firmament.util.assertNotNullOr @@ -42,7 +43,12 @@ object SaveCursorPosition { (lastPosition.middle.first - middleX).absoluteValue < 1 && (lastPosition.middle.second - middleY).absoluteValue < 1 ) { - GLFW.glfwSetCursorPos(MC.window.handle, lastPosition.cursor.first, lastPosition.cursor.second); + InputUtil.setCursorParameters( + MC.window.handle, + InputUtil.GLFW_CURSOR_NORMAL, + lastPosition.cursor.first, + lastPosition.cursor.second + ) return lastPosition.cursor } return null |
