Cleanup in transforms and add projectile.getInteracting() transform (#165)
* Cleanup in transforms and add projectile.getInteracting transform Move whitespace out of string blocks Remove unused method from transform.java Use throws for transform methods, and catch the exceptions in modify() More whitespace between instructions to improve readability * Api changes for projectile.getInteracting, mixin for ref
This commit is contained in:
@@ -37,6 +37,13 @@ public interface Projectile extends Renderable
|
|||||||
*/
|
*/
|
||||||
int getId();
|
int getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the actor that is targeted by this projectile.
|
||||||
|
*
|
||||||
|
* @return the target actor, or null if this projectile is an AoE attack
|
||||||
|
*/
|
||||||
|
Actor getInteracting();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the original x-axis coordinate that this projectile started from.
|
* Gets the original x-axis coordinate that this projectile started from.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Constants;
|
import net.runelite.api.Constants;
|
||||||
import net.runelite.api.DecorativeObject;
|
import net.runelite.api.DecorativeObject;
|
||||||
@@ -391,15 +392,36 @@ class DevToolsOverlay extends Overlay
|
|||||||
|
|
||||||
for (Projectile projectile : projectiles)
|
for (Projectile projectile : projectiles)
|
||||||
{
|
{
|
||||||
int projectileId = projectile.getId();
|
int originX = projectile.getX1();
|
||||||
String text = "(ID: " + projectileId + ")";
|
int originY = projectile.getY1();
|
||||||
int x = (int) projectile.getX();
|
|
||||||
int y = (int) projectile.getY();
|
LocalPoint tilePoint = new LocalPoint(originX, originY);
|
||||||
LocalPoint projectilePoint = new LocalPoint(x, y);
|
Polygon poly = Perspective.getCanvasTilePoly(client, tilePoint);
|
||||||
Point textLocation = Perspective.getCanvasTextLocation(client, graphics, projectilePoint, text, 0);
|
|
||||||
if (textLocation != null)
|
if (poly != null)
|
||||||
{
|
{
|
||||||
OverlayUtil.renderTextLocation(graphics, textLocation, text, Color.RED);
|
OverlayUtil.renderPolygon(graphics, poly, Color.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
int projectileId = projectile.getId();
|
||||||
|
Actor projectileInteracting = projectile.getInteracting();
|
||||||
|
|
||||||
|
String infoString = "";
|
||||||
|
|
||||||
|
if (projectileInteracting == null)
|
||||||
|
{
|
||||||
|
infoString += "AoE";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
infoString += "Targeted (T: " + projectileInteracting.getName() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
infoString += " (ID: " + projectileId + ")";
|
||||||
|
|
||||||
|
if (projectileInteracting != null)
|
||||||
|
{
|
||||||
|
OverlayUtil.renderActorOverlay(graphics, projectile.getInteracting(), infoString, Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
|
import javassist.CannotCompileException;
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
@@ -7,66 +8,63 @@ import javassist.NotFoundException;
|
|||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
public class ActorTransform implements Transform {
|
public class ActorTransform implements Transform {
|
||||||
public CtClass ct = null;
|
private CtClass ct;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(Class actor) {
|
public void modify(Class actor) {
|
||||||
try {
|
try {
|
||||||
ct = ByteCodePatcher.classPool.get(actor.getName());
|
ct = ByteCodePatcher.classPool.get(actor.getName());
|
||||||
|
|
||||||
transformGetAnimation();
|
transformGetAnimation();
|
||||||
transformAnimationChanged();
|
transformAnimationChanged();
|
||||||
transformGraphicChanged();
|
transformGraphicChanged();
|
||||||
|
|
||||||
ByteCodePatcher.modifiedClasses.add(ct);
|
ByteCodePatcher.modifiedClasses.add(ct);
|
||||||
} catch (NotFoundException e) {
|
} catch (CannotCompileException | NotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void transformGetAnimation() throws CannotCompileException, NotFoundException
|
||||||
public void transform() { }
|
{
|
||||||
|
|
||||||
public void transformGetAnimation() {
|
|
||||||
try {
|
|
||||||
CtMethod protectedAnimation = ct.getDeclaredMethod("1protect$getRsAnimation");
|
CtMethod protectedAnimation = ct.getDeclaredMethod("1protect$getRsAnimation");
|
||||||
ct.removeMethod(protectedAnimation);
|
ct.removeMethod(protectedAnimation);
|
||||||
|
|
||||||
protectedAnimation.setName("getRsAnimation");
|
protectedAnimation.setName("getRsAnimation");
|
||||||
ct.addMethod(protectedAnimation);
|
ct.addMethod(protectedAnimation);
|
||||||
|
|
||||||
CtMethod getAnimation = ct.getDeclaredMethod("getAnimation");
|
CtMethod getAnimation = ct.getDeclaredMethod("getAnimation");
|
||||||
ct.removeMethod(getAnimation);
|
ct.removeMethod(getAnimation);
|
||||||
|
|
||||||
getAnimation = CtNewMethod.make("public int getAnimation() { return this.getRsAnimation(); }",ct);
|
getAnimation = CtNewMethod.make("public int getAnimation() { return this.getRsAnimation(); }",ct);
|
||||||
ct.addMethod(getAnimation);
|
ct.addMethod(getAnimation);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void transformAnimationChanged() {
|
private void transformAnimationChanged() throws CannotCompileException, NotFoundException
|
||||||
try {
|
{
|
||||||
CtMethod getAnimationChanged = ct.getDeclaredMethod("animationChanged", new CtClass[]{CtClass.intType});
|
CtMethod getAnimationChanged = ct.getDeclaredMethod("animationChanged", new CtClass[]{CtClass.intType});
|
||||||
ct.removeMethod(getAnimationChanged);
|
ct.removeMethod(getAnimationChanged);
|
||||||
getAnimationChanged = CtNewMethod.make("public void animationChanged(int n) { " +
|
|
||||||
|
getAnimationChanged = CtNewMethod.make(
|
||||||
|
"public void animationChanged(int n) { " +
|
||||||
"net.runelite.api.events.AnimationChanged animationChanged = new net.runelite.api.events.AnimationChanged();" +
|
"net.runelite.api.events.AnimationChanged animationChanged = new net.runelite.api.events.AnimationChanged();" +
|
||||||
"animationChanged.setActor((net.runelite.api.Actor)this);" +
|
"animationChanged.setActor((net.runelite.api.Actor)this);" +
|
||||||
" "+ByteCodePatcher.clientInstance+".getCallbacks().post((java.lang.Object)animationChanged); }",ct);
|
ByteCodePatcher.clientInstance + ".getCallbacks().post((java.lang.Object)animationChanged); }", ct);
|
||||||
ct.addMethod(getAnimationChanged);
|
ct.addMethod(getAnimationChanged);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformGraphicChanged() {
|
private void transformGraphicChanged() throws CannotCompileException, NotFoundException
|
||||||
try {
|
{
|
||||||
CtMethod graphicChanged = ct.getDeclaredMethod("graphicChanged", new CtClass[]{CtClass.intType});
|
CtMethod graphicChanged = ct.getDeclaredMethod("graphicChanged", new CtClass[]{CtClass.intType});
|
||||||
ct.removeMethod(graphicChanged);
|
ct.removeMethod(graphicChanged);
|
||||||
graphicChanged = CtNewMethod.make("public void graphicChanged(int paramInt){" +
|
|
||||||
|
graphicChanged = CtNewMethod.make(
|
||||||
|
"public void graphicChanged(int paramInt){" +
|
||||||
"net.runelite.api.events.GraphicChanged localGraphicChanged = new net.runelite.api.events.GraphicChanged();" +
|
"net.runelite.api.events.GraphicChanged localGraphicChanged = new net.runelite.api.events.GraphicChanged();" +
|
||||||
"localGraphicChanged.setActor(this);" +
|
"localGraphicChanged.setActor(this);" +
|
||||||
" "+ByteCodePatcher.clientInstance+".getCallbacks().post(localGraphicChanged);}",ct);
|
ByteCodePatcher.clientInstance+".getCallbacks().post(localGraphicChanged);}",ct);
|
||||||
ct.addMethod(graphicChanged);
|
ct.addMethod(graphicChanged);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
import javassist.CtBehavior;
|
import javassist.CannotCompileException;
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtField;
|
|
||||||
import javassist.CtMember;
|
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
|
import javassist.NotFoundException;
|
||||||
import javassist.bytecode.AnnotationsAttribute;
|
import javassist.bytecode.AnnotationsAttribute;
|
||||||
import javassist.bytecode.ClassFile;
|
import javassist.bytecode.ClassFile;
|
||||||
import javassist.bytecode.ConstPool;
|
import javassist.bytecode.ConstPool;
|
||||||
import javassist.bytecode.StackMapTable;
|
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
public class ClientTransform implements Transform {
|
public class ClientTransform implements Transform {
|
||||||
|
|
||||||
public CtClass ct = null;
|
private CtClass ct;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(Class clazz) {
|
public void modify(Class clazz) {
|
||||||
try {
|
try {
|
||||||
ct = ByteCodePatcher.classPool.get(clazz.getName());
|
ct = ByteCodePatcher.classPool.get(clazz.getName());
|
||||||
|
|
||||||
transformProtectedGetMenuOptions();
|
transformProtectedGetMenuOptions();
|
||||||
transformProtectedGetMenuTargets();
|
transformProtectedGetMenuTargets();
|
||||||
transformProtectedGetMenuIdentifiers();
|
transformProtectedGetMenuIdentifiers();
|
||||||
@@ -42,29 +41,32 @@ public class ClientTransform implements Transform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformProtectedGetMenuOptions() {
|
private void transformProtectedGetMenuOptions() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod protectedGetMenuOptions;
|
CtMethod protectedGetMenuOptions;
|
||||||
try {
|
|
||||||
protectedGetMenuOptions = ct.getDeclaredMethod("1protect$getMenuOptions");
|
protectedGetMenuOptions = ct.getDeclaredMethod("1protect$getMenuOptions");
|
||||||
ct.removeMethod(protectedGetMenuOptions);
|
ct.removeMethod(protectedGetMenuOptions);
|
||||||
|
|
||||||
protectedGetMenuOptions.setName("getMenuOptions");
|
protectedGetMenuOptions.setName("getMenuOptions");
|
||||||
ct.addMethod(protectedGetMenuOptions);
|
ct.addMethod(protectedGetMenuOptions);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformGetProjectiles() {
|
private void transformGetProjectiles() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod getProjectiles;
|
CtMethod getProjectiles;
|
||||||
try {
|
|
||||||
CtMethod getProjectilesDeque = ct.getDeclaredMethod("1protect$getProjectilesDeque");
|
CtMethod getProjectilesDeque = ct.getDeclaredMethod("1protect$getProjectilesDeque");
|
||||||
ct.removeMethod(getProjectilesDeque);
|
ct.removeMethod(getProjectilesDeque);
|
||||||
|
|
||||||
getProjectilesDeque.setName("getProjectilesDeque");
|
getProjectilesDeque.setName("getProjectilesDeque");
|
||||||
ct.addMethod(getProjectilesDeque);
|
ct.addMethod(getProjectilesDeque);
|
||||||
|
|
||||||
getProjectiles = ct.getDeclaredMethod("getProjectiles");
|
getProjectiles = ct.getDeclaredMethod("getProjectiles");
|
||||||
ct.removeMethod(getProjectiles);
|
ct.removeMethod(getProjectiles);
|
||||||
getProjectiles = CtNewMethod.make("public java.util.List getProjectiles() { " +
|
|
||||||
|
getProjectiles = CtNewMethod.make(
|
||||||
|
"public java.util.List getProjectiles() { " +
|
||||||
"java.util.ArrayList localArrayList = new java.util.ArrayList();" +
|
"java.util.ArrayList localArrayList = new java.util.ArrayList();" +
|
||||||
"net.runelite.rs.api.RSDeque localRSDeque = getProjectilesDeque();" +
|
"net.runelite.rs.api.RSDeque localRSDeque = getProjectilesDeque();" +
|
||||||
"net.runelite.rs.api.RSNode localRSNode = localRSDeque.getHead();" +
|
"net.runelite.rs.api.RSNode localRSNode = localRSDeque.getHead();" +
|
||||||
@@ -72,8 +74,8 @@ public class ClientTransform implements Transform {
|
|||||||
"net.runelite.api.Projectile localProjectile = (net.runelite.api.Projectile)localNode;" +
|
"net.runelite.api.Projectile localProjectile = (net.runelite.api.Projectile)localNode;" +
|
||||||
"localArrayList.add(localProjectile); }" +
|
"localArrayList.add(localProjectile); }" +
|
||||||
"return localArrayList; }", ct);
|
"return localArrayList; }", ct);
|
||||||
|
|
||||||
ct.addMethod(getProjectiles);
|
ct.addMethod(getProjectiles);
|
||||||
|
|
||||||
ClassFile classFile = ct.getClassFile();
|
ClassFile classFile = ct.getClassFile();
|
||||||
ConstPool constPool = classFile.getConstPool();
|
ConstPool constPool = classFile.getConstPool();
|
||||||
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
|
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
|
||||||
@@ -81,98 +83,91 @@ public class ClientTransform implements Transform {
|
|||||||
attr.setAnnotation(annotation);
|
attr.setAnnotation(annotation);
|
||||||
getProjectiles.getMethodInfo().addAttribute(attr);
|
getProjectiles.getMethodInfo().addAttribute(attr);
|
||||||
System.out.println("Added override annotation for getprojectiles");
|
System.out.println("Added override annotation for getprojectiles");
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public void transformProtectedGetMenuTargets() {
|
private void transformProtectedGetMenuTargets() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod protectedGetMenuTargets;
|
CtMethod protectedGetMenuTargets;
|
||||||
try {
|
|
||||||
protectedGetMenuTargets = ct.getDeclaredMethod("1protect$getMenuTargets");
|
protectedGetMenuTargets = ct.getDeclaredMethod("1protect$getMenuTargets");
|
||||||
ct.removeMethod(protectedGetMenuTargets);
|
ct.removeMethod(protectedGetMenuTargets);
|
||||||
|
|
||||||
protectedGetMenuTargets.setName("getMenuTargets");
|
protectedGetMenuTargets.setName("getMenuTargets");
|
||||||
ct.addMethod(protectedGetMenuTargets);
|
ct.addMethod(protectedGetMenuTargets);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformGetCollisionMaps() {
|
private void transformGetCollisionMaps() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod getCollisionMaps;
|
CtMethod getCollisionMaps;
|
||||||
try {
|
|
||||||
CtMethod protectedMaps = ct.getDeclaredMethod("1protect$getRsCollisionMaps");
|
CtMethod protectedMaps = ct.getDeclaredMethod("1protect$getRsCollisionMaps");
|
||||||
ct.removeMethod(protectedMaps);
|
ct.removeMethod(protectedMaps);
|
||||||
|
|
||||||
protectedMaps.setName("getRsCollisionMaps");
|
protectedMaps.setName("getRsCollisionMaps");
|
||||||
ct.addMethod(protectedMaps);
|
ct.addMethod(protectedMaps);
|
||||||
|
|
||||||
getCollisionMaps = ct.getDeclaredMethod("getCollisionMaps");
|
getCollisionMaps = ct.getDeclaredMethod("getCollisionMaps");
|
||||||
ct.removeMethod(getCollisionMaps);
|
ct.removeMethod(getCollisionMaps);
|
||||||
getCollisionMaps = CtMethod.make("public net.runelite.rs.api.RSCollisionData[] getCollisionMaps() {" +
|
|
||||||
" return getRsCollisionMaps();" +
|
getCollisionMaps = CtMethod.make("public net.runelite.rs.api.RSCollisionData[] getCollisionMaps() { return getRsCollisionMaps(); }", ct);
|
||||||
" }", ct);
|
|
||||||
ct.addMethod(getCollisionMaps);
|
ct.addMethod(getCollisionMaps);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public void transformProtectedGetMenuIdentifiers() {
|
private void transformProtectedGetMenuIdentifiers() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod protectedGetMenuIdentifiers;
|
CtMethod protectedGetMenuIdentifiers;
|
||||||
try {
|
|
||||||
protectedGetMenuIdentifiers = ct.getDeclaredMethod("1protect$getMenuIdentifiers");
|
protectedGetMenuIdentifiers = ct.getDeclaredMethod("1protect$getMenuIdentifiers");
|
||||||
ct.removeMethod(protectedGetMenuIdentifiers);
|
ct.removeMethod(protectedGetMenuIdentifiers);
|
||||||
|
|
||||||
protectedGetMenuIdentifiers.setName("getMenuIdentifiers");
|
protectedGetMenuIdentifiers.setName("getMenuIdentifiers");
|
||||||
ct.addMethod(protectedGetMenuIdentifiers);
|
ct.addMethod(protectedGetMenuIdentifiers);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformProtectedGetMenuTypes() {
|
private void transformProtectedGetMenuTypes() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod protectedGetMenuTypes;
|
CtMethod protectedGetMenuTypes;
|
||||||
try {
|
|
||||||
protectedGetMenuTypes = ct.getDeclaredMethod("1protect$getMenuTypes");
|
protectedGetMenuTypes = ct.getDeclaredMethod("1protect$getMenuTypes");
|
||||||
|
|
||||||
// Don't remove as this is referenced elsewhere in client
|
// Don't remove as this is referenced elsewhere in client
|
||||||
//ct.removeMethod(protectedGetMenuTypes);
|
//ct.removeMethod(protectedGetMenuTypes);
|
||||||
|
|
||||||
CtMethod newProtectedGetMenuTypes = CtNewMethod.copy(protectedGetMenuTypes, ct, null);
|
CtMethod newProtectedGetMenuTypes = CtNewMethod.copy(protectedGetMenuTypes, ct, null);
|
||||||
newProtectedGetMenuTypes.setName("getMenuTypes");
|
newProtectedGetMenuTypes.setName("getMenuTypes");
|
||||||
|
|
||||||
ct.addMethod(newProtectedGetMenuTypes);
|
ct.addMethod(newProtectedGetMenuTypes);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformProtectedGetMenuActionParams0() {
|
private void transformProtectedGetMenuActionParams0() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod protectedGetMenuActionParams0;
|
CtMethod protectedGetMenuActionParams0;
|
||||||
try {
|
|
||||||
protectedGetMenuActionParams0 = ct.getDeclaredMethod("1protect$getMenuActionParams0");
|
protectedGetMenuActionParams0 = ct.getDeclaredMethod("1protect$getMenuActionParams0");
|
||||||
ct.removeMethod(protectedGetMenuActionParams0);
|
ct.removeMethod(protectedGetMenuActionParams0);
|
||||||
|
|
||||||
protectedGetMenuActionParams0.setName("getMenuActionParams0");
|
protectedGetMenuActionParams0.setName("getMenuActionParams0");
|
||||||
ct.addMethod(protectedGetMenuActionParams0);
|
ct.addMethod(protectedGetMenuActionParams0);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformProtectedGetMenuActionParams1() {
|
private void transformProtectedGetMenuActionParams1() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod protectedGetMenuActionParams1;
|
CtMethod protectedGetMenuActionParams1;
|
||||||
try {
|
|
||||||
protectedGetMenuActionParams1 = ct.getDeclaredMethod("1protect$getMenuActionParams1");
|
protectedGetMenuActionParams1 = ct.getDeclaredMethod("1protect$getMenuActionParams1");
|
||||||
ct.removeMethod(protectedGetMenuActionParams1);
|
ct.removeMethod(protectedGetMenuActionParams1);
|
||||||
protectedGetMenuActionParams1.setName("getMenuActionParams1");
|
protectedGetMenuActionParams1.setName("getMenuActionParams1");
|
||||||
ct.addMethod(protectedGetMenuActionParams1);
|
ct.addMethod(protectedGetMenuActionParams1);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void transformGetMenuEntries() throws CannotCompileException, NotFoundException
|
||||||
public void transform() {}
|
{
|
||||||
|
|
||||||
public void transformGetMenuEntries() {
|
|
||||||
CtMethod getMenuEntries;
|
CtMethod getMenuEntries;
|
||||||
try {
|
|
||||||
getMenuEntries = ct.getDeclaredMethod("getMenuEntries");
|
getMenuEntries = ct.getDeclaredMethod("getMenuEntries");
|
||||||
ct.removeMethod(getMenuEntries);
|
ct.removeMethod(getMenuEntries);
|
||||||
getMenuEntries = CtMethod.make("public net.runelite.api.MenuEntry[] getMenuEntries() {" +
|
|
||||||
|
getMenuEntries = CtMethod.make(
|
||||||
|
"public net.runelite.api.MenuEntry[] getMenuEntries() {" +
|
||||||
"int n2 = this.getMenuOptionCount();"+
|
"int n2 = this.getMenuOptionCount();"+
|
||||||
"String[] arrstring = this.getMenuOptions();"+
|
"String[] arrstring = this.getMenuOptions();"+
|
||||||
"String[] arrstring2 = this.getMenuTargets();"+
|
"String[] arrstring2 = this.getMenuTargets();"+
|
||||||
@@ -192,22 +187,16 @@ public class ClientTransform implements Transform {
|
|||||||
"menuEntry.setParam0(arrn3[n3]);"+
|
"menuEntry.setParam0(arrn3[n3]);"+
|
||||||
"menuEntry.setParam1(arrn4[n3]);"+
|
"menuEntry.setParam1(arrn4[n3]);"+
|
||||||
"menuEntry.setForceLeftClick(arrbl[n3]);"+
|
"menuEntry.setForceLeftClick(arrbl[n3]);"+
|
||||||
" ++n3;"+
|
"++n3; }"+
|
||||||
" }"+
|
"return arrmenuEntry; }", ct);
|
||||||
" return arrmenuEntry;"+
|
|
||||||
" }", ct);
|
|
||||||
ct.addMethod(getMenuEntries);
|
ct.addMethod(getMenuEntries);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformSetMenuEntries() {
|
private void transformSetMenuEntries() throws CannotCompileException, NotFoundException {
|
||||||
CtMethod setMenuEntries;
|
CtMethod setMenuEntries;
|
||||||
try {
|
|
||||||
setMenuEntries = ct.getDeclaredMethod("setMenuEntries");
|
setMenuEntries = ct.getDeclaredMethod("setMenuEntries");
|
||||||
ct.removeMethod(setMenuEntries);
|
ct.removeMethod(setMenuEntries);
|
||||||
String src;
|
|
||||||
setMenuEntries = CtNewMethod.make(
|
setMenuEntries = CtNewMethod.make(
|
||||||
"public void setMenuEntries(net.runelite.api.MenuEntry[] arrmenuEntry) {" +
|
"public void setMenuEntries(net.runelite.api.MenuEntry[] arrmenuEntry) {" +
|
||||||
"int n2 = 0;" +
|
"int n2 = 0;" +
|
||||||
@@ -243,55 +232,58 @@ public class ClientTransform implements Transform {
|
|||||||
"}"
|
"}"
|
||||||
, ct);
|
, ct);
|
||||||
ct.addMethod(setMenuEntries);
|
ct.addMethod(setMenuEntries);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformOnMenuOptionsChanged() {
|
private void transformOnMenuOptionsChanged() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod onMenuOptionsChanged;
|
CtMethod onMenuOptionsChanged;
|
||||||
try {
|
|
||||||
onMenuOptionsChanged = ct.getDeclaredMethod("onMenuOptionsChanged", new CtClass[]{CtClass.intType});
|
onMenuOptionsChanged = ct.getDeclaredMethod("onMenuOptionsChanged", new CtClass[]{CtClass.intType});
|
||||||
ct.removeMethod(onMenuOptionsChanged);
|
ct.removeMethod(onMenuOptionsChanged);
|
||||||
onMenuOptionsChanged = CtMethod.make(" public static void onMenuOptionsChanged(int n2) {"+
|
|
||||||
|
onMenuOptionsChanged = CtMethod.make(
|
||||||
|
"public static void onMenuOptionsChanged(int n2) {"+
|
||||||
"int n3;" +
|
"int n3;" +
|
||||||
"int n4 = oldMenuEntryCount;"+
|
"int n4 = oldMenuEntryCount;"+
|
||||||
"oldMenuEntryCount = n3 = "+ByteCodePatcher.clientInstance+".getMenuOptionCount();"+
|
"oldMenuEntryCount = n3 = "+ByteCodePatcher.clientInstance+".getMenuOptionCount();"+
|
||||||
"if (n3 != n4 + 1) return;"+
|
"if (n3 != n4 + 1) return;"+
|
||||||
" net.runelite.api.events.MenuEntryAdded menuEntryAdded = new net.runelite.api.events.MenuEntryAdded("+ByteCodePatcher.clientInstance+".getMenuOptions()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuTargets()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuTypes()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuIdentifiers()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuActionParams0()[n3 - 1], "+ByteCodePatcher.clientInstance+".getMenuActionParams1()[n3 - 1]);"+
|
"net.runelite.api.events.MenuEntryAdded menuEntryAdded = new net.runelite.api.events.MenuEntryAdded("+
|
||||||
" "+ByteCodePatcher.clientInstance+".getCallbacks().post((Object)menuEntryAdded);" +
|
ByteCodePatcher.clientInstance+".getMenuOptions()[n3 - 1],"+
|
||||||
|
ByteCodePatcher.clientInstance+".getMenuTargets()[n3 - 1],"+
|
||||||
|
ByteCodePatcher.clientInstance+".getMenuTypes()[n3 - 1],"+
|
||||||
|
ByteCodePatcher.clientInstance+".getMenuIdentifiers()[n3 - 1],"+
|
||||||
|
ByteCodePatcher.clientInstance+".getMenuActionParams0()[n3 - 1],"+
|
||||||
|
ByteCodePatcher.clientInstance+".getMenuActionParams1()[n3 - 1]);"+
|
||||||
|
ByteCodePatcher.clientInstance+".getCallbacks().post((Object)menuEntryAdded);"+
|
||||||
"}"
|
"}"
|
||||||
, ct);
|
, ct);
|
||||||
|
|
||||||
ct.addMethod(onMenuOptionsChanged);
|
ct.addMethod(onMenuOptionsChanged);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformRenderSelf() {
|
private void transformRenderSelf() throws CannotCompileException
|
||||||
|
{
|
||||||
CtMethod renderSelf;
|
CtMethod renderSelf;
|
||||||
try {
|
|
||||||
renderSelf = CtMethod.make(" public void toggleRenderSelf() {"+
|
renderSelf = CtMethod.make("public void toggleRenderSelf() { jb = !jb; }", ct);
|
||||||
" jb = !jb;"+
|
|
||||||
" }"
|
|
||||||
, ct);
|
|
||||||
ClassFile classFile = ct.getClassFile();
|
ClassFile classFile = ct.getClassFile();
|
||||||
ConstPool constPool = classFile.getConstPool();
|
ConstPool constPool = classFile.getConstPool();
|
||||||
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
|
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
|
||||||
javassist.bytecode.annotation.Annotation annotation = new javassist.bytecode.annotation.Annotation("Export", constPool);
|
javassist.bytecode.annotation.Annotation annotation = new javassist.bytecode.annotation.Annotation("Export", constPool);
|
||||||
attr.setAnnotation(annotation);
|
attr.setAnnotation(annotation);
|
||||||
renderSelf.getMethodInfo().addAttribute(attr);
|
renderSelf.getMethodInfo().addAttribute(attr);
|
||||||
|
|
||||||
ct.addMethod(renderSelf);
|
ct.addMethod(renderSelf);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformDraw2010Menu() {
|
private void transformDraw2010Menu() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod draw2010Menu;
|
CtMethod draw2010Menu;
|
||||||
try {
|
|
||||||
draw2010Menu = ct.getDeclaredMethod("draw2010Menu");
|
draw2010Menu = ct.getDeclaredMethod("draw2010Menu");
|
||||||
ct.removeMethod(draw2010Menu);
|
ct.removeMethod(draw2010Menu);
|
||||||
|
|
||||||
draw2010Menu = CtNewMethod.make(
|
draw2010Menu = CtNewMethod.make(
|
||||||
"public void draw2010Menu() {" +
|
"public void draw2010Menu() {" +
|
||||||
"int n2 = this.getMenuX();" +
|
"int n2 = this.getMenuX();" +
|
||||||
@@ -338,16 +330,15 @@ public class ClientTransform implements Transform {
|
|||||||
"}"
|
"}"
|
||||||
, ct);
|
, ct);
|
||||||
ct.addMethod(draw2010Menu);
|
ct.addMethod(draw2010Menu);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: fix not being able to click far away objects towards top of screen only.
|
//TODO: fix not being able to click far away objects towards top of screen only.
|
||||||
public void transformboundingBoxCheck() {
|
private void transformboundingBoxCheck() throws CannotCompileException
|
||||||
|
{
|
||||||
CtMethod boundingboxCheck2;
|
CtMethod boundingboxCheck2;
|
||||||
try {
|
|
||||||
boundingboxCheck2 = CtMethod.make(" public boolean boundingboxCheck2(net.runelite.api.Model model, int n2, int n3, int n4) {" +
|
boundingboxCheck2 = CtMethod.make(
|
||||||
|
"public boolean boundingboxCheck2(net.runelite.api.Model model, int n2, int n3, int n4) {" +
|
||||||
"int n5 = "+ByteCodePatcher.clientInstance+".getCameraPitch();" +
|
"int n5 = "+ByteCodePatcher.clientInstance+".getCameraPitch();" +
|
||||||
"int n6 = "+ByteCodePatcher.clientInstance+".getCameraYaw();" +
|
"int n6 = "+ByteCodePatcher.clientInstance+".getCameraYaw();" +
|
||||||
"int n7 = net.runelite.api.Perspective.SINE[n5];" +
|
"int n7 = net.runelite.api.Perspective.SINE[n5];" +
|
||||||
@@ -411,17 +402,17 @@ public class ClientTransform implements Transform {
|
|||||||
"return false;" +
|
"return false;" +
|
||||||
"}", ct);
|
"}", ct);
|
||||||
ct.addMethod(boundingboxCheck2);
|
ct.addMethod(boundingboxCheck2);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformcheckClickBox() {
|
private void transformcheckClickBox() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
CtMethod checkClickBox;
|
CtMethod checkClickBox;
|
||||||
try {
|
|
||||||
checkClickBox = ct.getDeclaredMethod("checkClickbox");
|
checkClickBox = ct.getDeclaredMethod("checkClickbox");
|
||||||
ct.removeMethod(checkClickBox);
|
ct.removeMethod(checkClickBox);
|
||||||
checkClickBox = CtMethod.make("public void checkClickbox(net.runelite.api.Model model, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, long l2) {"+
|
|
||||||
|
checkClickBox = CtMethod.make(
|
||||||
|
"public void checkClickbox(net.runelite.api.Model model, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, long l2) {"+
|
||||||
"int n10;" +
|
"int n10;" +
|
||||||
"int n11;" +
|
"int n11;" +
|
||||||
"int n12;" +
|
"int n12;" +
|
||||||
@@ -502,11 +493,7 @@ public class ClientTransform implements Transform {
|
|||||||
"}" +
|
"}" +
|
||||||
"++n13;" +
|
"++n13;" +
|
||||||
"}" +
|
"}" +
|
||||||
" }"
|
"}", ct);
|
||||||
, ct);
|
|
||||||
ct.addMethod(checkClickBox);
|
ct.addMethod(checkClickBox);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,43 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
|
import javassist.CannotCompileException;
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.NotFoundException;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
//This prevents the client from sending stack traces to Jagex at all, even classes outside of runelite.
|
//This prevents the client from sending stack traces to Jagex at all, even classes outside of runelite.
|
||||||
public class ErrorTransform implements Transform {
|
public class ErrorTransform implements Transform {
|
||||||
public CtClass ct = null;
|
private CtClass ct;
|
||||||
|
|
||||||
//Where Runelites error interceptor is located, not auto-scraped.
|
//Where Runelites error interceptor is located, not auto-scraped.
|
||||||
private final String ERROR_INSTANCE_CLASS = "dp";
|
private static final String ERROR_INSTANCE_CLASS = "dp";
|
||||||
private final String ERROR_INSTANCE_METHOD = "a";
|
private static final String ERROR_INSTANCE_METHOD = "a";
|
||||||
private final String ERROR_WARNING = "Tried to send a warning";
|
//private static final String ERROR_WARNING = "Tried to send a warning";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(Class clazz) {
|
public void modify(Class clazz) {
|
||||||
try {
|
try {
|
||||||
System.out.println("[RuneLitePlus] Transforming error method at class: "+ERROR_INSTANCE_CLASS);
|
System.out.println("[RuneLitePlus] Transforming error method at class: "+ERROR_INSTANCE_CLASS);
|
||||||
|
|
||||||
ct = ByteCodePatcher.classPool.get(ERROR_INSTANCE_CLASS);
|
ct = ByteCodePatcher.classPool.get(ERROR_INSTANCE_CLASS);
|
||||||
CtMethod error = ct.getDeclaredMethod(ERROR_INSTANCE_METHOD);
|
transformError();
|
||||||
ct.removeMethod(error);
|
|
||||||
error = CtMethod.make("public static void a(String string, Throwable throwable, byte by) {"+
|
|
||||||
" throwable.printStackTrace();"+
|
|
||||||
" System.out.println(\"[RuneLitePlus] Prevented preceeding stack trace from being sent to Jagex\");"+
|
|
||||||
" }", ct);
|
|
||||||
ct.addMethod(error);
|
|
||||||
ByteCodePatcher.modifiedClasses.add(ct);
|
ByteCodePatcher.modifiedClasses.add(ct);
|
||||||
} catch (Exception e) {
|
} catch (CannotCompileException | NotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void transformError() throws CannotCompileException, NotFoundException
|
||||||
public void transform() {
|
{
|
||||||
|
CtMethod error = ct.getDeclaredMethod(ERROR_INSTANCE_METHOD);
|
||||||
|
ct.removeMethod(error);
|
||||||
|
|
||||||
|
error = CtMethod.make(
|
||||||
|
"public static void a(String string, Throwable throwable, byte by) {"+
|
||||||
|
"throwable.printStackTrace();"+
|
||||||
|
"System.out.println(\"[RuneLitePlus] Prevented preceeding stack trace from being sent to Jagex\");}", ct);
|
||||||
|
ct.addMethod(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
|
import javassist.CannotCompileException;
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
|
import javassist.NotFoundException;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
public class PlayerTransform implements Transform {
|
public class PlayerTransform implements Transform {
|
||||||
public CtClass ct = null;
|
private CtClass ct;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(Class player) {
|
public void modify(Class player) {
|
||||||
@@ -15,34 +17,31 @@ public class PlayerTransform implements Transform {
|
|||||||
transformProtectedGetSkullIcon();
|
transformProtectedGetSkullIcon();
|
||||||
transformGetSkullIcon();
|
transformGetSkullIcon();
|
||||||
ByteCodePatcher.modifiedClasses.add(ct);
|
ByteCodePatcher.modifiedClasses.add(ct);
|
||||||
} catch (Exception e) {
|
} catch (CannotCompileException | NotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void transformProtectedGetSkullIcon() throws CannotCompileException, NotFoundException {
|
||||||
public void transform(){}
|
|
||||||
|
|
||||||
public void transformProtectedGetSkullIcon() {
|
|
||||||
CtMethod protectedGetSkullIcon;
|
CtMethod protectedGetSkullIcon;
|
||||||
try {
|
|
||||||
protectedGetSkullIcon = ct.getDeclaredMethod("1protect$getRsSkullIcon");
|
protectedGetSkullIcon = ct.getDeclaredMethod("1protect$getRsSkullIcon");
|
||||||
ct.removeMethod(protectedGetSkullIcon);
|
ct.removeMethod(protectedGetSkullIcon);
|
||||||
protectedGetSkullIcon.setName("getRsSkullIcon");
|
protectedGetSkullIcon.setName("getRsSkullIcon");
|
||||||
|
|
||||||
ct.addMethod(protectedGetSkullIcon);
|
ct.addMethod(protectedGetSkullIcon);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private void transformGetSkullIcon() throws CannotCompileException, NotFoundException
|
||||||
|
{
|
||||||
public void transformGetSkullIcon() {
|
|
||||||
CtMethod getSkullIcon;
|
CtMethod getSkullIcon;
|
||||||
try {
|
|
||||||
String SkullIcon = "net.runelite.api.SkullIcon";
|
String SkullIcon = "net.runelite.api.SkullIcon";
|
||||||
getSkullIcon = ct.getDeclaredMethod("getSkullIcon");
|
getSkullIcon = ct.getDeclaredMethod("getSkullIcon");
|
||||||
ct.removeMethod(getSkullIcon);
|
ct.removeMethod(getSkullIcon);
|
||||||
getSkullIcon = CtNewMethod.make("public "+SkullIcon+" getSkullIcon() {" +
|
|
||||||
|
getSkullIcon = CtNewMethod.make(
|
||||||
|
"public "+SkullIcon+" getSkullIcon() {" +
|
||||||
"switch (this.getRsSkullIcon()) {" +
|
"switch (this.getRsSkullIcon()) {" +
|
||||||
"case 0: {" +
|
"case 0: {" +
|
||||||
"return " + SkullIcon + ".SKULL; }" +
|
"return " + SkullIcon + ".SKULL; }" +
|
||||||
@@ -60,8 +59,5 @@ public class PlayerTransform implements Transform {
|
|||||||
"return " + SkullIcon + ".DEAD_MAN_ONE; } }" +
|
"return " + SkullIcon + ".DEAD_MAN_ONE; } }" +
|
||||||
"return null; }", ct);
|
"return null; }", ct);
|
||||||
ct.addMethod(getSkullIcon);
|
ct.addMethod(getSkullIcon);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,80 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
|
import javassist.CannotCompileException;
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
|
import javassist.NotFoundException;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
|
||||||
public class ProjectileTransform implements Transform {
|
public class ProjectileTransform implements Transform {
|
||||||
public CtClass ct = null;
|
private CtClass ct;
|
||||||
|
|
||||||
|
// Next variable is manually added, and will break on rev update
|
||||||
|
private static final String interactingIntvalue = "-1655053057";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(Class projectile) {
|
public void modify(Class projectile) {
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
ct = ByteCodePatcher.classPool.get(projectile.getName());
|
ct = ByteCodePatcher.classPool.get(projectile.getName());
|
||||||
transform();
|
|
||||||
|
transformGetAnimation();
|
||||||
|
|
||||||
|
transformInteracting();
|
||||||
|
|
||||||
ByteCodePatcher.modifiedClasses.add(ct);
|
ByteCodePatcher.modifiedClasses.add(ct);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (CannotCompileException | NotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void transformGetAnimation() throws CannotCompileException, NotFoundException
|
||||||
public void transform() {
|
{
|
||||||
CtMethod getAnimation;
|
CtMethod getAnimation;
|
||||||
try {
|
|
||||||
getAnimation = ct.getDeclaredMethod("projectileMoved", new CtClass[]{CtClass.intType, CtClass.intType, CtClass.intType, CtClass.intType});
|
getAnimation = ct.getDeclaredMethod("projectileMoved", new CtClass[]{CtClass.intType, CtClass.intType, CtClass.intType, CtClass.intType});
|
||||||
ct.removeMethod(getAnimation);
|
ct.removeMethod(getAnimation);
|
||||||
getAnimation = CtNewMethod.make("public void projectileMoved(int n, int n2, int n3, int n4) { " +
|
|
||||||
|
getAnimation = CtNewMethod.make(
|
||||||
|
"public void projectileMoved(int n, int n2, int n3, int n4) { " +
|
||||||
"int n5 = this.getId();" +
|
"int n5 = this.getId();" +
|
||||||
"net.runelite.api.coords.LocalPoint localPoint = new net.runelite.api.coords.LocalPoint(n, n2);" +
|
"net.runelite.api.coords.LocalPoint localPoint = new net.runelite.api.coords.LocalPoint(n, n2);" +
|
||||||
"net.runelite.api.events.ProjectileMoved projectileMoved = new net.runelite.api.events.ProjectileMoved();" +
|
"net.runelite.api.events.ProjectileMoved projectileMoved = new net.runelite.api.events.ProjectileMoved();" +
|
||||||
"projectileMoved.setProjectile(this);" +
|
"projectileMoved.setProjectile(this);" +
|
||||||
"projectileMoved.setPosition(localPoint);" +
|
"projectileMoved.setPosition(localPoint);" +
|
||||||
"projectileMoved.setZ(n3);" +
|
"projectileMoved.setZ(n3);" +
|
||||||
" "+ByteCodePatcher.clientInstance+".getCallbacks().post(projectileMoved); }",ct);
|
ByteCodePatcher.clientInstance + ".getCallbacks().post(projectileMoved); }", ct);
|
||||||
ct.addMethod(getAnimation);
|
ct.addMethod(getAnimation);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void transformInteracting() throws CannotCompileException
|
||||||
|
{
|
||||||
|
CtMethod getRsInteracting;
|
||||||
|
CtMethod getInteracting;
|
||||||
|
|
||||||
|
getRsInteracting = CtNewMethod.make("public int getRsInteracting() { return this.n * " + interactingIntvalue + "; }", ct);
|
||||||
|
ct.addMethod(getRsInteracting);
|
||||||
|
|
||||||
|
getInteracting = CtNewMethod.make(
|
||||||
|
"public net.runelite.api.Actor getInteracting() {" +
|
||||||
|
"int var1 = this.getRsInteracting();" +
|
||||||
|
"if (var1 == 0) {" +
|
||||||
|
"return null;" +
|
||||||
|
"} else {" +
|
||||||
|
"int var2;" +
|
||||||
|
"if (var1 > 0) {" +
|
||||||
|
"var2 = var1 - 1;" +
|
||||||
|
"net.runelite.rs.api.RSNPC[] var4 = " + ByteCodePatcher.clientInstance + ".getCachedNPCs();" +
|
||||||
|
"return var4[var2];" +
|
||||||
|
"} else {" +
|
||||||
|
"var2 = -var1 - 1;" +
|
||||||
|
"if (var2 == " + ByteCodePatcher.clientInstance + ".getLocalInteractingIndex()) {" +
|
||||||
|
"return " + ByteCodePatcher.clientInstance + ".getLocalPlayer();" +
|
||||||
|
"} else {" +
|
||||||
|
"net.runelite.rs.api.RSPlayer[] var3 = " + ByteCodePatcher.clientInstance + ".getCachedPlayers();" +
|
||||||
|
"return var3[var2]; }}}}", ct);
|
||||||
|
ct.addMethod(getInteracting);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ package net.runelite.client.rs.bytecode.transformers;
|
|||||||
public interface Transform {
|
public interface Transform {
|
||||||
|
|
||||||
void modify(Class clazz);
|
void modify(Class clazz);
|
||||||
void transform();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.mixins;
|
package net.runelite.mixins;
|
||||||
|
|
||||||
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.events.ProjectileMoved;
|
import net.runelite.api.events.ProjectileMoved;
|
||||||
import net.runelite.api.mixins.Inject;
|
import net.runelite.api.mixins.Inject;
|
||||||
@@ -31,6 +32,8 @@ import net.runelite.api.mixins.MethodHook;
|
|||||||
import net.runelite.api.mixins.Mixin;
|
import net.runelite.api.mixins.Mixin;
|
||||||
import net.runelite.api.mixins.Shadow;
|
import net.runelite.api.mixins.Shadow;
|
||||||
import net.runelite.rs.api.RSClient;
|
import net.runelite.rs.api.RSClient;
|
||||||
|
import net.runelite.rs.api.RSNPC;
|
||||||
|
import net.runelite.rs.api.RSPlayer;
|
||||||
import net.runelite.rs.api.RSProjectile;
|
import net.runelite.rs.api.RSProjectile;
|
||||||
|
|
||||||
@Mixin(RSProjectile.class)
|
@Mixin(RSProjectile.class)
|
||||||
@@ -48,6 +51,36 @@ public abstract class RSProjectileMixin implements RSProjectile
|
|||||||
return getEndCycle() - currentGameCycle;
|
return getEndCycle() - currentGameCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Override
|
||||||
|
public Actor getInteracting()
|
||||||
|
{
|
||||||
|
int interactingIndex = getRsInteracting();
|
||||||
|
if (interactingIndex == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interactingIndex > 0)
|
||||||
|
{
|
||||||
|
int idx = interactingIndex - 1;
|
||||||
|
RSNPC[] npcs = client.getCachedNPCs();
|
||||||
|
return npcs[idx];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int idx = -interactingIndex - 1;
|
||||||
|
|
||||||
|
if (idx == client.getLocalInteractingIndex())
|
||||||
|
{
|
||||||
|
return client.getLocalPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
RSPlayer[] players = client.getCachedPlayers();
|
||||||
|
return players[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a projectile is set to move towards a point. For
|
* Called when a projectile is set to move towards a point. For
|
||||||
* projectiles that target the ground, like AoE projectiles from
|
* projectiles that target the ground, like AoE projectiles from
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ public interface RSProjectile extends RSRenderable, Projectile
|
|||||||
@Override
|
@Override
|
||||||
int getId();
|
int getId();
|
||||||
|
|
||||||
|
@Import("interacting")
|
||||||
|
int getRsInteracting();
|
||||||
|
|
||||||
@Import("height")
|
@Import("height")
|
||||||
@Override
|
@Override
|
||||||
int getHeight();
|
int getHeight();
|
||||||
|
|||||||
Reference in New Issue
Block a user