This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
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
Stéphan Kochen
committed
Jul 17, 2012
0 parents
commit 27351d5
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/.classpath | ||
/.project | ||
/.settings | ||
/bin |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package mcdisablewheel; | ||
|
||
import static javassist.bytecode.Opcode.INVOKESTATIC; | ||
import static javassist.bytecode.Opcode.ICONST_0; | ||
import java.io.IOException; | ||
|
||
import com.pclewis.mcpatcher.BytecodePatch; | ||
import com.pclewis.mcpatcher.BytecodeSignature; | ||
import com.pclewis.mcpatcher.ClassMod; | ||
import com.pclewis.mcpatcher.MethodRef; | ||
import com.pclewis.mcpatcher.Mod; | ||
|
||
public final class DisableMouseWheel extends Mod { | ||
public DisableMouseWheel() { | ||
name = "Disable Mouse Wheel"; | ||
author = "stephan@kochen.nl"; | ||
description = "Disables the mouse wheel for inventory scrolling"; | ||
version = "0.1"; | ||
|
||
classMods.add(new MinecraftMod()); | ||
} | ||
|
||
private final class MinecraftMod extends ClassMod { | ||
public MinecraftMod() { | ||
// Find the main tick handling method. | ||
MethodRef runTick = new MethodRef(getDeobfClass(), "runTick", "()V"); | ||
classSignatures.add(new BytecodeSignature() { | ||
@Override | ||
public String getMatchExpression() { | ||
return buildExpression( | ||
push("animateTick") | ||
); | ||
} | ||
}.setMethod(runTick)); | ||
|
||
// Patch the mouse event handling. | ||
patches.add(new BytecodePatch() { | ||
@Override | ||
public String getDescription() { | ||
return "disable mouse wheel"; | ||
} | ||
|
||
@Override | ||
public String getMatchExpression() { | ||
// Find the call to Mouse.getEventDWheel(). | ||
return buildExpression( | ||
reference(INVOKESTATIC, new MethodRef("org/lwjgl/input/Mouse", "getEventDWheel", "()I")) | ||
); | ||
} | ||
|
||
@Override | ||
public byte[] getReplacementBytes() throws IOException { | ||
// Simply replace it by 0. | ||
return buildCode( | ||
ICONST_0 | ||
); | ||
} | ||
}.targetMethod(runTick)); | ||
} | ||
} | ||
} |