Checkstyle fixes

This commit is contained in:
zeruth
2019-06-10 01:51:19 -04:00
parent 0b970a6a2d
commit 090c95b626
22 changed files with 667 additions and 675 deletions

View File

@@ -23,7 +23,8 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@@ -58,7 +59,7 @@
<artifactId>runescape-api</artifactId> <artifactId>runescape-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId> <artifactId>maven-plugin-api</artifactId>

View File

@@ -51,19 +51,16 @@ import net.runelite.injector.raw.RasterizerHook;
import net.runelite.injector.raw.RenderDraw; import net.runelite.injector.raw.RenderDraw;
import net.runelite.injector.raw.ScriptVM; import net.runelite.injector.raw.ScriptVM;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
import net.runelite.rs.api.RSClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import net.runelite.rs.api.RSClient;
public class Inject public class Inject
{ {
private static final Logger logger = LoggerFactory.getLogger(Inject.class);
public static final java.lang.Class<?> CLIENT_CLASS = RSClient.class; public static final java.lang.Class<?> CLIENT_CLASS = RSClient.class;
public static final String API_PACKAGE_BASE = "net.runelite.rs.api.RS"; public static final String API_PACKAGE_BASE = "net.runelite.rs.api.RS";
public static final String RL_API_PACKAGE_BASE = "net.runelite.api."; public static final String RL_API_PACKAGE_BASE = "net.runelite.api.";
private static final Logger logger = LoggerFactory.getLogger(Inject.class);
private final InjectHookMethod hookMethod = new InjectHookMethod(this); private final InjectHookMethod hookMethod = new InjectHookMethod(this);
private final InjectGetter getters = new InjectGetter(this); private final InjectGetter getters = new InjectGetter(this);
@@ -87,34 +84,6 @@ public class Inject
this.vanilla = vanilla; this.vanilla = vanilla;
} }
public Type getFieldType(Field f)
{
Type type = f.getType();
Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfSignature != null)
{
//Annotation exists. Type was updated by us during deobfuscation
type = DeobAnnotations.getObfuscatedType(f);
}
return type;
}
public Signature getMethodSignature(Method m)
{
Signature signature = m.getDescriptor();
Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfSignature != null)
{
//Annotation exists. Signature was updated by us during deobfuscation
signature = DeobAnnotations.getObfuscatedSignature(m);
}
return signature;
}
/** /**
* Convert a java.lang.Class to a Type * Convert a java.lang.Class to a Type
* *
@@ -173,6 +142,34 @@ public class Inject
return Type.getType("L" + c.getName().replace('.', '/') + ";", dimms); return Type.getType("L" + c.getName().replace('.', '/') + ";", dimms);
} }
public Type getFieldType(Field f)
{
Type type = f.getType();
Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfSignature != null)
{
//Annotation exists. Type was updated by us during deobfuscation
type = DeobAnnotations.getObfuscatedType(f);
}
return type;
}
public Signature getMethodSignature(Method m)
{
Signature signature = m.getDescriptor();
Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfSignature != null)
{
//Annotation exists. Signature was updated by us during deobfuscation
signature = DeobAnnotations.getObfuscatedSignature(m);
}
return signature;
}
/** /**
* Build a Signature from a java method * Build a Signature from a java method
* *
@@ -284,7 +281,7 @@ public class Inject
assert !f.isStatic(); assert !f.isStatic();
// non static field exported on non exported interface // non static field exported on non exported interface
// logger.debug("Non static exported field {} on non exported interface", exportedName); // logger.debug("Non static exported field {} on non exported interface", exportedName);
continue; continue;
} }
@@ -325,7 +322,7 @@ public class Inject
invokes.process(m, other, implementingClass); invokes.process(m, other, implementingClass);
} }
} }
logger.info("Injected {} getters, {} setters, {} invokers", logger.info("Injected {} getters, {} setters, {} invokers",
getters.getInjectedGetters(), getters.getInjectedGetters(),
setters.getInjectedSetters(), invokes.getInjectedInvokers()); setters.getInjectedSetters(), invokes.getInjectedInvokers());
@@ -514,10 +511,10 @@ public class Inject
} }
} }
// if (rlApiType == null) // if (rlApiType == null)
// { // {
// throw new InjectionException("RS API type " + rsApiType + " does not extend RL API interface"); // throw new InjectionException("RS API type " + rsApiType + " does not extend RL API interface");
// } // }
final java.lang.Class<?> finalType = rlApiType == null ? rsApiType : rlApiType; final java.lang.Class<?> finalType = rlApiType == null ? rsApiType : rlApiType;
@@ -539,7 +536,7 @@ public class Inject
return Type.getType("L" + type.getInternalName().substring(API_PACKAGE_BASE.length()) + ";", type.getDimensions()); return Type.getType("L" + type.getInternalName().substring(API_PACKAGE_BASE.length()) + ";", type.getDimensions());
} }
ClassFile findVanillaForInterface(java.lang.Class<?> clazz) ClassFile findVanillaForInterface(java.lang.Class<?> clazz)
{ {
String className = clazz.getName().replace('.', '/'); String className = clazz.getName().replace('.', '/');

View File

@@ -115,19 +115,19 @@ public class InjectConstruct
Signature sig = inject.javaMethodToSignature(apiMethod); Signature sig = inject.javaMethodToSignature(apiMethod);
Signature constructorSig = new Signature.Builder() Signature constructorSig = new Signature.Builder()
.addArguments(Stream.of(apiMethod.getParameterTypes()) .addArguments(Stream.of(apiMethod.getParameterTypes())
.map(arg -> .map(arg ->
{ {
ClassFile vanilla = inject.findVanillaForInterface(arg); ClassFile vanilla = inject.findVanillaForInterface(arg);
if (vanilla != null) if (vanilla != null)
{ {
return new Type("L" + vanilla.getName() + ";"); return new Type("L" + vanilla.getName() + ";");
} }
return Inject.classToType(arg); return Inject.classToType(arg);
}) })
.collect(Collectors.toList())) .collect(Collectors.toList()))
.setReturnType(Type.VOID) .setReturnType(Type.VOID)
.build(); .build();
Method vanillaConstructor = vanillaClass.findMethod("<init>", constructorSig); Method vanillaConstructor = vanillaClass.findMethod("<init>", constructorSig);
if (vanillaConstructor == null) if (vanillaConstructor == null)
{ {

View File

@@ -47,16 +47,16 @@ import org.slf4j.LoggerFactory;
public class InjectGetter public class InjectGetter
{ {
private static final Logger logger = LoggerFactory.getLogger(InjectGetter.class); private static final Logger logger = LoggerFactory.getLogger(InjectGetter.class);
private final Inject inject; private final Inject inject;
private int injectedGetters; private int injectedGetters;
public InjectGetter(Inject inject) public InjectGetter(Inject inject)
{ {
this.inject = inject; this.inject = inject;
} }
public void injectGetter(ClassFile clazz, java.lang.reflect.Method method, Field field, Number getter) public void injectGetter(ClassFile clazz, java.lang.reflect.Method method, Field field, Number getter)
{ {
// clazz = class file we're injecting the method into. // clazz = class file we're injecting the method into.

View File

@@ -58,23 +58,10 @@ import org.slf4j.LoggerFactory;
public class InjectHook public class InjectHook
{ {
private static final Logger logger = LoggerFactory.getLogger(InjectHook.class); private static final Logger logger = LoggerFactory.getLogger(InjectHook.class);
static class HookInfo
{
String fieldName;
String clazz;
Method method;
boolean before;
Number getter;
}
private static final String HOOK_METHOD_SIGNATURE = "(I)V"; private static final String HOOK_METHOD_SIGNATURE = "(I)V";
private static final String CLINIT = "<clinit>"; private static final String CLINIT = "<clinit>";
private final Inject inject; private final Inject inject;
private final Map<Field, HookInfo> hooked = new HashMap<>(); private final Map<Field, HookInfo> hooked = new HashMap<>();
private int injectedHooks; private int injectedHooks;
public InjectHook(Inject inject) public InjectHook(Inject inject)
@@ -272,7 +259,7 @@ public class InjectHook
if (hookInfo.getter instanceof Integer) if (hookInfo.getter instanceof Integer)
{ {
ins.getInstructions().add(idx++, new LDC(ins, (int) hookInfo.getter)); ins.getInstructions().add(idx++, new LDC(ins, (int) hookInfo.getter));
ins.getInstructions().add(idx++,new IMul(ins)); ins.getInstructions().add(idx++, new IMul(ins));
} }
else else
{ {
@@ -399,4 +386,13 @@ public class InjectHook
{ {
return injectedHooks; return injectedHooks;
} }
static class HookInfo
{
String fieldName;
String clazz;
Method method;
boolean before;
Number getter;
}
} }

View File

@@ -49,10 +49,8 @@ import org.slf4j.LoggerFactory;
public class InjectHookMethod public class InjectHookMethod
{ {
private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class);
public static final String HOOKS = "net/runelite/client/callback/Hooks"; public static final String HOOKS = "net/runelite/client/callback/Hooks";
private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class);
private final Inject inject; private final Inject inject;
public InjectHookMethod(Inject inject) public InjectHookMethod(Inject inject)
@@ -115,7 +113,7 @@ public class InjectHookMethod
Instructions instructions = vanillaMethod.getCode().getInstructions(); Instructions instructions = vanillaMethod.getCode().getInstructions();
Signature.Builder builder = new Signature.Builder() Signature.Builder builder = new Signature.Builder()
.setReturnType(Type.VOID); // Hooks always return void .setReturnType(Type.VOID); // Hooks always return void
for (Type type : deobMethod.getDescriptor().getArguments()) for (Type type : deobMethod.getDescriptor().getArguments())
{ {
@@ -164,11 +162,11 @@ public class InjectHookMethod
{ {
// Invoke callback // Invoke callback
invoke = new InvokeStatic(instructions, invoke = new InvokeStatic(instructions,
new net.runelite.asm.pool.Method( new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class(HOOKS), new net.runelite.asm.pool.Class(HOOKS),
hookName, hookName,
signature signature
) )
); );
} }
else else
@@ -179,11 +177,11 @@ public class InjectHookMethod
if (vanillaMethod.isStatic()) if (vanillaMethod.isStatic())
{ {
invoke = new InvokeStatic(instructions, invoke = new InvokeStatic(instructions,
new net.runelite.asm.pool.Method( new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class("client"), // Static methods are in client new net.runelite.asm.pool.Class("client"), // Static methods are in client
hookMethod.getName(), hookMethod.getName(),
signature signature
) )
); );
} }
else else
@@ -191,11 +189,11 @@ public class InjectHookMethod
// otherwise invoke member function // otherwise invoke member function
//instructions.addInstruction(insertPos++, new ALoad(instructions, 0)); //instructions.addInstruction(insertPos++, new ALoad(instructions, 0));
invoke = new InvokeVirtual(instructions, invoke = new InvokeVirtual(instructions,
new net.runelite.asm.pool.Method( new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class(vanillaMethod.getClassFile().getName()), new net.runelite.asm.pool.Class(vanillaMethod.getClassFile().getName()),
hookMethod.getName(), hookMethod.getName(),
signature signature
) )
); );
} }
} }

View File

@@ -67,11 +67,11 @@ public class InjectInvoker
/** /**
* Inject an invoker for a method * Inject an invoker for a method
* *
* @param m Method in the deobfuscated client to inject an invoker for * @param m Method in the deobfuscated client to inject an invoker for
* @param other Class in the vanilla client of the same class m is a * @param other Class in the vanilla client of the same class m is a
* member of * member of
* @param implementingClass Java class for the API interface the class * @param implementingClass Java class for the API interface the class
* will implement * will implement
*/ */
public void process(Method m, ClassFile other, java.lang.Class<?> implementingClass) public void process(Method m, ClassFile other, java.lang.Class<?> implementingClass)
{ {
@@ -108,14 +108,14 @@ public class InjectInvoker
assert !m.isStatic(); assert !m.isStatic();
// non static exported method on non exported interface, weird. // non static exported method on non exported interface, weird.
// logger.debug("Non static exported method {} on non exported interface", exportedName); // logger.debug("Non static exported method {} on non exported interface", exportedName);
return; return;
} }
java.lang.reflect.Method apiMethod = inject.findImportMethodOnApi(targetClassJava, exportedName, null); // api method to invoke 'otherm' java.lang.reflect.Method apiMethod = inject.findImportMethodOnApi(targetClassJava, exportedName, null); // api method to invoke 'otherm'
if (apiMethod == null) if (apiMethod == null)
{ {
// logger.debug("Unable to find api method on {} with imported name {}, not injecting invoker", targetClassJava, exportedName); // logger.debug("Unable to find api method on {} with imported name {}, not injecting invoker", targetClassJava, exportedName);
return; return;
} }

View File

@@ -45,17 +45,14 @@ import org.apache.maven.plugins.annotations.Parameter;
) )
public class InjectMojo extends AbstractMojo public class InjectMojo extends AbstractMojo
{ {
private final Log log = getLog();
@Parameter(defaultValue = "${project.build.outputDirectory}") @Parameter(defaultValue = "${project.build.outputDirectory}")
private File outputDirectory; private File outputDirectory;
@Parameter(defaultValue = "./runescape-client/target/rs-client-${project.version}.jar", readonly = true, required = true) @Parameter(defaultValue = "./runescape-client/target/rs-client-${project.version}.jar", readonly = true, required = true)
private String rsClientPath; private String rsClientPath;
@Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true) @Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true)
private String vanillaPath; private String vanillaPath;
private final Log log = getLog();
@Override @Override
public void execute() throws MojoExecutionException, MojoFailureException public void execute() throws MojoExecutionException, MojoFailureException
{ {

View File

@@ -50,7 +50,7 @@ public class InjectSetter
private static final Logger logger = LoggerFactory.getLogger(InjectSetter.class); private static final Logger logger = LoggerFactory.getLogger(InjectSetter.class);
private final Inject inject; private final Inject inject;
private int injectedSetters; private int injectedSetters;
public InjectSetter(Inject inject) public InjectSetter(Inject inject)
@@ -61,12 +61,12 @@ public class InjectSetter
/** /**
* inject a setter into the vanilla classgroup * inject a setter into the vanilla classgroup
* *
* @param targetClass Class where to inject the setter (field's class, * @param targetClass Class where to inject the setter (field's class,
* or client) * or client)
* @param targetApiClass API targetClass implements, which may have the * @param targetApiClass API targetClass implements, which may have the
* setter declared * setter declared
* @param field Field of vanilla that will be set * @param field Field of vanilla that will be set
* @param exportedName exported name of field * @param exportedName exported name of field
* @param setter * @param setter
*/ */
public void injectSetter(ClassFile targetClass, Class<?> targetApiClass, Field field, String exportedName, Number setter) public void injectSetter(ClassFile targetClass, Class<?> targetApiClass, Field field, String exportedName, Number setter)
@@ -114,7 +114,7 @@ public class InjectSetter
// load argument // load argument
Type argumentType = sig.getTypeOfArg(0); Type argumentType = sig.getTypeOfArg(0);
ins.add(inject.createLoadForTypeIndex(instructions, argumentType, 1)); ins.add(inject.createLoadForTypeIndex(instructions, argumentType, 1));
// cast argument to field type // cast argument to field type
Type fieldType = field.getType(); Type fieldType = field.getType();
if (!argumentType.equals(fieldType)) if (!argumentType.equals(fieldType))

View File

@@ -39,17 +39,6 @@ public class Injector
this.vanilla = vanilla; this.vanilla = vanilla;
} }
public void inject() throws InjectionException
{
Inject instance = new Inject(deobfuscated, vanilla);
instance.run();
}
public void save(File out) throws IOException
{
JarUtil.saveJar(vanilla, out);
}
public static void main(String[] args) throws IOException, InjectionException public static void main(String[] args) throws IOException, InjectionException
{ {
if (args.length < 3) if (args.length < 3)
@@ -72,5 +61,16 @@ public class Injector
u.save(new File(args[2])); u.save(new File(args[2]));
} }
public void inject() throws InjectionException
{
Inject instance = new Inject(deobfuscated, vanilla);
instance.run();
}
public void save(File out) throws IOException
{
JarUtil.saveJar(vanilla, out);
}
} }

View File

@@ -404,7 +404,7 @@ public class MixinInjector
care of the garbage parameter itself. care of the garbage parameter itself.
*/ */
boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size() boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size()
&& deobMethod.getDescriptor().size() < obMethodSignature.size(); && deobMethod.getDescriptor().size() < obMethodSignature.size();
copiedMethods.put(method.getPoolMethod(), new CopiedMethod(copy, hasGarbageValue)); copiedMethods.put(method.getPoolMethod(), new CopiedMethod(copy, hasGarbageValue));
logger.debug("Injected copy of {} to {}", obMethod, copy); logger.debug("Injected copy of {} to {}", obMethod, copy);
@@ -577,7 +577,7 @@ public class MixinInjector
if (!returnType.equals(deobReturnType)) if (!returnType.equals(deobReturnType))
{ {
ClassFile deobReturnTypeClassFile = inject.getDeobfuscated() ClassFile deobReturnTypeClassFile = inject.getDeobfuscated()
.findClass(deobReturnType.getInternalName()); .findClass(deobReturnType.getInternalName());
if (deobReturnTypeClassFile != null) if (deobReturnTypeClassFile != null)
{ {
ClassFile obReturnTypeClass = inject.toObClass(deobReturnTypeClassFile); ClassFile obReturnTypeClass = inject.toObClass(deobReturnTypeClassFile);
@@ -601,13 +601,13 @@ public class MixinInjector
moveCode(obMethod, method.getCode()); moveCode(obMethod, method.getCode());
boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size() boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size()
&& deobMethod.getDescriptor().size() < obMethodSignature.size(); && deobMethod.getDescriptor().size() < obMethodSignature.size();
if (hasGarbageValue) if (hasGarbageValue)
{ {
int garbageIndex = obMethod.isStatic() int garbageIndex = obMethod.isStatic()
? obMethod.getDescriptor().size() - 1 ? obMethod.getDescriptor().size() - 1
: obMethod.getDescriptor().size(); : obMethod.getDescriptor().size();
/* /*
If the mixin method doesn't have the garbage parameter, If the mixin method doesn't have the garbage parameter,
@@ -645,8 +645,8 @@ public class MixinInjector
} }
private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method, private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method,
Map<net.runelite.asm.pool.Field, Field> shadowFields, Map<net.runelite.asm.pool.Field, Field> shadowFields,
Map<net.runelite.asm.pool.Method, CopiedMethod> copiedMethods) Map<net.runelite.asm.pool.Method, CopiedMethod> copiedMethods)
throws InjectionException throws InjectionException
{ {
ListIterator<Instruction> iterator = method.getCode().getInstructions().getInstructions().listIterator(); ListIterator<Instruction> iterator = method.getCode().getInstructions().getInstructions().listIterator();

View File

@@ -79,7 +79,7 @@ public class ClearColorBuffer
if (current instanceof LDC && ((LDC) current).getConstantAsInt() == 0) if (current instanceof LDC && ((LDC) current).getConstantAsInt() == 0)
{ {
int varIdx = 0; int varIdx = 0;
for (; ;) for (; ; )
{ {
current = it.previous(); current = it.previous();
if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx) if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx)

View File

@@ -166,7 +166,7 @@ public class DrawAfterWidgets
{ {
// If we get here, we're either in the wrong method // If we get here, we're either in the wrong method
// or Jagex has removed the "if (535573958 * kl != -1)" // or Jagex has removed the "if (535573958 * kl != -1)"
// logger.debug("Could not find the label for jumping to the " + noClip + " call in " + m); // logger.debug("Could not find the label for jumping to the " + noClip + " call in " + m);
continue; continue;
} }

View File

@@ -35,11 +35,6 @@ import static org.mockito.Mockito.when;
public class InjectConstructTest public class InjectConstructTest
{ {
interface APIClass
{
APIClass create();
}
@Test @Test
public void testInjectConstruct() throws Exception public void testInjectConstruct() throws Exception
{ {
@@ -60,4 +55,9 @@ public class InjectConstructTest
assertNotNull(targetClass.findMethod("create")); assertNotNull(targetClass.findMethod("create"));
} }
interface APIClass
{
APIClass create();
}
} }

View File

@@ -44,13 +44,6 @@ import static org.mockito.Mockito.when;
public class InjectSetterTest public class InjectSetterTest
{ {
interface APIClass
{
void setTest(int i);
void setTestObject(Object str);
}
@Test @Test
public void testInjectSetterInt() throws NoSuchMethodException public void testInjectSetterInt() throws NoSuchMethodException
{ {
@@ -113,4 +106,11 @@ public class InjectSetterTest
.isPresent()); .isPresent());
} }
interface APIClass
{
void setTest(int i);
void setTestObject(Object str);
}
} }

View File

@@ -53,6 +53,9 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC;
@ObfuscatedName("net/runelite/injector/VanillaTarget") @ObfuscatedName("net/runelite/injector/VanillaTarget")
class DeobTarget class DeobTarget
{ {
@ObfuscatedName("ob_foo4")
private static int foo4;
@ObfuscatedName("ob_foo3") @ObfuscatedName("ob_foo3")
@ObfuscatedSignature( @ObfuscatedSignature(
signature = "(I)V", signature = "(I)V",
@@ -63,13 +66,12 @@ class DeobTarget
// De-obfuscated foo3 // De-obfuscated foo3
System.out.println("foo3"); System.out.println("foo3");
} }
@ObfuscatedName("ob_foo4")
private static int foo4;
} }
class VanillaTarget class VanillaTarget
{ {
private static int ob_foo4;
private void ob_foo3(int garbageValue) private void ob_foo3(int garbageValue)
{ {
// Obfuscated foo3 // Obfuscated foo3
@@ -79,14 +81,14 @@ class VanillaTarget
} }
System.out.println("foo3"); System.out.println("foo3");
} }
private static int ob_foo4;
} }
abstract class Source abstract class Source
{ {
@net.runelite.api.mixins.Inject @net.runelite.api.mixins.Inject
private static int foo; private static int foo;
@Shadow("foo4")
private static int foo4;
@net.runelite.api.mixins.Inject @net.runelite.api.mixins.Inject
private void foo2() private void foo2()
@@ -103,9 +105,6 @@ abstract class Source
System.out.println(foo4); System.out.println(foo4);
foo3(); foo3();
} }
@Shadow("foo4")
private static int foo4;
} }
// Test shadowing the "foo" field injected by Source // Test shadowing the "foo" field injected by Source

View File

@@ -1,10 +1,9 @@
package net.runelite.client.util.bootstrap; package net.runelite.client.util.bootstrap;
public class Artifact { public class Artifact
{
String hash; String hash;
String name; String name;
String path; String path;
String size; String size;
} }

View File

@@ -1,328 +1,345 @@
package net.runelite.client.util.bootstrap; package net.runelite.client.util.bootstrap;
import net.runelite.http.api.RuneLiteAPI;
import sun.misc.BASE64Encoder;
import javax.xml.bind.DatatypeConverter;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.DigestInputStream; import java.security.DigestInputStream;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import javax.xml.bind.DatatypeConverter;
import net.runelite.http.api.RuneLiteAPI;
public class Bootstrap { public class Bootstrap
{
Artifact[] artifacts = getArtifacts();
Client client = new Client();
String[] clientJvm9Arguments = new String[]{
"-XX:+DisableAttachMechanism",
"-Xmx512m",
"-Xss2m",
"-XX:CompileThreshold=1500",
"-Djna.nosys=true"
};
String[] clientJvmArguments = new String[]{
"-XX:+DisableAttachMechanism",
"-Xmx512m",
"-Xss2m",
"-XX:CompileThreshold=1500",
"-Xincgc",
"-XX:+UseConcMarkSweepGC",
"-XX:+UseParNewGC",
"-Djna.nosys=true"};
String[] dependencyHashes;
String[] launcherArguments = new String[]{
"-XX:+DisableAttachMechanism",
"-Drunelite.launcher.nojvm=true",
"-Xmx512m",
"-Xss2m",
"-XX:CompileThreshold=1500",
"-Xincgc",
"-XX:+UseConcMarkSweepGC",
"-XX:+UseParNewGC",
"-Djna.nosys=true"};
Artifact[] artifacts = getArtifacts(); public Bootstrap()
Client client = new Client(); {
String[] clientJvm9Arguments = new String[]{ }
"-XX:+DisableAttachMechanism",
"-Xmx512m",
"-Xss2m",
"-XX:CompileThreshold=1500",
"-Djna.nosys=true"
};
String[] clientJvmArguments = new String[]{
"-XX:+DisableAttachMechanism",
"-Xmx512m",
"-Xss2m",
"-XX:CompileThreshold=1500",
"-Xincgc",
"-XX:+UseConcMarkSweepGC",
"-XX:+UseParNewGC",
"-Djna.nosys=true"};
String[] dependencyHashes;
String[] launcherArguments = new String[]{
"-XX:+DisableAttachMechanism",
"-Drunelite.launcher.nojvm=true",
"-Xmx512m",
"-Xss2m",
"-XX:CompileThreshold=1500",
"-Xincgc",
"-XX:+UseConcMarkSweepGC",
"-XX:+UseParNewGC",
"-Djna.nosys=true"};
public Bootstrap(){} public static String getChecksumObject(Serializable object) throws IOException, NoSuchAlgorithmException
{
ByteArrayOutputStream baos = null;
ObjectOutputStream oos = null;
try
{
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(object);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(baos.toByteArray());
return DatatypeConverter.printHexBinary(thedigest);
}
finally
{
oos.close();
baos.close();
}
}
public Artifact[] getArtifacts() { private static String getChecksumFile(String filepath) throws IOException
try { {
artifacts = new Artifact[42]; System.out.println("Generating Hash for " + filepath);
MessageDigest md = null;
try
{
md = MessageDigest.getInstance("SHA-256");
}
catch (Exception e)
{
e.printStackTrace();
}
try (DigestInputStream dis = new DigestInputStream(new FileInputStream(filepath), md))
{
while (dis.read() != -1)
{
//empty loop to clear the data
}
md = dis.getMessageDigest();
}
catch (Exception e)
{
e.printStackTrace();
}
//Static artifacts return bytesToHex(md.digest());
artifacts[0] = new Artifact();
artifacts[0].hash = "b12331da8683e5f107d294adeebb83ecf9124abc1db533554d2a8d3c62832d75";
artifacts[0].name = "asm-all-6.0_BETA.jar";
artifacts[0].path = "https://mvn.runelite.net/org/ow2/asm/asm-all/6.0_BETA/asm-all-6.0_BETA.jar";
artifacts[0].size = "265176";
artifacts[1] = new Artifact();
artifacts[1].hash = "37abf0103ce5318bfda004fabc004c75ed0dc6d392a8459175692ab7eac97083";
artifacts[1].name = "naturalmouse-2.0.0.jar";
artifacts[1].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/naturalmouse-2.0.0.jar";
artifacts[1].size = "3168921";
artifacts[2] = new Artifact();
artifacts[2].hash = "50d1e07f11827672249dee9ce8a23691fc59f663deed084bb7b52a4f778d5fbc";
artifacts[2].name = "jcl-core-2.9-SNAPSHOT.jar";
artifacts[2].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/jcl-core-2.9-SNAPSHOT.jar";
artifacts[2].size = "3168921";
artifacts[4] = new Artifact();
artifacts[4].hash = "18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79";
artifacts[4].name = "slf4j-api-1.7.25.jar";
artifacts[4].path = "https://mvn.runelite.net/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar";
artifacts[4].size = "41203";
artifacts[5] = new Artifact();
artifacts[5].hash = "fb53f8539e7fcb8f093a56e138112056ec1dc809ebb020b59d8a36a5ebac37e0";
artifacts[5].name = "logback-classic-1.2.3.jar";
artifacts[5].path = "https://mvn.runelite.net/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar";
artifacts[5].size = "290339";
artifacts[6] = new Artifact();
artifacts[6].hash = "5946d837fe6f960c02a53eda7a6926ecc3c758bbdd69aa453ee429f858217f22";
artifacts[6].name = "logback-core-1.2.3.jar";
artifacts[6].path = "https://mvn.runelite.net/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar";
artifacts[6].size = "471901";
artifacts[7] = new Artifact();
artifacts[7].hash = "9f0c8d50fa4b79b6ff1502dbec8502179d6b9497cacbe17a13074001aed537ec";
artifacts[7].name = "jopt-simple-5.0.1.jar";
artifacts[7].path = "https://mvn.runelite.net/net/sf/jopt-simple/jopt-simple/5.0.1/jopt-simple-5.0.1.jar";
artifacts[7].size = "78826";
artifacts[8] = new Artifact();
artifacts[8].hash = "5be9a7d05ba0ccd74708bc8018ae412255f85843c0b92302e9b9befa6ed52564";
artifacts[8].name = "guava-23.2-jre.jar";
artifacts[8].path = "https://mvn.runelite.net/com/google/guava/guava/23.2-jre/guava-23.2-jre.jar";
artifacts[8].size = "2649860";
artifacts[9] = new Artifact();
artifacts[9].hash = "905721a0eea90a81534abb7ee6ef4ea2e5e645fa1def0a5cd88402df1b46c9ed";
artifacts[9].name = "jsr305-1.3.9.jar";
artifacts[9].path = "https://mvn.runelite.net/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar";
artifacts[9].size = "33015";
artifacts[10] = new Artifact();
artifacts[10].hash = "cb4cfad870bf563a07199f3ebea5763f0dec440fcda0b318640b1feaa788656b";
artifacts[10].name = "error_prone_annotations-2.0.18.jar";
artifacts[10].path = "https://mvn.runelite.net/com/google/errorprone/error_prone_annotations/2.0.18/error_prone_annotations-2.0.18.jar";
artifacts[10].size = "12078";
artifacts[11] = new Artifact();
artifacts[11].hash = "2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6";
artifacts[11].name = "j2objc-annotations-1.1.jar";
artifacts[11].path = "https://mvn.runelite.net/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar";
artifacts[11].size = "8782";
artifacts[12] = new Artifact();
artifacts[12].hash = "2068320bd6bad744c3673ab048f67e30bef8f518996fa380033556600669905d";
artifacts[12].name = "animal-sniffer-annotations-1.14.jar";
artifacts[12].path = "https://mvn.runelite.net/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar";
artifacts[12].size = "3482";
artifacts[13] = new Artifact();
artifacts[13].hash = "9264c6931c431e928dc64adc842584d5f57d17b2f3aff29221f2b3fdea673dad";
artifacts[13].name = "guice-4.1.0-no_aop.jar";
artifacts[13].path = "https://mvn.runelite.net/com/google/inject/guice/4.1.0/guice-4.1.0-no_aop.jar";
artifacts[13].size = "428603";
artifacts[14] = new Artifact();
artifacts[14].hash = "91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff";
artifacts[14].name = "javax.inject-1.jar";
artifacts[14].path = "https://mvn.runelite.net/javax/inject/javax.inject/1/javax.inject-1.jar";
artifacts[14].size = "2497";
artifacts[15] = new Artifact();
artifacts[15].hash = "0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08";
artifacts[15].name = "aopalliance-1.0.jar";
artifacts[15].path = "https://mvn.runelite.net/aopalliance/aopalliance/1.0/aopalliance-1.0.jar";
artifacts[15].size = "4467";
artifacts[16] = new Artifact();
artifacts[16].hash = "233a0149fc365c9f6edbd683cfe266b19bdc773be98eabdaf6b3c924b48e7d81";
artifacts[16].name = "gson-2.8.5.jar";
artifacts[16].path = "https://mvn.runelite.net/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar";
artifacts[16].size = "241622";
artifacts[17] = new Artifact();
artifacts[17].hash = "0467d25f408428824d5c9c09ec60ee1f0bc341d9bf48971a77fd14939a826c83";
artifacts[17].name = "substance-8.0.02.jar";
artifacts[17].path = "https://repo.runelite.net/net/runelite/pushingpixels/substance/8.0.02/substance-8.0.02.jar";
artifacts[17].size = "1589195";
artifacts[18] = new Artifact();
artifacts[18].hash = "3214e1c23d549d5d67c91da4da1ef33c5248470bb824f91cbe8f9e0beea59eef";
artifacts[18].name = "trident-1.5.00.jar";
artifacts[18].path = "https://repo.runelite.net/net/runelite/pushingpixels/trident/1.5.00/trident-1.5.00.jar";
artifacts[18].size = "79726";
artifacts[19] = new Artifact();
artifacts[19].hash = "d4a57bbc1627da7c391308fd0fe910b83170fb66afd117236a5b111d2db1590b";
artifacts[19].name = "commons-text-1.2.jar";
artifacts[19].path = "https://mvn.runelite.net/org/apache/commons/commons-text/1.2/commons-text-1.2.jar";
artifacts[19].size = "136544";
artifacts[20] = new Artifact();
artifacts[20].hash = "6e8dc31e046508d9953c96534edf0c2e0bfe6f468966b5b842b3f87e43b6a847";
artifacts[20].name = "commons-lang3-3.7.jar";
artifacts[20].path = "https://mvn.runelite.net/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar";
artifacts[20].size = "499634";
artifacts[21] = new Artifact();
artifacts[21].hash = "e74603dc77b4183f108480279dbbf7fed3ac206069478636406c1fb45e83b31a";
artifacts[21].name = "jogl-all-2.3.2.jar";
artifacts[21].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2.jar";
artifacts[21].size = "3414448";
artifacts[22] = new Artifact();
artifacts[22].hash = "8c53b1884cef19309d34fd10a94b010136d9d6de9a88c386f46006fb47acab5d";
artifacts[22].name = "jogl-all-2.3.2-natives-windows-amd64.jar";
artifacts[22].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-amd64.jar";
artifacts[22].size = "240721";
artifacts[23] = new Artifact();
artifacts[23].hash = "507a0e6bd1ee4e81c3dfb287783af93775864eec742988d4162f98ce0cbac9d6";
artifacts[23].name = "jogl-all-2.3.2-natives-windows-i586.jar";
artifacts[23].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-i586.jar";
artifacts[23].size = "209445";
artifacts[24] = new Artifact();
artifacts[24].hash = "82637302ae9effdf7d6f302e1050ad6aee3b13019914ddda5b502b9faa980216";
artifacts[24].name = "jogl-all-2.3.2-natives-linux-amd64.jar";
artifacts[24].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-amd64.jar";
artifacts[24].size = "224010";
artifacts[25] = new Artifact();
artifacts[25].hash = "f474ef2ef01be24ec811d3858b0f4bc5659076975f4a58ddd79abd787e9305c7";
artifacts[25].name = "jogl-all-2.3.2-natives-linux-i586.jar";
artifacts[25].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-i586.jar";
artifacts[25].size = "217274";
artifacts[26] = new Artifact();
artifacts[26].hash = "084844543b18f7ff71b4c0437852bd22f0cb68d7e44c2c611c1bbea76f8c6fdf";
artifacts[26].name = "gluegen-rt-2.3.2.jar";
artifacts[26].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2.jar";
artifacts[26].size = "345605";
artifacts[27] = new Artifact();
artifacts[27].hash = "3474017422eff384db466bdb56c96c61220c43133a9da6329cf1781bea16c6b6";
artifacts[27].name = "gluegen-rt-2.3.2-natives-windows-amd64.jar";
artifacts[27].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-amd64.jar";
artifacts[27].size = "8159";
artifacts[28] = new Artifact();
artifacts[28].hash = "4eeed9fc2ebea5b9dc48a342b9478d127e989a2e1aa7129b512a98ec75cde338";
artifacts[28].name = "gluegen-rt-2.3.2-natives-windows-i586.jar";
artifacts[28].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-i586.jar";
artifacts[28].size = "7577";
artifacts[29] = new Artifact();
artifacts[29].hash = "f2dfd1800202059cf7e0294db5d57755147304e6eb220a9277526dbe6842bde2";
artifacts[29].name = "gluegen-rt-2.3.2-natives-linux-amd64.jar";
artifacts[29].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-amd64.jar";
artifacts[29].size = "4149";
artifacts[30] = new Artifact();
artifacts[30].hash = "1365d463f98c0abec92f3ad6b35aa4b53a9599a517800cf99fdabea6712ca7ec";
artifacts[30].name = "gluegen-rt-2.3.2-natives-linux-i586.jar";
artifacts[30].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-i586.jar";
artifacts[30].size = "4130";
artifacts[31] = new Artifact();
artifacts[31].hash = "7b7ae00e2aa98c3b2b5ac76e793e2c9b752bf51c86c54654dbd473843a25f1aa";
artifacts[31].name = "jbsdiff-1.0.jar";
artifacts[31].path = "https://mvn.runelite.net/io/sigpipe/jbsdiff/1.0/jbsdiff-1.0.jar";
artifacts[31].size = "24589";
artifacts[32] = new Artifact();
artifacts[32].hash = "55bbfe26cee9296fd5b7c0d47ce6a00ea4dd572e235b63e9bb4eaf6f802315e4";
artifacts[32].name = "commons-compress-1.5.jar";
artifacts[32].path = "https://mvn.runelite.net/org/apache/commons/commons-compress/1.5/commons-compress-1.5.jar";
artifacts[32].size = "256241";
artifacts[33] = new Artifact();
artifacts[33].hash = "fbc9de96a0cc193a125b4008dbc348e9ed54e5e13fc67b8ed40e645d303cc51b";
artifacts[33].name = "jna-4.5.1.jar";
artifacts[33].path = "https://mvn.runelite.net/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar";
artifacts[33].size = "1440662";
artifacts[34] = new Artifact();
artifacts[34].hash = "84c8667555ee8dd91fef44b451419f6f16f71f727d5fc475a10c2663eba83abb";
artifacts[34].name = "jna-platform-4.5.1.jar";
artifacts[34].path = "https://mvn.runelite.net/net/java/dev/jna/jna-platform/4.5.1/jna-platform-4.5.1.jar";
artifacts[34].size = "2327547";
artifacts[38] = new Artifact();
artifacts[38].hash = "f55abda036da75e1af45bd43b9dfa79b2a3d90905be9cb38687c6621597a8165";
artifacts[38].name = "okhttp-3.7.0.jar";
artifacts[38].path = "https://mvn.runelite.net/com/squareup/okhttp3/okhttp/3.7.0/okhttp-3.7.0.jar";
artifacts[38].size = "394987";
artifacts[39] = new Artifact();
artifacts[39].hash = "bfe7dfe483c37137966a1690f0c7d0b448ba217902c1fed202aaffdbba3291ae";
artifacts[39].name = "okio-1.12.0.jar";
artifacts[39].path = "https://mvn.runelite.net/com/squareup/okio/okio/1.12.0/okio-1.12.0.jar";
artifacts[39].size = "81088";
artifacts[40] = new Artifact();
artifacts[40].hash = "9d4924588d6280c7516db3a4b7298306db5b6f0d1cdf568ce738309b5660f008";
artifacts[40].name = "commons-csv-1.4.jar";
artifacts[40].path = "https://mvn.runelite.net/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar";
artifacts[40].size = "39978";
artifacts[41] = new Artifact();
artifacts[41].hash = "7e26a8d043418f2f22d5f6a3083a9a131817009ee8cd72c004e83b50d1849a7c";
artifacts[41].name = "discord-1.1.jar";
artifacts[41].path = "https://repo.runelite.net/net/runelite/discord/1.1/discord-1.1.jar";
artifacts[41].size = "617294";
//Dynamic artifacts }
artifacts[3] = new Artifact();
artifacts[3].name = "client-"+ RuneLiteAPI.getVersion()+".jar";
artifacts[3].hash = getChecksumFile("./runelite-client/target/"+artifacts[3].name);
artifacts[3].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[3].name;
artifacts[3].size = Long.toString(getFileSize("./runelite-client/target/"+artifacts[3].name));
artifacts[35] = new Artifact();
artifacts[35].name = "runelite-api-"+ RuneLiteAPI.getVersion()+".jar";
artifacts[35].hash = getChecksumFile("./runelite-api/target/"+artifacts[35].name);
artifacts[35].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[35].name;
artifacts[35].size = Long.toString(getFileSize("./runelite-api/target/"+artifacts[35].name));
artifacts[36] = new Artifact();
artifacts[36].name = "runescape-api-"+ RuneLiteAPI.getVersion()+".jar";
artifacts[36].hash = getChecksumFile("./runescape-api/target/"+artifacts[36].name);
artifacts[36].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[36].name;
artifacts[36].size = Long.toString(getFileSize("./runescape-api/target/"+artifacts[36].name));
artifacts[37] = new Artifact();
artifacts[37].name = "http-api-"+ RuneLiteAPI.getVersion()+".jar";
artifacts[37].hash = getChecksumFile("./http-api/target/"+artifacts[37].name);
artifacts[37].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[37].name;
artifacts[37].size = Long.toString(getFileSize("./http-api/target/"+artifacts[37].name));
} catch (IOException e) {
e.printStackTrace();
}
return artifacts;
}
private static String bytesToHex(byte[] hashInBytes)
{
StringBuilder sb = new StringBuilder();
for (byte b : hashInBytes)
{
sb.append(String.format("%02x", b));
}
return sb.toString();
public static String getChecksumObject(Serializable object) throws IOException, NoSuchAlgorithmException { }
ByteArrayOutputStream baos = null;
ObjectOutputStream oos = null;
try {
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(object);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(baos.toByteArray());
return DatatypeConverter.printHexBinary(thedigest);
} finally {
oos.close();
baos.close();
}
}
private static String getChecksumFile(String filepath) throws IOException {
System.out.println("Generating Hash for "+filepath);
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (Exception e) {
e.printStackTrace();
}
try (DigestInputStream dis = new DigestInputStream(new FileInputStream(filepath), md)) {
while (dis.read() != -1) ; //empty loop to clear the data
md = dis.getMessageDigest();
} catch (Exception e) {
e.printStackTrace();
}
return bytesToHex(md.digest()); public Artifact[] getArtifacts()
{
try
{
artifacts = new Artifact[42];
} //Static artifacts
artifacts[0] = new Artifact();
artifacts[0].hash = "b12331da8683e5f107d294adeebb83ecf9124abc1db533554d2a8d3c62832d75";
artifacts[0].name = "asm-all-6.0_BETA.jar";
artifacts[0].path = "https://mvn.runelite.net/org/ow2/asm/asm-all/6.0_BETA/asm-all-6.0_BETA.jar";
artifacts[0].size = "265176";
artifacts[1] = new Artifact();
artifacts[1].hash = "37abf0103ce5318bfda004fabc004c75ed0dc6d392a8459175692ab7eac97083";
artifacts[1].name = "naturalmouse-2.0.0.jar";
artifacts[1].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/naturalmouse-2.0.0.jar";
artifacts[1].size = "3168921";
artifacts[2] = new Artifact();
artifacts[2].hash = "50d1e07f11827672249dee9ce8a23691fc59f663deed084bb7b52a4f778d5fbc";
artifacts[2].name = "jcl-core-2.9-SNAPSHOT.jar";
artifacts[2].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/jcl-core-2.9-SNAPSHOT.jar";
artifacts[2].size = "3168921";
artifacts[4] = new Artifact();
artifacts[4].hash = "18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79";
artifacts[4].name = "slf4j-api-1.7.25.jar";
artifacts[4].path = "https://mvn.runelite.net/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar";
artifacts[4].size = "41203";
artifacts[5] = new Artifact();
artifacts[5].hash = "fb53f8539e7fcb8f093a56e138112056ec1dc809ebb020b59d8a36a5ebac37e0";
artifacts[5].name = "logback-classic-1.2.3.jar";
artifacts[5].path = "https://mvn.runelite.net/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar";
artifacts[5].size = "290339";
artifacts[6] = new Artifact();
artifacts[6].hash = "5946d837fe6f960c02a53eda7a6926ecc3c758bbdd69aa453ee429f858217f22";
artifacts[6].name = "logback-core-1.2.3.jar";
artifacts[6].path = "https://mvn.runelite.net/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar";
artifacts[6].size = "471901";
artifacts[7] = new Artifact();
artifacts[7].hash = "9f0c8d50fa4b79b6ff1502dbec8502179d6b9497cacbe17a13074001aed537ec";
artifacts[7].name = "jopt-simple-5.0.1.jar";
artifacts[7].path = "https://mvn.runelite.net/net/sf/jopt-simple/jopt-simple/5.0.1/jopt-simple-5.0.1.jar";
artifacts[7].size = "78826";
artifacts[8] = new Artifact();
artifacts[8].hash = "5be9a7d05ba0ccd74708bc8018ae412255f85843c0b92302e9b9befa6ed52564";
artifacts[8].name = "guava-23.2-jre.jar";
artifacts[8].path = "https://mvn.runelite.net/com/google/guava/guava/23.2-jre/guava-23.2-jre.jar";
artifacts[8].size = "2649860";
artifacts[9] = new Artifact();
artifacts[9].hash = "905721a0eea90a81534abb7ee6ef4ea2e5e645fa1def0a5cd88402df1b46c9ed";
artifacts[9].name = "jsr305-1.3.9.jar";
artifacts[9].path = "https://mvn.runelite.net/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar";
artifacts[9].size = "33015";
artifacts[10] = new Artifact();
artifacts[10].hash = "cb4cfad870bf563a07199f3ebea5763f0dec440fcda0b318640b1feaa788656b";
artifacts[10].name = "error_prone_annotations-2.0.18.jar";
artifacts[10].path = "https://mvn.runelite.net/com/google/errorprone/error_prone_annotations/2.0.18/error_prone_annotations-2.0.18.jar";
artifacts[10].size = "12078";
artifacts[11] = new Artifact();
artifacts[11].hash = "2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6";
artifacts[11].name = "j2objc-annotations-1.1.jar";
artifacts[11].path = "https://mvn.runelite.net/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar";
artifacts[11].size = "8782";
artifacts[12] = new Artifact();
artifacts[12].hash = "2068320bd6bad744c3673ab048f67e30bef8f518996fa380033556600669905d";
artifacts[12].name = "animal-sniffer-annotations-1.14.jar";
artifacts[12].path = "https://mvn.runelite.net/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar";
artifacts[12].size = "3482";
artifacts[13] = new Artifact();
artifacts[13].hash = "9264c6931c431e928dc64adc842584d5f57d17b2f3aff29221f2b3fdea673dad";
artifacts[13].name = "guice-4.1.0-no_aop.jar";
artifacts[13].path = "https://mvn.runelite.net/com/google/inject/guice/4.1.0/guice-4.1.0-no_aop.jar";
artifacts[13].size = "428603";
artifacts[14] = new Artifact();
artifacts[14].hash = "91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff";
artifacts[14].name = "javax.inject-1.jar";
artifacts[14].path = "https://mvn.runelite.net/javax/inject/javax.inject/1/javax.inject-1.jar";
artifacts[14].size = "2497";
artifacts[15] = new Artifact();
artifacts[15].hash = "0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08";
artifacts[15].name = "aopalliance-1.0.jar";
artifacts[15].path = "https://mvn.runelite.net/aopalliance/aopalliance/1.0/aopalliance-1.0.jar";
artifacts[15].size = "4467";
artifacts[16] = new Artifact();
artifacts[16].hash = "233a0149fc365c9f6edbd683cfe266b19bdc773be98eabdaf6b3c924b48e7d81";
artifacts[16].name = "gson-2.8.5.jar";
artifacts[16].path = "https://mvn.runelite.net/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar";
artifacts[16].size = "241622";
artifacts[17] = new Artifact();
artifacts[17].hash = "0467d25f408428824d5c9c09ec60ee1f0bc341d9bf48971a77fd14939a826c83";
artifacts[17].name = "substance-8.0.02.jar";
artifacts[17].path = "https://repo.runelite.net/net/runelite/pushingpixels/substance/8.0.02/substance-8.0.02.jar";
artifacts[17].size = "1589195";
artifacts[18] = new Artifact();
artifacts[18].hash = "3214e1c23d549d5d67c91da4da1ef33c5248470bb824f91cbe8f9e0beea59eef";
artifacts[18].name = "trident-1.5.00.jar";
artifacts[18].path = "https://repo.runelite.net/net/runelite/pushingpixels/trident/1.5.00/trident-1.5.00.jar";
artifacts[18].size = "79726";
artifacts[19] = new Artifact();
artifacts[19].hash = "d4a57bbc1627da7c391308fd0fe910b83170fb66afd117236a5b111d2db1590b";
artifacts[19].name = "commons-text-1.2.jar";
artifacts[19].path = "https://mvn.runelite.net/org/apache/commons/commons-text/1.2/commons-text-1.2.jar";
artifacts[19].size = "136544";
artifacts[20] = new Artifact();
artifacts[20].hash = "6e8dc31e046508d9953c96534edf0c2e0bfe6f468966b5b842b3f87e43b6a847";
artifacts[20].name = "commons-lang3-3.7.jar";
artifacts[20].path = "https://mvn.runelite.net/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar";
artifacts[20].size = "499634";
artifacts[21] = new Artifact();
artifacts[21].hash = "e74603dc77b4183f108480279dbbf7fed3ac206069478636406c1fb45e83b31a";
artifacts[21].name = "jogl-all-2.3.2.jar";
artifacts[21].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2.jar";
artifacts[21].size = "3414448";
artifacts[22] = new Artifact();
artifacts[22].hash = "8c53b1884cef19309d34fd10a94b010136d9d6de9a88c386f46006fb47acab5d";
artifacts[22].name = "jogl-all-2.3.2-natives-windows-amd64.jar";
artifacts[22].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-amd64.jar";
artifacts[22].size = "240721";
artifacts[23] = new Artifact();
artifacts[23].hash = "507a0e6bd1ee4e81c3dfb287783af93775864eec742988d4162f98ce0cbac9d6";
artifacts[23].name = "jogl-all-2.3.2-natives-windows-i586.jar";
artifacts[23].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-i586.jar";
artifacts[23].size = "209445";
artifacts[24] = new Artifact();
artifacts[24].hash = "82637302ae9effdf7d6f302e1050ad6aee3b13019914ddda5b502b9faa980216";
artifacts[24].name = "jogl-all-2.3.2-natives-linux-amd64.jar";
artifacts[24].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-amd64.jar";
artifacts[24].size = "224010";
artifacts[25] = new Artifact();
artifacts[25].hash = "f474ef2ef01be24ec811d3858b0f4bc5659076975f4a58ddd79abd787e9305c7";
artifacts[25].name = "jogl-all-2.3.2-natives-linux-i586.jar";
artifacts[25].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-i586.jar";
artifacts[25].size = "217274";
artifacts[26] = new Artifact();
artifacts[26].hash = "084844543b18f7ff71b4c0437852bd22f0cb68d7e44c2c611c1bbea76f8c6fdf";
artifacts[26].name = "gluegen-rt-2.3.2.jar";
artifacts[26].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2.jar";
artifacts[26].size = "345605";
artifacts[27] = new Artifact();
artifacts[27].hash = "3474017422eff384db466bdb56c96c61220c43133a9da6329cf1781bea16c6b6";
artifacts[27].name = "gluegen-rt-2.3.2-natives-windows-amd64.jar";
artifacts[27].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-amd64.jar";
artifacts[27].size = "8159";
artifacts[28] = new Artifact();
artifacts[28].hash = "4eeed9fc2ebea5b9dc48a342b9478d127e989a2e1aa7129b512a98ec75cde338";
artifacts[28].name = "gluegen-rt-2.3.2-natives-windows-i586.jar";
artifacts[28].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-i586.jar";
artifacts[28].size = "7577";
artifacts[29] = new Artifact();
artifacts[29].hash = "f2dfd1800202059cf7e0294db5d57755147304e6eb220a9277526dbe6842bde2";
artifacts[29].name = "gluegen-rt-2.3.2-natives-linux-amd64.jar";
artifacts[29].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-amd64.jar";
artifacts[29].size = "4149";
artifacts[30] = new Artifact();
artifacts[30].hash = "1365d463f98c0abec92f3ad6b35aa4b53a9599a517800cf99fdabea6712ca7ec";
artifacts[30].name = "gluegen-rt-2.3.2-natives-linux-i586.jar";
artifacts[30].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-i586.jar";
artifacts[30].size = "4130";
artifacts[31] = new Artifact();
artifacts[31].hash = "7b7ae00e2aa98c3b2b5ac76e793e2c9b752bf51c86c54654dbd473843a25f1aa";
artifacts[31].name = "jbsdiff-1.0.jar";
artifacts[31].path = "https://mvn.runelite.net/io/sigpipe/jbsdiff/1.0/jbsdiff-1.0.jar";
artifacts[31].size = "24589";
artifacts[32] = new Artifact();
artifacts[32].hash = "55bbfe26cee9296fd5b7c0d47ce6a00ea4dd572e235b63e9bb4eaf6f802315e4";
artifacts[32].name = "commons-compress-1.5.jar";
artifacts[32].path = "https://mvn.runelite.net/org/apache/commons/commons-compress/1.5/commons-compress-1.5.jar";
artifacts[32].size = "256241";
artifacts[33] = new Artifact();
artifacts[33].hash = "fbc9de96a0cc193a125b4008dbc348e9ed54e5e13fc67b8ed40e645d303cc51b";
artifacts[33].name = "jna-4.5.1.jar";
artifacts[33].path = "https://mvn.runelite.net/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar";
artifacts[33].size = "1440662";
artifacts[34] = new Artifact();
artifacts[34].hash = "84c8667555ee8dd91fef44b451419f6f16f71f727d5fc475a10c2663eba83abb";
artifacts[34].name = "jna-platform-4.5.1.jar";
artifacts[34].path = "https://mvn.runelite.net/net/java/dev/jna/jna-platform/4.5.1/jna-platform-4.5.1.jar";
artifacts[34].size = "2327547";
artifacts[38] = new Artifact();
artifacts[38].hash = "f55abda036da75e1af45bd43b9dfa79b2a3d90905be9cb38687c6621597a8165";
artifacts[38].name = "okhttp-3.7.0.jar";
artifacts[38].path = "https://mvn.runelite.net/com/squareup/okhttp3/okhttp/3.7.0/okhttp-3.7.0.jar";
artifacts[38].size = "394987";
artifacts[39] = new Artifact();
artifacts[39].hash = "bfe7dfe483c37137966a1690f0c7d0b448ba217902c1fed202aaffdbba3291ae";
artifacts[39].name = "okio-1.12.0.jar";
artifacts[39].path = "https://mvn.runelite.net/com/squareup/okio/okio/1.12.0/okio-1.12.0.jar";
artifacts[39].size = "81088";
artifacts[40] = new Artifact();
artifacts[40].hash = "9d4924588d6280c7516db3a4b7298306db5b6f0d1cdf568ce738309b5660f008";
artifacts[40].name = "commons-csv-1.4.jar";
artifacts[40].path = "https://mvn.runelite.net/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar";
artifacts[40].size = "39978";
artifacts[41] = new Artifact();
artifacts[41].hash = "7e26a8d043418f2f22d5f6a3083a9a131817009ee8cd72c004e83b50d1849a7c";
artifacts[41].name = "discord-1.1.jar";
artifacts[41].path = "https://repo.runelite.net/net/runelite/discord/1.1/discord-1.1.jar";
artifacts[41].size = "617294";
private static String bytesToHex(byte[] hashInBytes) { //Dynamic artifacts
artifacts[3] = new Artifact();
artifacts[3].name = "client-" + RuneLiteAPI.getVersion() + ".jar";
artifacts[3].hash = getChecksumFile("./runelite-client/target/" + artifacts[3].name);
artifacts[3].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[3].name;
artifacts[3].size = Long.toString(getFileSize("./runelite-client/target/" + artifacts[3].name));
artifacts[35] = new Artifact();
artifacts[35].name = "runelite-api-" + RuneLiteAPI.getVersion() + ".jar";
artifacts[35].hash = getChecksumFile("./runelite-api/target/" + artifacts[35].name);
artifacts[35].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[35].name;
artifacts[35].size = Long.toString(getFileSize("./runelite-api/target/" + artifacts[35].name));
artifacts[36] = new Artifact();
artifacts[36].name = "runescape-api-" + RuneLiteAPI.getVersion() + ".jar";
artifacts[36].hash = getChecksumFile("./runescape-api/target/" + artifacts[36].name);
artifacts[36].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[36].name;
artifacts[36].size = Long.toString(getFileSize("./runescape-api/target/" + artifacts[36].name));
artifacts[37] = new Artifact();
artifacts[37].name = "http-api-" + RuneLiteAPI.getVersion() + ".jar";
artifacts[37].hash = getChecksumFile("./http-api/target/" + artifacts[37].name);
artifacts[37].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[37].name;
artifacts[37].size = Long.toString(getFileSize("./http-api/target/" + artifacts[37].name));
}
catch (IOException e)
{
e.printStackTrace();
}
return artifacts;
}
StringBuilder sb = new StringBuilder(); private long getFileSize(String fileLocation)
for (byte b : hashInBytes) { {
sb.append(String.format("%02x", b)); File f = new File(fileLocation);
} return f.length();
return sb.toString(); }
}
private long getFileSize(String fileLocation) {
File f = new File(fileLocation);
return f.length();
}
} }

View File

@@ -2,24 +2,24 @@ package net.runelite.client.util.bootstrap;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException;
public class Bootstrapper { public class Bootstrapper
{
public static void main(String[] args) { public static void main(String[] args)
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); {
try { Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
FileWriter fw = new FileWriter("./bootstrap.json"); try
gson.toJson(new Bootstrap(), fw); {
fw.close(); FileWriter fw = new FileWriter("./bootstrap.json");
} catch (Exception e) { gson.toJson(new Bootstrap(), fw);
e.printStackTrace(); fw.close();
} }
catch (Exception e)
{
e.printStackTrace();
}
} }
} }

View File

@@ -1,11 +1,12 @@
package net.runelite.client.util.bootstrap; package net.runelite.client.util.bootstrap;
public class Client { public class Client
{
String artifactId = "client"; String artifactId = "client";
String classifier = ""; String classifier = "";
String extension = "jar"; String extension = "jar";
String groupId = "net.runelite"; String groupId = "net.runelite";
String properties = ""; String properties = "";
String version = "1.5.27"; String version = "1.5.27";
} }

View File

@@ -1,12 +1,9 @@
package net.runelite.mixins; package net.runelite.mixins;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
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.RSModel;
/** /**
* Class to check clickboxes of models. Mostly refactored code from the client. * Class to check clickboxes of models. Mostly refactored code from the client.
@@ -14,19 +11,40 @@ import net.runelite.rs.api.RSModel;
@Mixin(RSClient.class) @Mixin(RSClient.class)
public abstract class ClickboxMixin implements RSClient public abstract class ClickboxMixin implements RSClient
{ {
@Shadow("client")
private static RSClient client;
private static final int MAX_ENTITES_AT_MOUSE = 1000; private static final int MAX_ENTITES_AT_MOUSE = 1000;
private static final int CLICKBOX_CLOSE = 50; private static final int CLICKBOX_CLOSE = 50;
private static final int CLICKBOX_FAR = 10000; private static final int CLICKBOX_FAR = 10000;
private static final int OBJECT_INTERACTION_FAR = 100; // Max distance, in tiles, from camera private static final int OBJECT_INTERACTION_FAR = 100; // Max distance, in tiles, from camera
@Inject @Inject
private static final int[] rl$modelViewportXs = new int[4700]; private static final int[] rl$modelViewportXs = new int[4700];
@Inject @Inject
private static final int[] rl$modelViewportYs = new int[4700]; private static final int[] rl$modelViewportYs = new int[4700];
@Shadow("client")
private static RSClient client;
@Inject
private static int rl$rot1(int var0, int var1, int var2, int var3)
{
return var0 * var2 + var3 * var1 >> 16;
}
@Inject
private static int rl$rot2(int var0, int var1, int var2, int var3)
{
return var2 * var1 - var3 * var0 >> 16;
}
@Inject
private static int rl$rot3(int var0, int var1, int var2, int var3)
{
return var0 * var2 - var3 * var1 >> 16;
}
@Inject
private static int rl$rot4(int var0, int var1, int var2, int var3)
{
return var3 * var0 + var2 * var1 >> 16;
}
@Inject @Inject
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) 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)
@@ -118,11 +136,8 @@ public abstract class ClickboxMixin implements RSClient
int n28 = rl$modelViewportXs[n12]; int n28 = rl$modelViewportXs[n12];
int n29 = rl$modelViewportXs[n10]; int n29 = rl$modelViewportXs[n10];
int n30 = rl$modelViewportXs[n24]; int n30 = rl$modelViewportXs[n24];
if (n25 != -5000 && n26 != -5000 && n27 != -5000 && (bl5 = (n23 = (n22 = rSModel.isClickable() ? 20 if (n25 != -5000 && n26 != -5000 && n27 != -5000 && (bl5 = ((n23 = (n22 = rSModel.isClickable() ? 20
: 5) + n11) < n28 && n23 < n29 && n23 < n30 ? false : 5) + n11) >= n28 || n23 >= n29 || n23 >= n30) && (((n23 = n11 - n22) <= n28 || n23 <= n29 || n23 <= n30) && (((n23 = n22 + n14) >= n25 || n23 >= n26 || n23 >= n27) && ((n23 = n14 - n22) <= n25 || n23 <= n26 || n23 <= n27)))))
: ((n23 = n11 - n22) > n28 && n23 > n29 && n23 > n30 ? false
: ((n23 = n22 + n14) < n25 && n23 < n26 && n23 < n27 ? false
: (n23 = n14 - n22) <= n25 || n23 <= n26 || n23 <= n27))))
{ {
this.addHashAtMouse(l2); this.addHashAtMouse(l2);
return; return;
@@ -211,34 +226,6 @@ public abstract class ClickboxMixin implements RSClient
{ {
return false; return false;
} }
if (Math.abs(n39 * n23 - n38 * n24) <= n33 * n26 + n32 * n27) return Math.abs(n39 * n23 - n38 * n24) <= n33 * n26 + n32 * n27;
{
return true;
}
return false;
}
@Inject
private static int rl$rot1(int var0, int var1, int var2, int var3)
{
return var0 * var2 + var3 * var1 >> 16;
}
@Inject
private static int rl$rot2(int var0, int var1, int var2, int var3)
{
return var2 * var1 - var3 * var0 >> 16;
}
@Inject
private static int rl$rot3(int var0, int var1, int var2, int var3)
{
return var0 * var2 - var3 * var1 >> 16;
}
@Inject
private static int rl$rot4(int var0, int var1, int var2, int var3)
{
return var3 * var0 + var2 * var1 >> 16;
} }
} }

View File

@@ -24,21 +24,21 @@
*/ */
package net.runelite.mixins; package net.runelite.mixins;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.model.Jarvis;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
import java.awt.Polygon; import java.awt.Polygon;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
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.MethodHook; import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Replace; import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow; import net.runelite.api.mixins.Shadow;
import net.runelite.api.model.Jarvis;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
import net.runelite.rs.api.RSAnimation; import net.runelite.rs.api.RSAnimation;
import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFrames; import net.runelite.rs.api.RSFrames;
@@ -77,9 +77,112 @@ public abstract class RSModelMixin implements RSModel
} }
@Inject @Inject
public boolean isClickable() { public boolean isClickable()
{
return isClickable; return isClickable;
}; }
@Inject
public void interpolateFrames(RSFrames frames, int frameId, RSFrames nextFrames, int nextFrameId, int interval, int intervalCount)
{
if (getVertexGroups() != null)
{
if (frameId != -1)
{
RSAnimation frame = frames.getFrames()[frameId];
RSSkeleton skin = frame.getSkin();
RSAnimation nextFrame = null;
if (nextFrames != null)
{
nextFrame = nextFrames.getFrames()[nextFrameId];
if (nextFrame.getSkin() != skin)
{
nextFrame = null;
}
}
client.setAnimOffsetX(0);
client.setAnimOffsetY(0);
client.setAnimOffsetZ(0);
interpolateFrames(skin, frame, nextFrame, interval, intervalCount);
resetBounds();
}
}
}
@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation, int tileHeight)
{
List<Vertex> vertices = getVertices();
// rotate vertices
for (int i = 0; i < vertices.size(); ++i)
{
Vertex v = vertices.get(i);
vertices.set(i, v.rotate(orientation));
}
List<Point> points = new ArrayList<Point>();
for (Vertex v : vertices)
{
// Compute canvas location of vertex
Point p = Perspective.localToCanvas(client,
localX - v.getX(),
localY - v.getZ(),
tileHeight + v.getY());
if (p != null)
{
points.add(p);
}
}
// Run Jarvis march algorithm
points = Jarvis.convexHull(points);
if (points == null)
{
return null;
}
// Convert to a polygon
Polygon p = new Polygon();
for (Point point : points)
{
p.addPoint(point.getX(), point.getY());
}
return p;
}
@Inject
@Override
public float[][] getFaceTextureUCoordinates()
{
return rl$faceTextureUCoordinates;
}
@Inject
@Override
public void setFaceTextureUCoordinates(float[][] faceTextureUCoordinates)
{
this.rl$faceTextureUCoordinates = faceTextureUCoordinates;
}
@Inject
@Override
public float[][] getFaceTextureVCoordinates()
{
return rl$faceTextureVCoordinates;
}
@Inject
@Override
public void setFaceTextureVCoordinates(float[][] faceTextureVCoordinates)
{
this.rl$faceTextureVCoordinates = faceTextureVCoordinates;
}
@MethodHook(value = "<init>", end = true) @MethodHook(value = "<init>", end = true)
@Inject @Inject
@@ -174,6 +277,48 @@ public abstract class RSModelMixin implements RSModel
return triangles; return triangles;
} }
@Inject
@Override
public int getSceneId()
{
return rl$sceneId;
}
@Inject
@Override
public void setSceneId(int sceneId)
{
this.rl$sceneId = sceneId;
}
@Inject
@Override
public int getBufferOffset()
{
return rl$bufferOffset;
}
@Inject
@Override
public void setBufferOffset(int bufferOffset)
{
rl$bufferOffset = bufferOffset;
}
@Inject
@Override
public int getUvBufferOffset()
{
return rl$uvBufferOffset;
}
@Inject
@Override
public void setUvBufferOffset(int bufferOffset)
{
rl$uvBufferOffset = bufferOffset;
}
@Copy("contourGround") @Copy("contourGround")
public abstract Model rs$contourGround(int[][] tileHeights, int packedX, int height, int packedY, boolean copy, int contouredGround); public abstract Model rs$contourGround(int[][] tileHeights, int packedX, int height, int packedY, boolean copy, int contouredGround);
@@ -201,36 +346,6 @@ public abstract class RSModelMixin implements RSModel
rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates); rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates);
} }
@Inject
public void interpolateFrames(RSFrames frames, int frameId, RSFrames nextFrames, int nextFrameId, int interval,
int intervalCount)
{
if (getVertexGroups() != null)
{
if (frameId != -1)
{
RSAnimation frame = frames.getFrames()[frameId];
RSSkeleton skin = frame.getSkin();
RSAnimation nextFrame = null;
if (nextFrames != null)
{
nextFrame = nextFrames.getFrames()[nextFrameId];
if (nextFrame.getSkin() != skin)
{
nextFrame = null;
}
}
client.setAnimOffsetX(0);
client.setAnimOffsetY(0);
client.setAnimOffsetZ(0);
interpolateFrames(skin, frame, nextFrame, interval, intervalCount);
resetBounds();
}
}
}
@Inject @Inject
public void interpolateFrames(RSSkeleton skin, RSAnimation frame, RSAnimation nextFrame, int interval, int intervalCount) public void interpolateFrames(RSSkeleton skin, RSAnimation frame, RSAnimation nextFrame, int interval, int intervalCount)
{ {
@@ -334,119 +449,4 @@ public abstract class RSModelMixin implements RSModel
} }
} }
} }
@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation, int tileHeight)
{
List<Vertex> vertices = getVertices();
// rotate vertices
for (int i = 0; i < vertices.size(); ++i)
{
Vertex v = vertices.get(i);
vertices.set(i, v.rotate(orientation));
}
List<Point> points = new ArrayList<Point>();
for (Vertex v : vertices)
{
// Compute canvas location of vertex
Point p = Perspective.localToCanvas(client,
localX - v.getX(),
localY - v.getZ(),
tileHeight + v.getY());
if (p != null)
{
points.add(p);
}
}
// Run Jarvis march algorithm
points = Jarvis.convexHull(points);
if (points == null)
{
return null;
}
// Convert to a polygon
Polygon p = new Polygon();
for (Point point : points)
{
p.addPoint(point.getX(), point.getY());
}
return p;
}
@Inject
@Override
public int getSceneId()
{
return rl$sceneId;
}
@Inject
@Override
public void setSceneId(int sceneId)
{
this.rl$sceneId = sceneId;
}
@Inject
@Override
public int getBufferOffset()
{
return rl$bufferOffset;
}
@Inject
@Override
public void setBufferOffset(int bufferOffset)
{
rl$bufferOffset = bufferOffset;
}
@Inject
@Override
public int getUvBufferOffset()
{
return rl$uvBufferOffset;
}
@Inject
@Override
public void setUvBufferOffset(int bufferOffset)
{
rl$uvBufferOffset = bufferOffset;
}
@Inject
@Override
public float[][] getFaceTextureUCoordinates()
{
return rl$faceTextureUCoordinates;
}
@Inject
@Override
public void setFaceTextureUCoordinates(float[][] faceTextureUCoordinates)
{
this.rl$faceTextureUCoordinates = faceTextureUCoordinates;
}
@Inject
@Override
public float[][] getFaceTextureVCoordinates()
{
return rl$faceTextureVCoordinates;
}
@Inject
@Override
public void setFaceTextureVCoordinates(float[][] faceTextureVCoordinates)
{
this.rl$faceTextureVCoordinates = faceTextureVCoordinates;
}
} }