Skip to content

Commit

Permalink
fix: shift scroll (MC-121772)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViRb3 committed Jan 11, 2022
1 parent 82b85ab commit b16350c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/me/virb3/mcmouser/client/mixin/MixinMouse.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
package me.virb3.mcmouser.client.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.MouseHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(MouseHandler.class)
public class MixinMouse {
private double deltaX;

@Redirect(method = "onPress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;ON_OSX:Z"))
private boolean onPress() {
return false;
}

@Inject(method = "onScroll", at = @At(value = "HEAD"))
private void onScroll(long windowHandle, double deltaX, double deltaY, CallbackInfo ci) {
this.deltaX = deltaX;
}

@ModifyVariable(method = "onScroll", ordinal = 1, at = @At(value = "LOAD"), argsOnly = true)
private double onScroll_deltaX(double deltaY) {
if (Minecraft.ON_OSX && deltaY == 0) {
return deltaX;
}
return deltaY;
}
}

0 comments on commit b16350c

Please sign in to comment.