Skip to content

Commit

Permalink
mouse moved.
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Jan 1, 2024
1 parent b83b356 commit 8ef818c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/net/krlite/it_follows/mixin/MouseMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import net.krlite.it_follows.ItFollows;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
import net.minecraft.client.util.InputUtil;
import org.joml.Vector2i;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -12,14 +14,19 @@

@Mixin(Mouse.class)
public abstract class MouseMixin {
@Shadow protected abstract void onCursorPos(long window, double x, double y);
@Shadow private double x;

@Shadow private double y;

@Shadow @Final private MinecraftClient client;

@Inject(method = "onResolutionChanged", at = @At("RETURN"))
private void onResolutionChanged(CallbackInfo ci) {
Vector2i pos = ItFollows.buttonPos();
if (pos != null) {
onCursorPos(MinecraftClient.getInstance().getWindow().getHandle(), pos.x(), pos.y());
System.out.println(pos.x() + ", " + pos.y());
x = pos.x();
y = pos.y();
InputUtil.setCursorParameters(client.getWindow().getHandle(), 212993, x, y);
}
}
}

0 comments on commit 8ef818c

Please sign in to comment.