-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/me/virb3/mcmouser/client/mixin/MixinMouse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |