project(internal): Move a couple methods to mixins
This commit is contained in:
@@ -30,7 +30,6 @@ import net.runelite.asm.signature.Signature;
|
||||
@NoArgsConstructor
|
||||
public abstract class InjectData
|
||||
{
|
||||
public static final String HOOKS = "net/runelite/client/callback/Hooks";
|
||||
public static final String CALLBACKS = "net/runelite/api/hooks/Callbacks";
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -22,17 +22,9 @@ import net.runelite.asm.execution.Execution;
|
||||
import net.runelite.asm.execution.InstructionContext;
|
||||
import net.runelite.asm.execution.MethodContext;
|
||||
import net.runelite.asm.execution.StackContext;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
import static com.openosrs.injector.injection.InjectData.HOOKS;
|
||||
|
||||
public class ClearColorBuffer extends AbstractInjector
|
||||
{
|
||||
private static final net.runelite.asm.pool.Method CLEARBUFFER = new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class(HOOKS),
|
||||
"clearColorBuffer",
|
||||
new Signature("(IIIII)V")
|
||||
);
|
||||
|
||||
public ClearColorBuffer(InjectData inject)
|
||||
{
|
||||
super(inject);
|
||||
@@ -40,11 +32,13 @@ public class ClearColorBuffer extends AbstractInjector
|
||||
|
||||
public void inject()
|
||||
{
|
||||
|
||||
/*
|
||||
* This class stops the client from basically painting everything black before the scene is drawn
|
||||
*/
|
||||
final Execution exec = new Execution(inject.getVanilla());
|
||||
|
||||
final net.runelite.asm.pool.Method clearBuffer = inject.getVanilla().findClass("client").findMethod("clearColorBuffer").getPoolMethod();
|
||||
final net.runelite.asm.pool.Method fillRectPool = InjectUtil.findMethod(inject, "Rasterizer2D_fillRectangle", "Rasterizer2D", null).getPoolMethod();
|
||||
final Method drawEntities = InjectUtil.findMethod(inject, "drawEntities"); // XXX: should prob be called drawViewport?
|
||||
|
||||
@@ -83,7 +77,7 @@ public class ClearColorBuffer extends AbstractInjector
|
||||
}
|
||||
|
||||
Instructions ins = instr.getInstructions();
|
||||
ins.replace(instr, new InvokeStatic(ins, CLEARBUFFER));
|
||||
ins.replace(instr, new InvokeStatic(ins, clearBuffer));
|
||||
log.debug("[DEBUG] Injected drawRectangle at {}", methodContext.getMethod().getPoolMethod());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,19 +24,10 @@ import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
||||
import net.runelite.asm.execution.Execution;
|
||||
import net.runelite.asm.execution.InstructionContext;
|
||||
import net.runelite.asm.execution.MethodContext;
|
||||
import net.runelite.asm.pool.Class;
|
||||
import net.runelite.asm.pool.Field;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
import static com.openosrs.injector.injection.InjectData.HOOKS;
|
||||
|
||||
public class DrawMenu extends AbstractInjector
|
||||
{
|
||||
private static final net.runelite.asm.pool.Method DRAWMENU = new net.runelite.asm.pool.Method(
|
||||
new Class(HOOKS),
|
||||
"drawMenu",
|
||||
new Signature("()Z")
|
||||
);
|
||||
|
||||
public DrawMenu(InjectData inject)
|
||||
{
|
||||
super(inject);
|
||||
@@ -66,6 +57,7 @@ public class DrawMenu extends AbstractInjector
|
||||
* --------
|
||||
*/
|
||||
|
||||
final net.runelite.asm.pool.Method drawMenu = inject.getVanilla().findClass("client").findMethod("drawMenu").getPoolMethod();
|
||||
final Method drawLoggedIn = InjectUtil.findMethod(inject, "drawLoggedIn", "Client", null, true, false);
|
||||
final Field gameDrawMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField();
|
||||
final Field isMenuOpen = InjectUtil.findField(inject, "isMenuOpen", "Client").getPoolField();
|
||||
@@ -135,7 +127,7 @@ public class DrawMenu extends AbstractInjector
|
||||
final Instructions instrs = mc.getMethod().getCode().getInstructions();
|
||||
int idx = instrs.getInstructions().indexOf(injectInvokeAfter);
|
||||
|
||||
instrs.addInstruction(++idx, new InvokeStatic(instrs, DRAWMENU));
|
||||
instrs.addInstruction(++idx, new InvokeStatic(instrs, drawMenu));
|
||||
instrs.addInstruction(++idx, new IfNe(instrs, labelToJumpTo));
|
||||
|
||||
log.info("[INFO] DrawMenu injected a method call at index {} in method {}. With a comparison jumping to {}", idx, drawLoggedIn, labelToJumpTo);
|
||||
|
||||
@@ -17,17 +17,9 @@ import net.runelite.asm.attributes.code.Instruction;
|
||||
import net.runelite.asm.attributes.code.Instructions;
|
||||
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
||||
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
|
||||
import net.runelite.asm.pool.Class;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
import static com.openosrs.injector.injection.InjectData.HOOKS;
|
||||
|
||||
public class RenderDraw extends AbstractInjector
|
||||
{
|
||||
private static final net.runelite.asm.pool.Method RENDERDRAW = new net.runelite.asm.pool.Method(
|
||||
new Class(HOOKS),
|
||||
"renderDraw",
|
||||
new Signature("(Lnet/runelite/api/Renderable;IIIIIIIIJ)V")
|
||||
);
|
||||
private static final int EXPECTED = 21;
|
||||
|
||||
public RenderDraw(InjectData inject)
|
||||
@@ -38,6 +30,8 @@ public class RenderDraw extends AbstractInjector
|
||||
@Override
|
||||
public void inject()
|
||||
{
|
||||
final net.runelite.asm.pool.Method renderDraw = inject.toVanilla(inject.getDeobfuscated().findClass("Scene")).findMethod("renderDraw").getPoolMethod();
|
||||
|
||||
int replaced = 0;
|
||||
|
||||
/*
|
||||
@@ -56,7 +50,7 @@ public class RenderDraw extends AbstractInjector
|
||||
{
|
||||
if (((InvokeVirtual) i).getMethod().equals(draw))
|
||||
{
|
||||
iterator.set(new InvokeStatic(ins, RENDERDRAW));
|
||||
iterator.set(new InvokeStatic(ins, renderDraw));
|
||||
log.debug("[DEBUG] Replaced method call at {}", i);
|
||||
++replaced;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user