Merge pull request #3214 from open-osrs/move
This commit is contained in:
@@ -30,7 +30,6 @@ import net.runelite.asm.signature.Signature;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public abstract class InjectData
|
public abstract class InjectData
|
||||||
{
|
{
|
||||||
public static final String HOOKS = "net/runelite/client/callback/Hooks";
|
|
||||||
public static final String CALLBACKS = "net/runelite/api/hooks/Callbacks";
|
public static final String CALLBACKS = "net/runelite/api/hooks/Callbacks";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -22,17 +22,9 @@ import net.runelite.asm.execution.Execution;
|
|||||||
import net.runelite.asm.execution.InstructionContext;
|
import net.runelite.asm.execution.InstructionContext;
|
||||||
import net.runelite.asm.execution.MethodContext;
|
import net.runelite.asm.execution.MethodContext;
|
||||||
import net.runelite.asm.execution.StackContext;
|
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
|
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)
|
public ClearColorBuffer(InjectData inject)
|
||||||
{
|
{
|
||||||
super(inject);
|
super(inject);
|
||||||
@@ -40,11 +32,13 @@ public class ClearColorBuffer extends AbstractInjector
|
|||||||
|
|
||||||
public void inject()
|
public void inject()
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class stops the client from basically painting everything black before the scene is drawn
|
* This class stops the client from basically painting everything black before the scene is drawn
|
||||||
*/
|
*/
|
||||||
final Execution exec = new Execution(inject.getVanilla());
|
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 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?
|
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();
|
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());
|
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.Execution;
|
||||||
import net.runelite.asm.execution.InstructionContext;
|
import net.runelite.asm.execution.InstructionContext;
|
||||||
import net.runelite.asm.execution.MethodContext;
|
import net.runelite.asm.execution.MethodContext;
|
||||||
import net.runelite.asm.pool.Class;
|
|
||||||
import net.runelite.asm.pool.Field;
|
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
|
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)
|
public DrawMenu(InjectData inject)
|
||||||
{
|
{
|
||||||
super(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 Method drawLoggedIn = InjectUtil.findMethod(inject, "drawLoggedIn", "Client", null, true, false);
|
||||||
final Field gameDrawMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField();
|
final Field gameDrawMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField();
|
||||||
final Field isMenuOpen = InjectUtil.findField(inject, "isMenuOpen", "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();
|
final Instructions instrs = mc.getMethod().getCode().getInstructions();
|
||||||
int idx = instrs.getInstructions().indexOf(injectInvokeAfter);
|
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));
|
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);
|
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;
|
||||||
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
||||||
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
|
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
|
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;
|
private static final int EXPECTED = 21;
|
||||||
|
|
||||||
public RenderDraw(InjectData inject)
|
public RenderDraw(InjectData inject)
|
||||||
@@ -38,6 +30,8 @@ public class RenderDraw extends AbstractInjector
|
|||||||
@Override
|
@Override
|
||||||
public void inject()
|
public void inject()
|
||||||
{
|
{
|
||||||
|
final net.runelite.asm.pool.Method renderDraw = inject.toVanilla(inject.getDeobfuscated().findClass("Scene")).findMethod("renderDraw").getPoolMethod();
|
||||||
|
|
||||||
int replaced = 0;
|
int replaced = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -56,7 +50,7 @@ public class RenderDraw extends AbstractInjector
|
|||||||
{
|
{
|
||||||
if (((InvokeVirtual) i).getMethod().equals(draw))
|
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);
|
log.debug("[DEBUG] Replaced method call at {}", i);
|
||||||
++replaced;
|
++replaced;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import com.openosrs.injector.injection.InjectData;
|
|||||||
import com.openosrs.injector.rsapi.RSApi;
|
import com.openosrs.injector.rsapi.RSApi;
|
||||||
import net.runelite.asm.ClassFile;
|
import net.runelite.asm.ClassFile;
|
||||||
import net.runelite.asm.ClassGroup;
|
import net.runelite.asm.ClassGroup;
|
||||||
|
import net.runelite.asm.Method;
|
||||||
|
import net.runelite.asm.signature.Signature;
|
||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -31,6 +33,9 @@ public class DrawMenuTest
|
|||||||
deob.addClass(deobClient);
|
deob.addClass(deobClient);
|
||||||
|
|
||||||
InjectData inject = new TestInjection(van, deob, new ClassGroup(), new RSApi());
|
InjectData inject = new TestInjection(van, deob, new ClassGroup(), new RSApi());
|
||||||
|
|
||||||
|
addPhonyMethod(van);
|
||||||
|
|
||||||
inject.initToVanilla();
|
inject.initToVanilla();
|
||||||
new DrawMenu(inject).inject();
|
new DrawMenu(inject).inject();
|
||||||
}
|
}
|
||||||
@@ -48,7 +53,19 @@ public class DrawMenuTest
|
|||||||
deob.addClass(deobClient);
|
deob.addClass(deobClient);
|
||||||
|
|
||||||
InjectData inject = new TestInjection(van, deob, new ClassGroup(), new RSApi());
|
InjectData inject = new TestInjection(van, deob, new ClassGroup(), new RSApi());
|
||||||
|
|
||||||
|
addPhonyMethod(van);
|
||||||
|
|
||||||
inject.initToVanilla();
|
inject.initToVanilla();
|
||||||
new DrawMenu(inject).inject();
|
new DrawMenu(inject).inject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPhonyMethod(ClassGroup vanilla)
|
||||||
|
{
|
||||||
|
final ClassFile c = vanilla.findClass("client");
|
||||||
|
|
||||||
|
final Method clientM = new Method(c, "drawMenu", new Signature("()Z"));
|
||||||
|
clientM.setStatic(true);
|
||||||
|
c.addMethod(clientM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,21 +41,18 @@ import java.util.List;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.BufferProvider;
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.MainBufferProvider;
|
import net.runelite.api.MainBufferProvider;
|
||||||
import net.runelite.api.RenderOverview;
|
import net.runelite.api.RenderOverview;
|
||||||
import net.runelite.api.Renderable;
|
import net.runelite.api.Renderable;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.WorldMapManager;
|
import net.runelite.api.WorldMapManager;
|
||||||
import net.runelite.api.events.BeforeMenuRender;
|
|
||||||
import net.runelite.api.events.BeforeRender;
|
import net.runelite.api.events.BeforeRender;
|
||||||
import net.runelite.api.events.FakeXpDrop;
|
import net.runelite.api.events.FakeXpDrop;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.ScriptCallbackEvent;
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
import net.runelite.api.hooks.Callbacks;
|
import net.runelite.api.hooks.Callbacks;
|
||||||
import net.runelite.api.hooks.DrawCallbacks;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_VIEW;
|
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_VIEW;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
@@ -124,6 +121,7 @@ public class Hooks implements Callbacks
|
|||||||
/**
|
/**
|
||||||
* Get the Graphics2D for the MainBufferProvider image
|
* Get the Graphics2D for the MainBufferProvider image
|
||||||
* This caches the Graphics2D instance so it can be reused
|
* This caches the Graphics2D instance so it can be reused
|
||||||
|
*
|
||||||
* @param mainBufferProvider
|
* @param mainBufferProvider
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -422,6 +420,7 @@ public class Hooks implements Callbacks
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy an image
|
* Copy an image
|
||||||
|
*
|
||||||
* @param src
|
* @param src
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -568,45 +567,6 @@ public class Hooks implements Callbacks
|
|||||||
renderableDrawListeners.remove(listener);
|
renderableDrawListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearColorBuffer(int x, int y, int width, int height, int color)
|
|
||||||
{
|
|
||||||
BufferProvider bp = client.getBufferProvider();
|
|
||||||
int canvasWidth = bp.getWidth();
|
|
||||||
int[] pixels = bp.getPixels();
|
|
||||||
|
|
||||||
int pixelPos = y * canvasWidth + x;
|
|
||||||
int pixelJump = canvasWidth - width;
|
|
||||||
|
|
||||||
for (int cy = y; cy < y + height; cy++)
|
|
||||||
{
|
|
||||||
for (int cx = x; cx < x + width; cx++)
|
|
||||||
{
|
|
||||||
pixels[pixelPos++] = 0;
|
|
||||||
}
|
|
||||||
pixelPos += pixelJump;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderDraw(Renderable renderable, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int x, int y, int z, long hash)
|
|
||||||
{
|
|
||||||
DrawCallbacks drawCallbacks = client.getDrawCallbacks();
|
|
||||||
if (drawCallbacks != null)
|
|
||||||
{
|
|
||||||
drawCallbacks.draw(renderable, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
renderable.draw(orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean drawMenu()
|
|
||||||
{
|
|
||||||
BeforeMenuRender event = new BeforeMenuRender();
|
|
||||||
client.getCallbacks().post(event);
|
|
||||||
return event.isConsumed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean draw(Renderable renderable, boolean drawingUi)
|
public boolean draw(Renderable renderable, boolean drawingUi)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ import net.runelite.api.clan.ClanRank;
|
|||||||
import net.runelite.api.clan.ClanSettings;
|
import net.runelite.api.clan.ClanSettings;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
|
import net.runelite.api.events.BeforeMenuRender;
|
||||||
import net.runelite.api.events.CanvasSizeChanged;
|
import net.runelite.api.events.CanvasSizeChanged;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.api.events.ClanChannelChanged;
|
import net.runelite.api.events.ClanChannelChanged;
|
||||||
@@ -3099,5 +3100,13 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
RSNPC[] var2 = this.getCachedNPCs();
|
RSNPC[] var2 = this.getCachedNPCs();
|
||||||
return var1 >= 0 && var1 < var2.length ? var2[var1] : null;
|
return var1 >= 0 && var1 < var2.length ? var2[var1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public static boolean drawMenu()
|
||||||
|
{
|
||||||
|
BeforeMenuRender event = new BeforeMenuRender();
|
||||||
|
client.getCallbacks().post(event);
|
||||||
|
return event.isConsumed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.runelite.mixins;
|
package net.runelite.mixins;
|
||||||
|
|
||||||
|
import net.runelite.api.BufferProvider;
|
||||||
import net.runelite.api.mixins.Copy;
|
import net.runelite.api.mixins.Copy;
|
||||||
import net.runelite.api.mixins.Inject;
|
import net.runelite.api.mixins.Inject;
|
||||||
import net.runelite.api.mixins.Mixin;
|
import net.runelite.api.mixins.Mixin;
|
||||||
@@ -207,4 +208,24 @@ public abstract class RSRasterizer2DMixin implements RSClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public static void clearColorBuffer(int x, int y, int width, int height, int color)
|
||||||
|
{
|
||||||
|
BufferProvider bp = client.getBufferProvider();
|
||||||
|
int canvasWidth = bp.getWidth();
|
||||||
|
int[] pixels = bp.getPixels();
|
||||||
|
|
||||||
|
int pixelPos = y * canvasWidth + x;
|
||||||
|
int pixelJump = canvasWidth - width;
|
||||||
|
|
||||||
|
for (int cy = y; cy < y + height; cy++)
|
||||||
|
{
|
||||||
|
for (int cx = x; cx < x + width; cx++)
|
||||||
|
{
|
||||||
|
pixels[pixelPos++] = 0;
|
||||||
|
}
|
||||||
|
pixelPos += pixelJump;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import static net.runelite.api.Constants.ROOF_FLAG_POSITION;
|
|||||||
import net.runelite.api.DecorativeObject;
|
import net.runelite.api.DecorativeObject;
|
||||||
import net.runelite.api.GroundObject;
|
import net.runelite.api.GroundObject;
|
||||||
import net.runelite.api.Perspective;
|
import net.runelite.api.Perspective;
|
||||||
|
import net.runelite.api.Renderable;
|
||||||
import net.runelite.api.SceneTileModel;
|
import net.runelite.api.SceneTileModel;
|
||||||
import net.runelite.api.SceneTilePaint;
|
import net.runelite.api.SceneTilePaint;
|
||||||
import net.runelite.api.Tile;
|
import net.runelite.api.Tile;
|
||||||
@@ -1288,4 +1289,18 @@ public abstract class RSSceneMixin implements RSScene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public static void renderDraw(Renderable renderable, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int x, int y, int z, long hash)
|
||||||
|
{
|
||||||
|
DrawCallbacks drawCallbacks = client.getDrawCallbacks();
|
||||||
|
if (drawCallbacks != null)
|
||||||
|
{
|
||||||
|
drawCallbacks.draw(renderable, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderable.draw(orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user