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>

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
* *

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)
@@ -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)

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

@@ -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

@@ -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,24 +1,19 @@
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(); Artifact[] artifacts = getArtifacts();
Client client = new Client(); Client client = new Client();
String[] clientJvm9Arguments = new String[]{ String[] clientJvm9Arguments = new String[]{
@@ -49,10 +44,75 @@ public class Bootstrap {
"-XX:+UseParNewGC", "-XX:+UseParNewGC",
"-Djna.nosys=true"}; "-Djna.nosys=true"};
public Bootstrap(){} public Bootstrap()
{
}
public Artifact[] getArtifacts() { public static String getChecksumObject(Serializable object) throws IOException, NoSuchAlgorithmException
try { {
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());
}
private static String bytesToHex(byte[] hashInBytes)
{
StringBuilder sb = new StringBuilder();
for (byte b : hashInBytes)
{
sb.append(String.format("%02x", b));
}
return sb.toString();
}
public Artifact[] getArtifacts()
{
try
{
artifacts = new Artifact[42]; artifacts = new Artifact[42];
//Static artifacts //Static artifacts
@@ -268,59 +328,16 @@ public class Bootstrap {
artifacts[37].hash = getChecksumFile("./http-api/target/" + artifacts[37].name); 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].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)); artifacts[37].size = Long.toString(getFileSize("./http-api/target/" + artifacts[37].name));
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return artifacts; return artifacts;
} }
private long getFileSize(String fileLocation)
{
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());
}
private static String bytesToHex(byte[] hashInBytes) {
StringBuilder sb = new StringBuilder();
for (byte b : hashInBytes) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
private long getFileSize(String fileLocation) {
File f = new File(fileLocation); File f = new File(fileLocation);
return f.length(); return f.length();
} }

View File

@@ -2,22 +2,22 @@ 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(); Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
try { try
{
FileWriter fw = new FileWriter("./bootstrap.json"); FileWriter fw = new FileWriter("./bootstrap.json");
gson.toJson(new Bootstrap(), fw); gson.toJson(new Bootstrap(), fw);
fw.close(); fw.close();
} catch (Exception e) { }
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -1,6 +1,7 @@
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 = "";

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;
}
} }