Remove object wrappers and use mixins to inject functionality

This causes hierarchy to be runelite-client -> runelite-api and
injected-client -> runescape-api -> runelite-api. The mixin injector
fufills the runelite-api interface with access to the runescape-api
interfaces. The mixins live in runelite-mixins and are not loaded within
the client.

Note the obfuscated client classes do not pass JVM verification on 7+,
so the mixins are currently set to target Java 6.
This commit is contained in:
Adam
2017-08-19 13:58:06 -04:00
parent 07c8442f22
commit 59552896ed
124 changed files with 2257 additions and 1814 deletions

View File

@@ -13,8 +13,9 @@ If you have any questions please join our IRC channel on [irc.rizon.net #runelit
- http-service - Service for api.runelite.net
- model-viewer - RS Model, NPC/Object, and terrain viewer
- runelite-api - runelite api, use this for plugin development
- runescape-api - mappings correspond to these interfaces, runelite-api wraps this
- runescape-client-injector - builds the injection from the vanilla client and the mappings
- runelite-mixins - Mixins which are injected into the injected client's classes
- runescape-api - mappings correspond to these interfaces, runelite-api is a subset of this
- runescape-client-injector - builds the injected client from the vanilla client and the mappings
- runescape-client - decompiled RuneScape client, contains mappings
## Usage

View File

@@ -101,6 +101,7 @@
<module>model-viewer-rsmv</module>
<module>runelite-api</module>
<module>runelite-client</module>
<module>runelite-mixins</module>
<module>runescape-api</module>
<module>runescape-client</module>
<module>runescape-client-injector</module>

View File

@@ -37,12 +37,6 @@
<name>Runelite API</name>
<dependencies>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@@ -27,172 +27,34 @@ package net.runelite.api;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.Objects;
import net.runelite.rs.api.CombatInfo1;
import net.runelite.rs.api.CombatInfo2;
import net.runelite.rs.api.CombatInfoList;
import net.runelite.rs.api.CombatInfoListHolder;
import net.runelite.rs.api.Node;
public abstract class Actor extends Renderable
public interface Actor extends Renderable
{
int getCombatLevel();
private final Client client;
private net.runelite.rs.api.Actor actor;
String getName();
public Actor(Client client, net.runelite.rs.api.Actor actor)
{
super(actor);
Actor getInteracting();
this.client = client;
this.actor = actor;
}
int getHealthRatio();
@Override
public int hashCode()
{
int hash = 5;
hash = 47 * hash + Objects.hashCode(this.client);
return hash;
}
int getHealth();
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Actor other = (Actor) obj;
if (!Objects.equals(this.client, other.client))
{
return false;
}
return true;
}
Point getLocalLocation();
public abstract int getCombatLevel();
int getOrientation();
public abstract String getName();
int getAnimation();
public Actor getInteracting()
{
int i = actor.getInteracting();
if (i == -1)
{
return null;
}
int getGraphic();
if (i < 0x8000)
{
return client.getNpc(i);
}
int getModelHeight();
i -= 0x8000;
return client.getPlayer(i);
}
Polygon getCanvasTilePoly();
public int getHealthRatio()
{
CombatInfoList combatInfoList = actor.getCombatInfoList();
if (combatInfoList != null)
{
Node node = combatInfoList.getNode();
Node next = node.getNext();
if (next instanceof CombatInfoListHolder)
{
CombatInfoListHolder combatInfoListWrapper = (CombatInfoListHolder) next;
CombatInfoList combatInfoList1 = combatInfoListWrapper.getCombatInfo1();
Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset);
Node node2 = combatInfoList1.getNode();
Node next2 = node2.getNext();
if (next2 instanceof CombatInfo1)
{
CombatInfo1 combatInfo = (CombatInfo1) next2;
return combatInfo.getHealthRatio();
}
}
}
return -1;
}
Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset);
public int getHealth()
{
CombatInfoList combatInfoList = actor.getCombatInfoList();
if (combatInfoList != null)
{
Node node = combatInfoList.getNode();
Node next = node.getNext();
if (next instanceof CombatInfoListHolder)
{
CombatInfoListHolder combatInfoListWrapper = (CombatInfoListHolder) next;
CombatInfo2 cf = combatInfoListWrapper.getCombatInfo2();
return cf.getHealthScale();
}
}
return -1;
}
public Point getLocalLocation()
{
return new Point(getX(), getY());
}
private int getX()
{
return actor.getX();
}
private int getY()
{
return actor.getY();
}
public int getOrientation()
{
return actor.getOrientation();
}
public int getAnimation()
{
return actor.getAnimation();
}
public int getGraphic()
{
return actor.getGraphic();
}
public int getModelHeight()
{
return actor.getModelHeight();
}
public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}
public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}
public Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset)
{
return Perspective.getCanvasImageLocation(client, graphics, getLocalLocation(), image, zOffset);
}
public Point getMinimapLocation()
{
return Perspective.worldToMiniMap(client, getX(), getY());
}
Point getMinimapLocation();
}

View File

@@ -25,396 +25,122 @@
package net.runelite.api;
import java.awt.Canvas;
import java.util.Arrays;
import java.util.Objects;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.rs.api.ItemComposition;
public class Client
public interface Client
{
private final net.runelite.rs.api.Client client;
public Client(net.runelite.rs.api.Client client)
{
this.client = client;
}
public Player getLocalPlayer()
{
if (client.getLocalPlayer() == null)
{
return null;
}
return new Player(this, client.getLocalPlayer());
}
public NPC[] getNpcs()
{
return Arrays.stream(client.getCachedNPCs())
.map(npc -> npc != null ? new NPC(this, npc) : null)
.toArray(size -> new NPC[size]);
}
NPC getNpc(int idx)
{
net.runelite.rs.api.NPC npc = client.getCachedNPCs()[idx];
return npc != null ? new NPC(this, npc) : null;
}
public Player[] getPlayers()
{
return Arrays.stream(client.getCachedPlayers())
.map(player -> player != null ? new Player(this, player) : null)
.toArray(size -> new Player[size]);
}
Player getPlayer(int idx)
{
net.runelite.rs.api.Player player = client.getCachedPlayers()[idx];
return player != null ? new Player(this, player) : null;
}
@SuppressWarnings("unchecked")
public <T> T[] runQuery(Query query)
{
return (T[]) query.result(this);
}
public int getBoostedSkillLevel(Skill skill)
{
int[] boostedLevels = client.getBoostedSkillLevels();
return boostedLevels[skill.ordinal()];
}
public int getRealSkillLevel(Skill skill)
{
int[] realLevels = client.getRealSkillLevels();
return realLevels[skill.ordinal()];
}
public void sendGameMessage(String message)
{
client.sendGameMessage(99, "", message);
}
public GameState getGameState()
{
return GameState.of(client.getGameState());
}
public String getUsername()
{
return client.getUsername();
}
public void setUsername(String name)
{
client.setUsername(name);
}
public Canvas getCanvas()
{
return client.getCanvas();
}
public int getFPS()
{
return client.getFPS();
}
public int getClientHeight()
{
return client.getCanvas().getHeight();
}
public int getClientWidth()
{
return client.getCanvas().getWidth();
}
public int getCameraX()
{
return client.getCameraX();
}
public int getCameraY()
{
return client.getCameraY();
}
public int getCameraZ()
{
return client.getCameraZ();
}
public int getCameraPitch()
{
return client.getCameraPitch();
}
public int getCameraYaw()
{
return client.getCameraYaw();
}
public int getViewportHeight()
{
return client.getViewportHeight();
}
public int getViewportWidth()
{
return client.getViewportWidth();
}
public int getScale()
{
return client.getScale();
}
public Point getMouseCanvasPosition()
{
return new Point(client.getMouseX(), client.getMouseY());
}
public int[][][] getTileHeights()
{
return client.getTileHeights();
}
public byte[][][] getTileSettings()
{
return client.getTileSettings();
}
public int getPlane()
{
return client.getPlane();
}
public Region getRegion()
{
return new Region(this, client.getRegion());
}
public ItemComposition getItemDefinition(int id)
{
return client.getItemDefinition(id);
}
public int getBaseX()
{
return client.getBaseX();
}
public int getBaseY()
{
return client.getBaseY();
}
public Widget[] getWidgetRoots()
{
int topGroup = client.getWidgetRoot();
return Arrays.stream(client.getWidgets()[topGroup])
.filter(Objects::nonNull)
.filter(w -> w.getParentId() == -1) // is a root
.map(w -> new Widget(this, w))
.toArray(Widget[]::new);
}
public Widget getWidget(WidgetInfo widget)
{
int groupId = widget.getGroupId();
int childId = widget.getChildId();
return getWidget(groupId, childId);
}
public Widget[] getGroup(int groupId)
{
net.runelite.rs.api.Widget[][] widgets = client.getWidgets();
if (widgets == null || groupId < 0 || groupId >= widgets.length)
{
return null;
}
return Arrays.stream(widgets[groupId])
.filter(Objects::nonNull)
.map(w -> new Widget(this, w))
.toArray(Widget[]::new);
}
public Widget getWidget(int groupId, int childId)
{
net.runelite.rs.api.Widget[][] widgets = client.getWidgets();
if (widgets == null || widgets.length <= groupId)
{
return null;
}
net.runelite.rs.api.Widget[] childWidgets = widgets[groupId];
if (childWidgets == null || childWidgets.length <= childId)
{
return null;
}
return new Widget(this, childWidgets[childId]);
}
public int[] getWidgetPositionsX()
{
return client.getWidgetPositionsX();
}
public int[] getWidgetPositionsY()
{
return client.getWidgetPositionsY();
}
public String[] getPlayerOptions()
{
return client.getPlayerOptions();
}
public boolean[] getPlayerOptionsPriorities()
{
return client.getPlayerOptionsPriorities();
}
public int[] getPlayerMenuType()
{
return client.getPlayerMenuTypes();
}
public String[] getMenuOptions()
{
return client.getMenuOptions();
}
public String[] getMenuTargets()
{
return client.getMenuTargets();
}
public int getMenuCount()
{
return client.getMenuOptionCount();
}
public boolean isMenuOpen()
{
return client.isMenuOpen();
}
public int getMapAngle()
{
return client.getMapAngle();
}
public boolean isResized()
{
return client.isResized();
}
public int getRevision()
{
return client.getRevision();
}
public int[] getMapRegions()
{
return client.getMapRegions();
}
public int[][] getXteaKeys()
{
return client.getXteaKeys();
}
public int getSetting(Varbits varbit)
{
int[] settings = client.getSettings();
int value = settings[varbit.getIndex()];
return varbit.get(value);
}
public XHashTable getComponentTable()
{
return new XHashTable(client.getComponentTable());
}
public int[] getSettings()
{
return client.getSettings();
}
public int[] getWidgetSettings()
{
return client.getWidgetSettings();
}
public boolean isPrayerActive(Prayer prayer)
{
return getSetting(prayer.getVarbit()) == 1;
}
public int getClanChatCount()
{
return client.getClanChatCount();
}
/**
* Returns the local player's current experience in the specified
* {@link Skill}.
*
* @param skill the {@link Skill} to retrieve the experience for
* @return the local player's current experience in the specified
* {@link Skill}, or -1 if the {@link Skill} isn't valid
*/
public int getSkillExperience(Skill skill)
{
int[] experiences = client.getSkillExperiences();
if (skill == Skill.OVERALL)
{
int totalExperience = 0;
for (int experience : experiences)
{
totalExperience += experience;
}
return totalExperience;
}
int idx = skill.ordinal();
// I'm not certain exactly how needed this is, but if the Skill enum is updated in the future
// to hold something else that's not reported it'll save us from an ArrayIndexOutOfBoundsException.
if (idx >= experiences.length)
{
return -1;
}
return experiences[idx];
}
public int getGameDrawingMode()
{
return client.getGameDrawingMode();
}
public void setGameDrawingMode(int gameDrawingMode)
{
client.setGameDrawingMode(gameDrawingMode);
}
public void refreshChat()
{
client.setChatCycle(client.getCycleCntr());
}
Player getPlayer(int idx);
Player[] getCachedPlayers();
NPC getNpc(int idx);
NPC[] getCachedNPCs();
int getBoostedSkillLevel(Skill skill);
int getRealSkillLevel(Skill skill);
void sendGameMessage(String message);
GameState getGameState();
String getUsername();
void setUsername(String name);
Canvas getCanvas();
int getFPS();
int getCameraX();
int getCameraY();
int getCameraZ();
int getCameraPitch();
int getCameraYaw();
int getViewportHeight();
int getViewportWidth();
int getScale();
Point getMouseCanvasPosition();
int[][][] getTileHeights();
byte[][][] getTileSettings();
int getPlane();
Region getRegion();
Player getLocalPlayer();
ItemComposition getItemDefinition(int id);
int getBaseX();
int getBaseY();
Widget[] getWidgetRoots();
Widget getWidget(WidgetInfo widget);
Widget[] getGroup(int groupId);
Widget getWidget(int groupId, int childId);
int[] getWidgetPositionsX();
int[] getWidgetPositionsY();
String[] getPlayerOptions();
boolean[] getPlayerOptionsPriorities();
int[] getPlayerMenuTypes();
String[] getMenuOptions();
String[] getMenuTargets();
int getMenuOptionCount();
boolean isMenuOpen();
int getMapAngle();
boolean isResized();
int getRevision();
int[] getMapRegions();
int[][] getXteaKeys();
int[] getSettings();
int[] getWidgetSettings();
int getSetting(Varbits varbit);
int getClanChatCount();
HashTable getComponentTable();
boolean isPrayerActive(Prayer prayer);
int getSkillExperience(Skill skill);
int getGameDrawingMode();
void setGameDrawingMode(int gameDrawingMode);
void refreshChat();
}

View File

@@ -31,63 +31,7 @@ import java.awt.Polygon;
*
* @author Adam
*/
public class DecorativeObject extends TileObject
public interface DecorativeObject extends TileObject
{
private final net.runelite.rs.api.DecorativeObject decorativeObject;
public DecorativeObject(Client client, net.runelite.rs.api.DecorativeObject decorativeObject)
{
super(client);
this.decorativeObject = decorativeObject;
}
@Override
protected int getHash()
{
return decorativeObject.getHash();
}
@Override
protected int getLocalX()
{
return decorativeObject.getX();
}
@Override
protected int getLocalY()
{
return decorativeObject.getY();
}
public Renderable getRenderable()
{
return Renderable.of(decorativeObject.getRenderable());
}
public Polygon getConvexHull()
{
Renderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
Model model;
if (renderable instanceof Model)
{
model = (Model) renderable;
}
else
{
model = renderable.getModel();
}
if (model == null)
{
return null;
}
return getConvexHull(model, decorativeObject.getOrientation());
}
Polygon getConvexHull();
}

View File

@@ -30,63 +30,7 @@ import java.awt.Polygon;
*
* @author Adam
*/
public class GameObject extends TileObject
public interface GameObject extends TileObject
{
private final net.runelite.rs.api.GameObject gameObject;
public GameObject(Client client, net.runelite.rs.api.GameObject gameObject)
{
super(client);
this.gameObject = gameObject;
}
@Override
protected int getHash()
{
return gameObject.getHash();
}
@Override
protected int getLocalX()
{
return gameObject.getX();
}
@Override
protected int getLocalY()
{
return gameObject.getY();
}
public Renderable getRenderable()
{
return Renderable.of(gameObject.getRenderable());
}
public Polygon getConvexHull()
{
Renderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
Model model;
if (renderable instanceof Model)
{
model = (Model) renderable;
}
else
{
model = renderable.getModel();
}
if (model == null)
{
return null;
}
return getConvexHull(model, gameObject.getOrientation());
}
Polygon getConvexHull();
}

View File

@@ -24,31 +24,6 @@
*/
package net.runelite.api;
public class GroundObject extends TileObject
public interface GroundObject extends TileObject
{
private final net.runelite.rs.api.GroundObject groundObject;
public GroundObject(Client client, net.runelite.rs.api.GroundObject groundObject)
{
super(client);
this.groundObject = groundObject;
}
@Override
protected int getHash()
{
return groundObject.getHash();
}
@Override
protected int getLocalX()
{
return groundObject.getX();
}
@Override
protected int getLocalY()
{
return groundObject.getY();
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;
import java.util.Collection;
public interface HashTable
{
Collection<Node> getNodes();
}

View File

@@ -24,23 +24,9 @@
*/
package net.runelite.api;
public class Item extends Renderable
public interface Item extends Renderable
{
private final net.runelite.rs.api.Item item;
int getId();
public Item(net.runelite.rs.api.Item item)
{
super(item);
this.item = item;
}
public int getId()
{
return item.getId();
}
public int getQuantity()
{
return item.getQuantity();
}
int getQuantity();
}

View File

@@ -22,69 +22,56 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;
package net.runelite.rs.api;
import net.runelite.mapping.Import;
/**
* ItemComposition is an interface that represents the various properties
* of an item. Imports several values from rs-client/ItemComposition,
* and allows direct access to them by calling these methods.
*/
public interface ItemComposition
{
/**
* Returns the item's name as a string.
*
* @return the name of the item
*/
@Import("name")
String getName();
/**
* Returns the item's ID. A list of item IDs can be
* found in net.runelite.api.ItemID.
* Returns the item's ID. A list of item IDs can be found in
* ItemID.
*
* @return the item's ID as an integer
*/
@Import("id")
int getId();
/**
* Returns a result that depends on whether the item
* is in noted form or not.
* Returns a result that depends on whether the item is in noted form or
* not.
*
* @return 799 if noted, -1 if unnoted
*/
@Import("notedTemplate")
int getNote();
/**
* Returns the item ID of the noted/unnoted counterpart.
* For example, if you call this on an unnoted monkfish(ID 7946),
* this method will return the ID of a noted monkfish(ID 7947),
* and vice versa.
* Returns the item ID of the noted/unnoted counterpart. For example, if
* you call this on an unnoted monkfish(ID 7946), this method will
* return the ID of a noted monkfish(ID 7947), and vice versa.
*
* @return the ID that is linked to this item in noted/unnoted form.
*/
@Import("note")
int getLinkedNoteId();
/**
* Returns the store price of the item. Even if the item cannot
* be found in a store, all items have a store price from which the
* High and Low Alchemy values are calculated. Multiply the price by
* 0.6 to get the High Alchemy value, or 0.4 to get the Low Alchemy
* value.
* Returns the store price of the item. Even if the item cannot be found
* in a store, all items have a store price from which the High and Low
* Alchemy values are calculated. Multiply the price by 0.6 to get the
* High Alchemy value, or 0.4 to get the Low Alchemy value.
*
* @return the general store value of the item
*/
@Import("price")
int getPrice();
/**
* Returns whether or not the item is members-only.
*
* @return true if members-only, false otherwise.
*/
@Import("isMembers")
boolean isMembers();
@Import("maleModel")
int getMaleModel();
}

View File

@@ -24,46 +24,11 @@
*/
package net.runelite.api;
public class ItemLayer extends TileObject
public interface ItemLayer extends TileObject
{
private final net.runelite.rs.api.ItemLayer itemLayer;
Renderable getBottom();
public ItemLayer(Client client, net.runelite.rs.api.ItemLayer itemLayer)
{
super(client);
this.itemLayer = itemLayer;
}
Renderable getMiddle();
@Override
protected int getHash()
{
return itemLayer.getHash();
}
@Override
protected int getLocalX()
{
return itemLayer.getX();
}
@Override
protected int getLocalY()
{
return itemLayer.getY();
}
public Renderable getBottom()
{
return Renderable.of(itemLayer.getBottom());
}
public Renderable getMiddle()
{
return Renderable.of(itemLayer.getMiddle());
}
public Renderable getTop()
{
return Renderable.of(itemLayer.getTop());
}
Renderable getTop();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,13 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
package net.runelite.api;
import java.awt.Image;
import net.runelite.mapping.Import;
public interface MainBufferProvider
{
@Import("image")
Image getImage();
}

View File

@@ -24,32 +24,13 @@
*/
package net.runelite.api;
public class MessageNode
public interface MessageNode
{
private final net.runelite.rs.api.MessageNode messageNode;
ChatMessageType getType();
public MessageNode(net.runelite.rs.api.MessageNode messageNode)
{
this.messageNode = messageNode;
}
String getSender();
public ChatMessageType getType()
{
return ChatMessageType.of(messageNode.getType());
}
String getValue();
public String getSender()
{
return messageNode.getSender();
}
public String getValue()
{
return messageNode.getValue();
}
public void setValue(String value)
{
messageNode.setValue(value);
}
void setValue(String value);
}

View File

@@ -24,71 +24,13 @@
*/
package net.runelite.api;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
public class Model extends Renderable
public interface Model extends Renderable
{
private final net.runelite.rs.api.Model model;
List<Vertex> getVertices();
public Model(net.runelite.rs.api.Model model)
{
super(model);
this.model = model;
}
public List<Vertex> getVertices()
{
int[] verticesX = model.getVerticesX();
int[] verticesY = model.getVerticesY();
int[] verticesZ = model.getVerticesZ();
assert verticesX.length == verticesY.length;
assert verticesY.length == verticesZ.length;
List<Vertex> vertices = new ArrayList<>();
for (int i = 0; i < verticesX.length; ++i)
{
Vertex v = new Vertex(
verticesX[i],
verticesY[i],
verticesZ[i]
);
vertices.add(v);
}
return vertices;
}
public List<Triangle> getTriangles()
{
int[] trianglesX = model.getTrianglesX();
int[] trianglesY = model.getTrianglesY();
int[] trianglesZ = model.getTrianglesZ();
assert trianglesX.length == trianglesY.length;
assert trianglesY.length == trianglesZ.length;
List<Vertex> vertices = getVertices();
List<Triangle> triangles = new ArrayList<>(trianglesX.length);
for (int i = 0; i < trianglesX.length; ++i)
{
int triangleX = trianglesX[i];
int triangleY = trianglesY[i];
int triangleZ = trianglesZ[i];
Triangle triangle = new Triangle(
vertices.get(triangleX),
vertices.get(triangleY),
vertices.get(triangleZ)
);
triangles.add(triangle);
}
return triangles;
}
List<Triangle> getTriangles();
}

View File

@@ -22,34 +22,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;
public class NPC extends Actor
public interface NPC extends Actor
{
private net.runelite.rs.api.NPC npc;
public NPC(Client client, net.runelite.rs.api.NPC npc)
{
super(client, npc);
this.npc = npc;
}
public int getId()
{
return npc.getComposition().getId();
}
int getId();
@Override
public String getName()
{
return npc.getComposition().getName().replace('\u00A0', ' ');
}
String getName();
@Override
public int getCombatLevel()
{
return npc.getComposition().getCombatLevel();
}
int getCombatLevel();
}

View File

@@ -24,58 +24,11 @@
*/
package net.runelite.api;
public class Node
public interface Node
{
private final net.runelite.rs.api.Node node;
Node getNext();
public Node(net.runelite.rs.api.Node node)
{
this.node = node;
}
Node getPrevious();
@Override
public String toString()
{
return "Node{" + "node=" + node + '}';
}
public Node getNext()
{
return of(node.getNext());
}
public Node getPrev()
{
return of(node.getPrevious());
}
public long getHash()
{
return node.getHash();
}
public static final Node of(net.runelite.rs.api.Node node)
{
if (node == null)
{
return null;
}
if (node instanceof net.runelite.rs.api.Item)
{
return new Item((net.runelite.rs.api.Item) node);
}
if (node instanceof net.runelite.rs.api.Renderable)
{
return Renderable.of((net.runelite.rs.api.Renderable) node);
}
if (node instanceof net.runelite.rs.api.WidgetNode)
{
return new WidgetNode((net.runelite.rs.api.WidgetNode) node);
}
return new Node(node);
}
long getHash();
}

View File

@@ -156,7 +156,7 @@ public class Perspective
int xx = y * sin + cos * x >> 16;
int yy = sin * x - y * cos >> 16;
int miniMapX = client.getClientWidth() - (!client.isResized() ? 208 : 167);
int miniMapX = client.getCanvas().getWidth() - (!client.isResized() ? 208 : 167);
x = (miniMapX + 167 / 2) + xx;
y = (167 / 2 - 1) + yy;

View File

@@ -25,115 +25,13 @@
package net.runelite.api;
import java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
public class Player extends Actor
public interface Player extends Actor
{
private final Client client;
private final net.runelite.rs.api.Player player;
public Player(Client client, net.runelite.rs.api.Player player)
{
super(client, player);
this.player = player;
this.client = client;
}
@Override
public String getName()
{
return player.getName().replace('\u00A0', ' ');
}
int getCombatLevel();
@Override
public int getCombatLevel()
{
return player.getCombatLevel();
}
PlayerComposition getPlayerComposition();
public PlayerComposition getPlayerComposition()
{
return new PlayerComposition(player.getComposition());
}
public Polygon[] getPolygons()
{
Model model = getModel();
if (model == null)
{
return null;
}
int localX = player.getX();
int localY = player.getY();
// models are orientated north (1024) and there are 2048 angles total
int orientation = (player.getOrientation() + 1024) % 2048;
List<Triangle> triangles = model.getTriangles();
if (orientation != 0)
{
triangles = rotate(triangles, orientation);
}
List<Polygon> polys = new ArrayList<>();
for (Triangle triangle : triangles)
{
Vertex vx = triangle.getA();
Vertex vy = triangle.getB();
Vertex vz = triangle.getC();
Point x = Perspective.worldToCanvas(client,
localX - vx.getX(),
localY - vx.getZ(),
-vx.getY());
Point y = Perspective.worldToCanvas(client,
localX - vy.getX(),
localY - vy.getZ(),
-vy.getY());
Point z = Perspective.worldToCanvas(client,
localX - vz.getX(),
localY - vz.getZ(),
-vz.getY());
int xx[] =
{
x.getX(), y.getX(), z.getX()
};
int yy[] =
{
x.getY(), y.getY(), z.getY()
};
polys.add(new Polygon(xx, yy, 3));
}
return polys.toArray(new Polygon[polys.size()]);
}
private List<Triangle> rotate(List<Triangle> triangles, int orientation)
{
List<Triangle> rotatedTriangles = new ArrayList<>();
for (Triangle triangle : triangles)
{
Vertex a = triangle.getA();
Vertex b = triangle.getB();
Vertex c = triangle.getC();
Triangle rotatedTriangle = new Triangle(
a.rotate(orientation),
b.rotate(orientation),
c.rotate(orientation)
);
rotatedTriangles.add(rotatedTriangle);
}
return rotatedTriangles;
}
Polygon[] getPolygons();
}

View File

@@ -26,43 +26,18 @@ package net.runelite.api;
import net.runelite.api.kit.KitType;
public class PlayerComposition
public interface PlayerComposition
{
private final net.runelite.rs.api.PlayerComposition playerComposition;
public PlayerComposition(net.runelite.rs.api.PlayerComposition playerComposition)
{
this.playerComposition = playerComposition;
}
/**
* Get equipment ids. If id is &ge; 256 &amp;&amp; &lt; 512 then subtract 256 and the id is a kit definition.
* If the id is &ge; 512 then subtract 512 and the id is an item id.
* Get equipment ids. If id is &ge; 256 &amp;&amp; &lt; 512 then
* subtract 256 and the id is a kit definition. If the id is &ge; 512
* then subtract 512 and the id is an item id.
*
* @return
*/
public int[] getEquipmentIds()
{
return playerComposition.getEquipmentIds();
}
int[] getEquipmentIds();
public int getEquipmentId(KitType type)
{
int id = getEquipmentIds()[type.getIndex()];
if (id < 512)
{
return -1; // not an item
}
return id - 512;
}
int getEquipmentId(KitType type);
public int getKitId(KitType type)
{
int id = getEquipmentIds()[type.getIndex()];
if (id < 256 || id >= 512)
{
return -1; // not a kit
}
return id - 256;
}
int getKitId(KitType type);
}

View File

@@ -34,7 +34,7 @@ public abstract class Query<EntityType, QueryType>
{
}
protected abstract EntityType[] result(Client client);
public abstract EntityType[] result(Client client);
protected Predicate<EntityType> and(Predicate<EntityType> other)
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,27 +24,7 @@
*/
package net.runelite.api;
import java.util.Arrays;
public class Region
public interface Region
{
private final Client client;
private final net.runelite.rs.api.Region region;
public Region(Client client, net.runelite.rs.api.Region region)
{
this.client = client;
this.region = region;
}
public Tile[][][] getTiles()
{
return Arrays.stream(region.getTiles())
.map(tile1 -> Arrays.stream(tile1)
.map(tile2 -> Arrays.stream(tile2)
.map(tile3 -> tile3 != null ? new Tile(client, tile3) : null)
.toArray(Tile[]::new)
).toArray(Tile[][]::new)
).toArray(Tile[][][]::new);
}
Tile[][][] getTiles();
}

View File

@@ -24,34 +24,7 @@
*/
package net.runelite.api;
public class Renderable extends Node
public interface Renderable extends Node
{
private final net.runelite.rs.api.Renderable renderable;
public Renderable(net.runelite.rs.api.Renderable renderable)
{
super(renderable);
this.renderable = renderable;
}
public Model getModel()
{
net.runelite.rs.api.Model model = renderable.getModel();
return model != null ? new Model(model) : null;
}
public static Renderable of(net.runelite.rs.api.Renderable renderable)
{
if (renderable == null)
{
return null;
}
if (renderable instanceof net.runelite.rs.api.Model)
{
return new Model((net.runelite.rs.api.Model) renderable);
}
return new Renderable(renderable);
}
Model getModel();
}

View File

@@ -24,83 +24,20 @@
*/
package net.runelite.api;
import java.util.Arrays;
public class Tile
public interface Tile
{
private final Client client;
private final net.runelite.rs.api.Tile tile;
public Tile(Client client, net.runelite.rs.api.Tile tile)
{
this.client = client;
this.tile = tile;
}
/**
* Get the decorative object for this tile.
*
* @return
*/
public DecorativeObject getDecorativeObject()
{
net.runelite.rs.api.DecorativeObject decorativeObject = tile.getDecorativeObject();
DecorativeObject getDecorativeObject();
if (decorativeObject == null)
{
return null;
}
GameObject[] getGameObjects();
return new DecorativeObject(client, decorativeObject);
}
ItemLayer getItemLayer();
public GameObject[] getGameObjects()
{
net.runelite.rs.api.GameObject[] objects = tile.getObjects();
GroundObject getGroundObject();
if (objects == null)
{
return null;
}
return Arrays.stream(tile.getObjects())
.map(go -> go != null ? new GameObject(client, go) : null)
.toArray(i -> new GameObject[i]);
}
public ItemLayer getItemLayer()
{
net.runelite.rs.api.ItemLayer itemLayer = tile.getItemLayer();
if (itemLayer == null)
{
return null;
}
return new ItemLayer(client, itemLayer);
}
public GroundObject getGroundObject()
{
net.runelite.rs.api.GroundObject groundObject = tile.getGroundObject();
if (groundObject == null)
{
return null;
}
return new GroundObject(client, groundObject);
}
public WallObject getWallObject()
{
net.runelite.rs.api.WallObject wallObject = tile.getWallObject();
if (wallObject == null)
{
return null;
}
return new WallObject(client, wallObject);
}
WallObject getWallObject();
}

View File

@@ -26,113 +26,28 @@ package net.runelite.api;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.model.Jarvis;
import net.runelite.api.model.Vertex;
public abstract class TileObject
public interface TileObject
{
protected final Client client;
int getHash();
public TileObject(Client client)
{
this.client = client;
}
int getX();
protected abstract int getHash();
int getY();
protected abstract int getLocalX();
int getId();
protected abstract int getLocalY();
Point getWorldLocation();
public int getId()
{
int hash = getHash();
return hash >> 14 & 32767;
}
Point getLocalLocation();
public Point getWorldLocation()
{
Point localLocation = getLocalLocation();
return Perspective.localToWorld(client, localLocation);
}
Point getCanvasLocation();
public Point getLocalLocation()
{
return new Point(getLocalX(), getLocalY());
}
Polygon getCanvasTilePoly();
public Point getCanvasLocation()
{
Point locaLocation = getLocalLocation();
return Perspective.worldToCanvas(client, locaLocation.getX(), locaLocation.getY(), 0);
}
Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset);
public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}
Point getMinimapLocation();
public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}
public Point getMinimapLocation()
{
return Perspective.worldToMiniMap(client, getLocalX(), getLocalY());
}
protected Polygon getConvexHull(Model model, int orientation)
{
int localX = getLocalX();
int localY = getLocalY();
// models are orientated north (1024) and there are 2048 angles total
orientation = (orientation + 1024) % 2048;
List<Vertex> verticies = model.getVertices();
if (orientation != 0)
{
// rotate verticies
for (int i = 0; i < verticies.size(); ++i)
{
Vertex v = verticies.get(i);
verticies.set(i, v.rotate(orientation));
}
}
List<Point> points = new ArrayList<>();
for (Vertex v : verticies)
{
// Compute canvas location of vertex
Point p = Perspective.worldToCanvas(client,
localX - v.getX(),
localY - v.getZ(),
-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;
}
Polygon getConvexHull(Model model, int orientation);
}

View File

@@ -29,31 +29,6 @@ package net.runelite.api;
*
* @author Adam
*/
public class WallObject extends TileObject
public interface WallObject extends TileObject
{
private final net.runelite.rs.api.WallObject wallObject;
public WallObject(Client client, net.runelite.rs.api.WallObject wallObject)
{
super(client);
this.wallObject = wallObject;
}
@Override
protected int getHash()
{
return wallObject.getHash();
}
@Override
protected int getLocalX()
{
return wallObject.getX();
}
@Override
protected int getLocalY()
{
return wallObject.getY();
}
}

View File

@@ -24,18 +24,7 @@
*/
package net.runelite.api;
public class WidgetNode extends Node
public interface WidgetNode extends Node
{
private final net.runelite.rs.api.WidgetNode widgetNode;
public WidgetNode(net.runelite.rs.api.WidgetNode widgetNode)
{
super(widgetNode);
this.widgetNode = widgetNode;
}
public int getId()
{
return widgetNode.getId();
}
int getId();
}

View File

@@ -35,7 +35,7 @@ import java.util.Objects;
public class DecorativeObjectQuery extends TileObjectQuery<DecorativeObject, DecorativeObjectQuery>
{
@Override
protected DecorativeObject[] result(Client client)
public DecorativeObject[] result(Client client)
{
return getDecorativeObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(DecorativeObject[]::new);
}

View File

@@ -36,7 +36,7 @@ import java.util.Objects;
public class GameObjectQuery extends TileObjectQuery<GameObject, GameObjectQuery>
{
@Override
protected GameObject[] result(Client client)
public GameObject[] result(Client client)
{
return getGameObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(GameObject[]::new);
}

View File

@@ -35,7 +35,7 @@ import java.util.Objects;
public class GroundObjectQuery extends TileObjectQuery<GroundObject, GroundObjectQuery>
{
@Override
protected GroundObject[] result(Client client)
public GroundObject[] result(Client client)
{
return getGroundObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(GroundObject[]::new);
}

View File

@@ -33,9 +33,9 @@ import java.util.Objects;
public class NPCQuery extends ActorQuery<NPC, NPCQuery>
{
@Override
protected NPC[] result(Client client)
public NPC[] result(Client client)
{
return Arrays.stream(client.getNpcs())
return Arrays.stream(client.getCachedNPCs())
.filter(Objects::nonNull)
.filter(predicate)
.toArray(NPC[]::new);

View File

@@ -33,9 +33,9 @@ import java.util.Objects;
public class PlayerQuery extends ActorQuery<Player, PlayerQuery>
{
@Override
protected Player[] result(Client client)
public Player[] result(Client client)
{
return Arrays.stream(client.getPlayers())
return Arrays.stream(client.getCachedPlayers())
.filter(Objects::nonNull)
.filter(predicate)
.toArray(Player[]::new);

View File

@@ -35,7 +35,7 @@ import java.util.Objects;
public class WallObjectQuery extends TileObjectQuery<WallObject, WallObjectQuery>
{
@Override
protected WallObject[] result(Client client)
public WallObject[] result(Client client)
{
return getWallObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(WallObject[]::new);
}

View File

@@ -81,7 +81,7 @@ public class WidgetItemQuery extends Query<WidgetItem, WidgetItemQuery>
}
@Override
protected WidgetItem[] result(Client client)
public WidgetItem[] result(Client client)
{
Widget widget = client.getWidget(widgetInfo);
if (widget != null)

View File

@@ -25,320 +25,60 @@
package net.runelite.api.widgets;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import net.runelite.api.Client;
import net.runelite.api.Node;
import net.runelite.api.Point;
import net.runelite.api.WidgetNode;
import net.runelite.api.XHashTable;
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
public class Widget
public interface Widget
{
private static final int ITEM_SLOT_SIZE = 32;
int getId();
private final Client client;
private final net.runelite.rs.api.Widget widget;
int getType();
public Widget(Client client, net.runelite.rs.api.Widget widget)
{
this.client = client;
this.widget = widget;
}
int getContentType();
public int getId()
{
return widget.getId();
}
Widget getParent();
public int getType()
{
return widget.getType();
}
int getParentId();
public int getContentType()
{
return widget.getContentType();
}
Widget getChild(int index);
public Widget getParent()
{
int id = getParentId();
if (id == -1)
{
return null;
}
Widget[] getDynamicChildren();
return client.getWidget(TO_GROUP(id), TO_CHILD(id));
}
Widget[] getStaticChildren();
public int getParentId()
{
int parentId = widget.getParentId();
if (parentId != -1)
{
return parentId;
}
Widget[] getNestedChildren();
int i = TO_GROUP(getId());
XHashTable componentTable = client.getComponentTable();
for (Node node : componentTable.getNodes())
{
WidgetNode wn = (WidgetNode) node;
int getRelativeX();
if (i == wn.getId())
{
return (int) wn.getHash();
}
}
int getRelativeY();
return -1;
}
String getText();
public Widget getChild(int index)
{
net.runelite.rs.api.Widget[] widgets = widget.getChildren();
void setText(String text);
if (widgets == null || widgets[index] == null)
{
return null;
}
int getTextColor();
return new Widget(client, widgets[index]);
}
String getName();
public Widget[] getDynamicChildren()
{
net.runelite.rs.api.Widget[] children = widget.getChildren();
int getModelId();
if (children == null)
{
return new Widget[0];
}
int getSpriteId();
return Arrays.stream(children)
.filter(Objects::nonNull)
.filter(w -> w.getParentId() == getId())
.map(w -> new Widget(client, w))
.toArray(Widget[]::new);
}
boolean isHidden();
public Widget[] getStaticChildren()
{
return Arrays.stream(client.getGroup(TO_GROUP(getId())))
.filter(Objects::nonNull)
.filter(w -> w.getParentId() == getId())
.toArray(Widget[]::new);
}
Point getCanvasLocation();
public Widget[] getNestedChildren()
{
XHashTable componentTable = client.getComponentTable();
int group = -1;
int getWidth();
// XXX can actually use hashtable lookup instead of table
// iteration here...
for (Node node : componentTable.getNodes())
{
WidgetNode wn = (WidgetNode) node;
int getHeight();
if (wn.getHash() == getId())
{
group = wn.getId();
break;
}
}
Rectangle getBounds();
if (group == -1)
{
return new Widget[0];
}
Collection<WidgetItem> getWidgetItems();
return Arrays.stream(client.getGroup(group))
.filter(w -> w.getParentId() == getId())
.toArray(Widget[]::new);
}
WidgetItem getWidgetItem(int index);
private int getRelativeX()
{
return widget.getRelativeX();
}
int getItemId();
private int getRelativeY()
{
return widget.getRelativeY();
}
public String getText()
{
return widget.getText().replace('\u00A0', ' ');
}
public void setText(String text)
{
widget.setText(text);
}
public int getTextColor()
{
return widget.getTextColor();
}
public String getName()
{
return widget.getName().replace('\u00A0', ' ');
}
public int getModelId()
{
return widget.getModelId();
}
public int getSpriteId()
{
return widget.getSpriteId();
}
public boolean isHidden()
{
Widget parent = getParent();
return (parent != null && parent.isHidden()) || widget.isHidden();
}
public Point getCanvasLocation()
{
int x = 0;
int y = 0;
Widget cur;
for (cur = this; cur.getParent() != null; cur = cur.getParent())
{
x += cur.getRelativeX();
y += cur.getRelativeY();
x -= cur.widget.getScrollX();
y -= cur.widget.getScrollY();
}
// cur is now the root
int[] widgetBoundsWidth = client.getWidgetPositionsX();
int[] widgetBoundsHeight = client.getWidgetPositionsY();
int boundsIndex = cur.widget.getBoundsIndex();
if (boundsIndex != -1)
{
x += widgetBoundsWidth[boundsIndex];
y += widgetBoundsHeight[boundsIndex];
if (cur.getType() > 0)
{
x += cur.getRelativeX();
y += cur.getRelativeY();
}
}
else
{
x += cur.getRelativeX();
y += cur.getRelativeY();
}
return new Point(x, y);
}
public int getWidth()
{
return widget.getWidth();
}
public int getHeight()
{
return widget.getHeight();
}
public Rectangle getBounds()
{
Point canvasLocation = getCanvasLocation();
return new Rectangle(canvasLocation.getX(), canvasLocation.getY(), getWidth(), getHeight());
}
public Collection<WidgetItem> getWidgetItems()
{
int[] itemIds = widget.getItemIds();
if (itemIds == null)
{
return null;
}
List<WidgetItem> items = new ArrayList<>(itemIds.length);
for (int i = 0; i < itemIds.length; ++i)
{
WidgetItem item = getWidgetItem(i);
if (item != null)
{
items.add(item);
}
}
return items;
}
public WidgetItem getWidgetItem(int index)
{
int[] itemIds = widget.getItemIds();
int[] itemQuantities = widget.getItemQuantities();
if (itemIds == null || itemQuantities == null)
{
return null;
}
int columns = getWidth(); // the number of item slot columns is stored here
int paddingX = getPaddingX();
int paddingY = getPaddingY();
int itemId = itemIds[index];
int itemQuantity = itemQuantities[index];
Point widgetCanvasLocation = getCanvasLocation();
if (itemId <= 0 || itemQuantity <= 0 || columns <= 0)
{
return null;
}
int row = index / columns;
int col = index % columns;
int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + paddingX) * col);
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + paddingY) * row);
Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
return new WidgetItem(itemId - 1, itemQuantity, index, bounds);
}
private int getPaddingX()
{
return widget.getPaddingX();
}
private int getPaddingY()
{
return widget.getPaddingY();
}
public int getItemId()
{
return widget.getItemId();
}
public int getItemQuantity()
{
return widget.getItemQuantity();
}
int getItemQuantity();
}

View File

@@ -87,7 +87,13 @@
</dependency>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>client</artifactId>
<artifactId>api</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>injected-client</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
@@ -148,13 +154,16 @@
<shadedClassifierName>shaded</shadedClassifierName>
<filters>
<!--
Do not filter anything under net.runelite.
net.runelite.rs:client gets automatically filtered otherwise because it is runtime scoped
and only accessed with reflection.
-->
<!-- include runtime apis -->
<filter>
<artifact>net.runelite.*:*</artifact>
<!-- net.runelite:injected-client and net.runelite:api -->
<artifact>net.runelite:*</artifact>
<includes>
<include>**</include>
</includes>
</filter>
<filter>
<artifact>net.runelite.rs:api</artifact>
<includes>
<include>**</include>
</includes>

View File

@@ -52,6 +52,7 @@ import javax.swing.UnsupportedLookAndFeelException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import net.runelite.api.Client;
import net.runelite.api.Query;
import net.runelite.client.account.AccountSession;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.events.SessionClose;
@@ -428,4 +429,9 @@ public class RuneLite
{
return infoBoxManager;
}
public <T> T[] runQuery(Query query)
{
return (T[]) query.result(client);
}
}

View File

@@ -27,7 +27,9 @@ package net.runelite.client.callback;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import net.runelite.api.ChatMessageType;
import net.runelite.api.MainBufferProvider;
import net.runelite.api.MenuAction;
import net.runelite.api.MessageNode;
import net.runelite.api.Skill;
import net.runelite.client.RuneLite;
import net.runelite.client.events.*;
@@ -35,8 +37,6 @@ import net.runelite.client.game.DeathChecker;
import net.runelite.client.task.Scheduler;
import net.runelite.client.ui.overlay.OverlayRenderer;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.rs.api.MainBufferProvider;
import net.runelite.rs.api.MessageNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -205,7 +205,7 @@ public class Hooks
// Hook is fired prior to actually setting these on the MessageNode, so send them
// in the event too.
SetMessage setMessage = new SetMessage();
setMessage.setMessageNode(new net.runelite.api.MessageNode(messageNode));
setMessage.setMessageNode(messageNode);
setMessage.setType(ChatMessageType.of(type));
setMessage.setName(name);
setMessage.setSender(sender);

View File

@@ -119,7 +119,7 @@ public class MenuManager
client.getPlayerOptions()[playerOptionIndex] = menuText;
client.getPlayerOptionsPriorities()[playerOptionIndex] = true;
client.getPlayerMenuType()[playerOptionIndex] = MenuAction.RUNELITE.getId();
client.getPlayerMenuTypes()[playerOptionIndex] = MenuAction.RUNELITE.getId();
playerMenuIndexMap.put(playerOptionIndex, menuText);
}

View File

@@ -33,6 +33,7 @@ import java.util.concurrent.ScheduledExecutorService;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.ItemComposition;
import net.runelite.api.MessageNode;
import net.runelite.client.RuneLite;
import net.runelite.client.events.SetMessage;
@@ -46,7 +47,6 @@ import net.runelite.http.api.item.Item;
import net.runelite.http.api.item.ItemClient;
import net.runelite.http.api.item.ItemPrice;
import net.runelite.http.api.item.SearchResult;
import net.runelite.rs.api.ItemComposition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -31,11 +31,11 @@ import java.time.Duration;
import java.time.Instant;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.ItemComposition;
import net.runelite.client.RuneLite;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.rs.api.ItemComposition;
public class ClueScrollOverlay extends Overlay
{

View File

@@ -123,7 +123,7 @@ public class DevToolsOverlay extends Overlay
private void renderPlayers(Graphics2D graphics)
{
Player[] players = client.getPlayers();
Player[] players = client.getCachedPlayers();
Player local = client.getLocalPlayer();
if (players != null && (players.length - 1) > 0)
@@ -148,7 +148,7 @@ public class DevToolsOverlay extends Overlay
private void renderNpcs(Graphics2D graphics)
{
NPC[] npcs = client.getNpcs();
NPC[] npcs = client.getCachedNPCs();
if (npcs != null && (npcs.length - 1) > 0)
{
for (NPC npc : npcs)

View File

@@ -53,8 +53,9 @@ class FishingSpotOverlay extends Overlay
private final List<Integer> ids = new ArrayList<>();
private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient();
private final FishingConfig config;
private final static Client client = RuneLite.getClient();
public FishingSpotOverlay(FishingPlugin plugin)
{
@@ -72,7 +73,7 @@ class FishingSpotOverlay extends Overlay
NPCQuery query = new NPCQuery()
.idEquals(Ints.toArray(ids));
NPC[] npcs = client.runQuery(query);
NPC[] npcs = runelite.runQuery(query);
for (NPC npc : npcs)
{

View File

@@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.ItemLayer;
import net.runelite.api.Node;
import net.runelite.api.Player;
@@ -53,7 +54,6 @@ import net.runelite.client.RuneLite;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.http.api.item.ItemPrice;
import net.runelite.rs.api.ItemComposition;
public class GroundItemsOverlay extends Overlay
{

View File

@@ -54,11 +54,12 @@ public class ImplingsOverlay extends Overlay
private static final int STATIC_SPAWN = 1618;
private static final int DYNAMIC_SPAWN = 1633;
private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient();
private final ImplingsConfig config;
private final List<Integer> ids;
private final Client client = RuneLite.getClient();
public ImplingsOverlay(Implings plugin)
{
super(OverlayPosition.DYNAMIC);
@@ -75,7 +76,7 @@ public class ImplingsOverlay extends Overlay
}
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids));
NPC[] implings = client.runQuery(implingQuery);
NPC[] implings = runelite.runQuery(implingQuery);
for (NPC imp : implings)
{
//Spawns have the name "null", so they get changed to "Spawn"

View File

@@ -66,7 +66,7 @@ class MouseHighlightOverlay extends Overlay
String[] targets = client.getMenuTargets();
String[] options = client.getMenuOptions();
int count = client.getMenuCount() - 1;
int count = client.getMenuOptionCount() - 1;
if (count < 0 || count >= targets.length || count >= options.length)
{

View File

@@ -54,7 +54,9 @@ public class PestControlOverlay extends Overlay
{
private static final Logger logger = LoggerFactory.getLogger(PestControlOverlay.class);
private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient();
private final PestControl plugin;
// Pest control game
@@ -107,7 +109,7 @@ public class PestControlOverlay extends Overlay
private void renderSpinners(Graphics2D graphics)
{
Query query = new NPCQuery().nameEquals("Spinner");
NPC[] result = client.runQuery(query);
NPC[] result = runelite.runQuery(query);
Arrays.stream(result).forEach(npc -> OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN));
}
@@ -266,4 +268,4 @@ public class PestControlOverlay extends Overlay
{
return widget.getText().trim().equals("0");
}
}
}

View File

@@ -93,7 +93,7 @@ public class XpGlobesOverlay extends Overlay
}
//check the width of the client if we can draw properly
int clientWidth = client.isResized() ? client.getClientWidth() : client.getViewportHeight();
int clientWidth = client.isResized() ? client.getCanvas().getWidth() : client.getViewportHeight();
if (clientWidth <= 0)
{
return null;

View File

@@ -51,6 +51,7 @@ public class Zulrah extends Plugin
{
private static final Logger logger = LoggerFactory.getLogger(Zulrah.class);
private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient();
private final StatusOverlay overlay = new StatusOverlay(this);
@@ -171,7 +172,7 @@ public class Zulrah extends Plugin
private NPC findZulrah()
{
Query query = new NPCQuery().nameEquals("Zulrah");
NPC[] result = client.runQuery(query);
NPC[] result = runelite.runQuery(query);
return result.length == 1 ? result[0] : null;
}

View File

@@ -84,13 +84,14 @@ final class ClientPanel extends JPanel
return;
}
if (!(rs instanceof net.runelite.rs.api.Client))
if (!(rs instanceof Client))
{
logger.error("Injected client does not implement Client!");
System.exit(-1);
}
Client client = new Client((net.runelite.rs.api.Client) rs);
Client client = (Client) rs;
RuneLite.setClient(client);
// This causes the whole game frame to be redrawn each frame instead

View File

@@ -52,8 +52,8 @@ public class TopDownRendererRight implements Renderer
overlays.sort((o1, o2) -> o2.getPriority().compareTo(o1.getPriority()));
int y = BORDER_TOP;
int clientWidth = client.getClientWidth();
int clientHeight = client.getClientHeight();
int clientWidth = client.getCanvas().getWidth();
int clientHeight = client.getCanvas().getHeight();
for (Overlay overlay : overlays)
{

63
runelite-mixins/pom.xml Normal file
View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.3-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>mixins</artifactId>
<name>Runelite Mixins</name>
<dependencies>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<!-- RuneScape classes do not verify
under Java 7+ due to the obfuscation
-->
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Inject
{
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Repeatable(Mixins.class)
public @interface Mixin
{
/**
* Class to inject this mixin into
*
* @return
*/
Class<?> value();
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Mixins
{
Mixin[] value();
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api.mixins;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Shadow
{
String value();
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import net.runelite.api.Actor;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSActor;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSCombatInfo1;
import net.runelite.rs.api.RSCombatInfo2;
import net.runelite.rs.api.RSCombatInfoList;
import net.runelite.rs.api.RSCombatInfoListHolder;
import net.runelite.rs.api.RSNode;
@Mixin(RSActor.class)
public abstract class RSActorMixin implements RSActor
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public Actor getInteracting()
{
int i = getRSInteracting();
if (i == -1)
{
return null;
}
if (i < 0x8000)
{
return client.getNpc(i);
}
i -= 0x8000;
return client.getPlayer(i);
}
@Inject
@Override
public int getHealthRatio()
{
RSCombatInfoList combatInfoList = getCombatInfoList();
if (combatInfoList != null)
{
RSNode node = combatInfoList.getNode();
RSNode next = node.getNext();
if (next instanceof RSCombatInfoListHolder)
{
RSCombatInfoListHolder combatInfoListWrapper = (RSCombatInfoListHolder) next;
RSCombatInfoList combatInfoList1 = combatInfoListWrapper.getCombatInfo1();
RSNode node2 = combatInfoList1.getNode();
RSNode next2 = node2.getNext();
if (next2 instanceof RSCombatInfo1)
{
RSCombatInfo1 combatInfo = (RSCombatInfo1) next2;
return combatInfo.getHealthRatio();
}
}
}
return -1;
}
@Inject
@Override
public int getHealth()
{
RSCombatInfoList combatInfoList = getCombatInfoList();
if (combatInfoList != null)
{
RSNode node = combatInfoList.getNode();
RSNode next = node.getNext();
if (next instanceof RSCombatInfoListHolder)
{
RSCombatInfoListHolder combatInfoListWrapper = (RSCombatInfoListHolder) next;
RSCombatInfo2 cf = combatInfoListWrapper.getCombatInfo2();
return cf.getHealthScale();
}
}
return -1;
}
@Inject
@Override
public Point getLocalLocation()
{
return new Point(getX(), getY());
}
@Inject
@Override
public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}
@Inject
@Override
public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}
@Inject
@Override
public Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset)
{
return Perspective.getCanvasImageLocation(client, graphics, getLocalLocation(), image, zOffset);
}
@Inject
@Override
public Point getMinimapLocation()
{
return Perspective.worldToMiniMap(client, getX(), getY());
}
}

View File

@@ -0,0 +1,225 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.GameState;
import net.runelite.api.NPC;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
import net.runelite.api.Skill;
import net.runelite.api.Varbits;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSWidget;
@Mixin(RSClient.class)
public abstract class RSClientMixin implements RSClient
{
@Inject
@Override
public Player getPlayer(int idx)
{
return getCachedPlayers()[idx];
}
@Inject
@Override
public NPC getNpc(int idx)
{
return getCachedNPCs()[idx];
}
@Inject
@Override
public int getBoostedSkillLevel(Skill skill)
{
int[] boostedLevels = getBoostedSkillLevels();
return boostedLevels[skill.ordinal()];
}
@Inject
@Override
public int getRealSkillLevel(Skill skill)
{
int[] realLevels = getRealSkillLevels();
return realLevels[skill.ordinal()];
}
@Inject
@Override
public void sendGameMessage(String message)
{
sendGameMessage(99, "", message);
}
@Inject
@Override
public GameState getGameState()
{
return GameState.of(getRSGameState());
}
@Inject
@Override
public Point getMouseCanvasPosition()
{
return new Point(getMouseX(), getMouseY());
}
@Inject
@Override
public Widget[] getWidgetRoots()
{
int topGroup = getWidgetRoot();
List<Widget> widgets = new ArrayList<Widget>();
for (Widget widget : getWidgets()[topGroup])
{
if (widget != null && widget.getParentId() == -1)
{
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
@Inject
@Override
public Widget getWidget(WidgetInfo widget)
{
int groupId = widget.getGroupId();
int childId = widget.getChildId();
return getWidget(groupId, childId);
}
@Inject
@Override
public Widget[] getGroup(int groupId)
{
RSWidget[][] widgets = getWidgets();
if (widgets == null || groupId < 0 || groupId >= widgets.length)
{
return null;
}
List<Widget> w = new ArrayList<Widget>();
for (Widget widget : widgets[groupId])
{
if (widget != null)
{
w.add(widget);
}
}
return w.toArray(new Widget[w.size()]);
}
@Inject
@Override
public Widget getWidget(int groupId, int childId)
{
RSWidget[][] widgets = getWidgets();
if (widgets == null || widgets.length <= groupId)
{
return null;
}
RSWidget[] childWidgets = widgets[groupId];
if (childWidgets == null || childWidgets.length <= childId)
{
return null;
}
return childWidgets[childId];
}
@Inject
@Override
public int getSetting(Varbits varbit)
{
int[] settings = getSettings();
int value = settings[varbit.getIndex()];
return varbit.get(value);
}
@Inject
@Override
public boolean isPrayerActive(Prayer prayer)
{
return getSetting(prayer.getVarbit()) == 1;
}
/**
* Returns the local player's current experience in the specified
* {@link Skill}.
*
* @param skill the {@link Skill} to retrieve the experience for
* @return the local player's current experience in the specified
* {@link Skill}, or -1 if the {@link Skill} isn't valid
*/
@Inject
@Override
public int getSkillExperience(Skill skill)
{
int[] experiences = getSkillExperiences();
if (skill == Skill.OVERALL)
{
int totalExperience = 0;
for (int experience : experiences)
{
totalExperience += experience;
}
return totalExperience;
}
int idx = skill.ordinal();
// I'm not certain exactly how needed this is, but if the Skill enum is updated in the future
// to hold something else that's not reported it'll save us from an ArrayIndexOutOfBoundsException.
if (idx >= experiences.length)
{
return -1;
}
return experiences[idx];
}
@Inject
@Override
public void refreshChat()
{
setChatCycle(getCycleCntr());
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.awt.Polygon;
import net.runelite.api.Model;
import net.runelite.api.Renderable;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSDecorativeObject;
@Mixin(RSDecorativeObject.class)
public abstract class RSDecorativeObjectMixin implements RSDecorativeObject
{
@Inject
@Override
public Polygon getConvexHull()
{
Renderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
Model model;
if (renderable instanceof Model)
{
model = (Model) renderable;
}
else
{
model = renderable.getModel();
}
if (model == null)
{
return null;
}
return getConvexHull(model, getOrientation());
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.awt.Polygon;
import net.runelite.api.Model;
import net.runelite.api.Renderable;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSGameObject;
@Mixin(RSGameObject.class)
public abstract class RSGameObjectMixin implements RSGameObject
{
@Inject
@Override
public Polygon getConvexHull()
{
Renderable renderable = getRenderable();
if (renderable == null)
{
return null;
}
Model model;
if (renderable instanceof Model)
{
model = (Model) renderable;
}
else
{
model = renderable.getModel();
}
if (model == null)
{
return null;
}
return getConvexHull(model, getOrientation());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,36 +22,37 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;
package net.runelite.mixins;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.runelite.api.Node;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSHashTable;
import net.runelite.rs.api.RSNode;
public class XHashTable
@Mixin(RSHashTable.class)
public abstract class RSHashTableMixin implements RSHashTable
{
private final net.runelite.rs.api.XHashTable hashtable;
public XHashTable(net.runelite.rs.api.XHashTable hashtable)
{
this.hashtable = hashtable;
}
@Inject
@Override
public Collection<Node> getNodes()
{
List<Node> nodes = new ArrayList<>();
List<Node> nodes = new ArrayList<Node>();
net.runelite.rs.api.Node[] buckets = hashtable.getBuckets();
RSNode[] buckets = getBuckets();
for (int i = 0; i < buckets.length; ++i)
{
net.runelite.rs.api.Node node = buckets[i];
Node node = buckets[i];
// It looks like the first node in the bucket is always
// a sentinel
net.runelite.rs.api.Node cur = node.getNext();
Node cur = node.getNext();
while (cur != node)
{
nodes.add(Node.of(cur));
nodes.add(cur);
cur = cur.getNext();
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import net.runelite.api.ChatMessageType;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSMessageNode;
@Mixin(RSMessageNode.class)
public abstract class RSMessageNodeMixin implements RSMessageNode
{
@Inject
@Override
public ChatMessageType getType()
{
return ChatMessageType.of(getRSType());
}
}

View File

@@ -0,0 +1,88 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSModel;
@Mixin(RSModel.class)
public abstract class RSModelMixin implements RSModel
{
@Override
@Inject
public List<Vertex> getVertices()
{
int[] verticesX = getVerticesX();
int[] verticesY = getVerticesY();
int[] verticesZ = getVerticesZ();
List<Vertex> vertices = new ArrayList<Vertex>();
for (int i = 0; i < verticesX.length; ++i)
{
Vertex v = new Vertex(
verticesX[i],
verticesY[i],
verticesZ[i]
);
vertices.add(v);
}
return vertices;
}
@Override
@Inject
public List<Triangle> getTriangles()
{
int[] trianglesX = getTrianglesX();
int[] trianglesY = getTrianglesY();
int[] trianglesZ = getTrianglesZ();
List<Vertex> vertices = getVertices();
List<Triangle> triangles = new ArrayList<Triangle>(trianglesX.length);
for (int i = 0; i < trianglesX.length; ++i)
{
int triangleX = trianglesX[i];
int triangleY = trianglesY[i];
int triangleZ = trianglesZ[i];
Triangle triangle = new Triangle(
vertices.get(triangleX),
vertices.get(triangleY),
vertices.get(triangleZ)
);
triangles.add(triangle);
}
return triangles;
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSNPC;
@Mixin(RSNPC.class)
public abstract class RSNPCMixin implements RSNPC
{
@Inject
@Override
public int getId()
{
return getComposition().getId();
}
@Inject
@Override
public String getName()
{
return getComposition().getName().replace('\u00A0', ' ');
}
@Inject
@Override
public int getCombatLevel()
{
return getComposition().getCombatLevel();
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import net.runelite.api.kit.KitType;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSPlayerComposition;
@Mixin(RSPlayerComposition.class)
public abstract class RSPlayerCompositionMixin implements RSPlayerComposition
{
@Inject
@Override
public int getEquipmentId(KitType type)
{
int id = getEquipmentIds()[type.getIndex()];
if (id < 512)
{
return -1; // not an item
}
return id - 512;
}
@Inject
@Override
public int getKitId(KitType type)
{
int id = getEquipmentIds()[type.getIndex()];
if (id < 256 || id >= 512)
{
return -1; // not a kit
}
return id - 256;
}
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSPlayer;
@Mixin(RSPlayer.class)
public abstract class RSPlayerMixin implements RSPlayer
{
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public String getName()
{
return getRSName().replace('\u00A0', ' ');
}
@Inject
@Override
public Polygon[] getPolygons()
{
Model model = getModel();
if (model == null)
{
return null;
}
int localX = getX();
int localY = getY();
// models are orientated north (1024) and there are 2048 angles total
int orientation = (getOrientation() + 1024) % 2048;
List<Triangle> triangles = model.getTriangles();
if (orientation != 0)
{
triangles = rotate(triangles, orientation);
}
List<Polygon> polys = new ArrayList<Polygon>();
for (Triangle triangle : triangles)
{
Vertex vx = triangle.getA();
Vertex vy = triangle.getB();
Vertex vz = triangle.getC();
Point x = Perspective.worldToCanvas(client,
localX - vx.getX(),
localY - vx.getZ(),
-vx.getY());
Point y = Perspective.worldToCanvas(client,
localX - vy.getX(),
localY - vy.getZ(),
-vy.getY());
Point z = Perspective.worldToCanvas(client,
localX - vz.getX(),
localY - vz.getZ(),
-vz.getY());
int xx[] =
{
x.getX(), y.getX(), z.getX()
};
int yy[] =
{
x.getY(), y.getY(), z.getY()
};
polys.add(new Polygon(xx, yy, 3));
}
return polys.toArray(new Polygon[polys.size()]);
}
@Inject
private List<Triangle> rotate(List<Triangle> triangles, int orientation)
{
List<Triangle> rotatedTriangles = new ArrayList<Triangle>();
for (Triangle triangle : triangles)
{
Vertex a = triangle.getA();
Vertex b = triangle.getB();
Vertex c = triangle.getC();
Triangle rotatedTriangle = new Triangle(
a.rotate(orientation),
b.rotate(orientation),
c.rotate(orientation)
);
rotatedTriangles.add(rotatedTriangle);
}
return rotatedTriangles;
}
}

View File

@@ -0,0 +1,310 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.runelite.api.Node;
import net.runelite.api.Point;
import net.runelite.api.WidgetNode;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSHashTable;
import net.runelite.rs.api.RSWidget;
@Mixin(RSWidget.class)
public abstract class RSWidgetMixin implements RSWidget
{
private static final int ITEM_SLOT_SIZE = 32;
@Shadow("clientInstance")
private static RSClient client;
@Inject
@Override
public Widget getParent()
{
int id = getParentId();
if (id == -1)
{
return null;
}
return client.getWidget(TO_GROUP(id), TO_CHILD(id));
}
@Inject
@Override
public int getParentId()
{
int parentId = getRSParentId();
if (parentId != -1)
{
return parentId;
}
int i = TO_GROUP(getId());
RSHashTable componentTable = client.getComponentTable();
for (Node node : componentTable.getNodes())
{
WidgetNode wn = (WidgetNode) node;
if (i == wn.getId())
{
return (int) wn.getHash();
}
}
return -1;
}
@Inject
@Override
public String getText()
{
return getRSText().replace('\u00A0', ' ');
}
@Inject
@Override
public String getName()
{
return getRSName().replace('\u00A0', ' ');
}
@Inject
@Override
public boolean isHidden()
{
Widget parent = getParent();
return (parent != null && parent.isHidden()) || isRSHidden();
}
@Inject
@Override
public Point getCanvasLocation()
{
int x = 0;
int y = 0;
RSWidget cur;
for (cur = this; cur.getParent() != null; cur = (RSWidget) cur.getParent())
{
x += cur.getRelativeX();
y += cur.getRelativeY();
x -= cur.getScrollX();
y -= cur.getScrollY();
}
// cur is now the root
int[] widgetBoundsWidth = client.getWidgetPositionsX();
int[] widgetBoundsHeight = client.getWidgetPositionsY();
int boundsIndex = cur.getBoundsIndex();
if (boundsIndex != -1)
{
x += widgetBoundsWidth[boundsIndex];
y += widgetBoundsHeight[boundsIndex];
if (cur.getType() > 0)
{
x += cur.getRelativeX();
y += cur.getRelativeY();
}
}
else
{
x += cur.getRelativeX();
y += cur.getRelativeY();
}
return new Point(x, y);
}
@Inject
@Override
public Rectangle getBounds()
{
Point canvasLocation = getCanvasLocation();
return new Rectangle(canvasLocation.getX(), canvasLocation.getY(), getWidth(), getHeight());
}
@Inject
@Override
public Collection<WidgetItem> getWidgetItems()
{
int[] itemIds = getItemIds();
if (itemIds == null)
{
return null;
}
List<WidgetItem> items = new ArrayList<WidgetItem>(itemIds.length);
for (int i = 0; i < itemIds.length; ++i)
{
WidgetItem item = getWidgetItem(i);
if (item != null)
{
items.add(item);
}
}
return items;
}
@Inject
@Override
public WidgetItem getWidgetItem(int index)
{
int[] itemIds = getItemIds();
int[] itemQuantities = getItemQuantities();
if (itemIds == null || itemQuantities == null)
{
return null;
}
int columns = getWidth(); // the number of item slot columns is stored here
int paddingX = getPaddingX();
int paddingY = getPaddingY();
int itemId = itemIds[index];
int itemQuantity = itemQuantities[index];
Point widgetCanvasLocation = getCanvasLocation();
if (itemId <= 0 || itemQuantity <= 0 || columns <= 0)
{
return null;
}
int row = index / columns;
int col = index % columns;
int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + paddingX) * col);
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + paddingY) * row);
Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
return new WidgetItem(itemId - 1, itemQuantity, index, bounds);
}
@Inject
@Override
public Widget getChild(int index)
{
RSWidget[] widgets = getChildren();
if (widgets == null || widgets[index] == null)
{
return null;
}
return widgets[index];
}
@Inject
@Override
public Widget[] getDynamicChildren()
{
RSWidget[] children = getChildren();
if (children == null)
{
return new Widget[0];
}
List<Widget> widgets = new ArrayList<Widget>();
for (Widget widget : children)
{
if (widget != null && widget.getParentId() == getId())
{
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
@Inject
@Override
public Widget[] getStaticChildren()
{
List<Widget> widgets = new ArrayList<Widget>();
for (Widget widget : client.getGroup(TO_GROUP(getId())))
{
if (widget != null && widget.getParentId() == getId())
{
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
@Inject
@Override
public Widget[] getNestedChildren()
{
RSHashTable componentTable = client.getComponentTable();
int group = -1;
// XXX can actually use hashtable lookup instead of table
// iteration here...
for (Node node : componentTable.getNodes())
{
WidgetNode wn = (WidgetNode) node;
if (wn.getHash() == getId())
{
group = wn.getId();
break;
}
}
if (group == -1)
{
return new Widget[0];
}
List<Widget> widgets = new ArrayList<Widget>();
for (Widget widget : client.getGroup(group))
{
if (widget != null && widget.getParentId() == getId())
{
widgets.add(widget);
}
}
return widgets.toArray(new Widget[widgets.size()]);
}
}

View File

@@ -0,0 +1,165 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.TileObject;
import net.runelite.api.model.Jarvis;
import net.runelite.api.model.Vertex;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Mixins;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSDecorativeObject;
import net.runelite.rs.api.RSGameObject;
import net.runelite.rs.api.RSGroundObject;
import net.runelite.rs.api.RSItemLayer;
import net.runelite.rs.api.RSWallObject;
@Mixins({
@Mixin(RSDecorativeObject.class),
@Mixin(RSGameObject.class),
@Mixin(RSGroundObject.class),
@Mixin(RSItemLayer.class),
@Mixin(RSWallObject.class)
})
public abstract class TileObjectMixin implements TileObject
{
@Shadow("clientInstance")
private static RSClient client;
@Override
@Inject
public int getId()
{
int hash = getHash();
return hash >> 14 & 32767;
}
@Override
@Inject
public Point getWorldLocation()
{
Point localLocation = getLocalLocation();
return Perspective.localToWorld(client, localLocation);
}
@Override
@Inject
public Point getLocalLocation()
{
return new Point(getX(), getY());
}
@Override
@Inject
public Point getCanvasLocation()
{
Point locaLocation = getLocalLocation();
return Perspective.worldToCanvas(client, locaLocation.getX(), locaLocation.getY(), 0);
}
@Override
@Inject
public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}
@Override
@Inject
public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}
@Override
@Inject
public Point getMinimapLocation()
{
return Perspective.worldToMiniMap(client, getX(), getY());
}
@Override
@Inject
public Polygon getConvexHull(Model model, int orientation)
{
int localX = getX();
int localY = getY();
// models are orientated north (1024) and there are 2048 angles total
orientation = (orientation + 1024) % 2048;
List<Vertex> verticies = model.getVertices();
if (orientation != 0)
{
// rotate verticies
for (int i = 0; i < verticies.size(); ++i)
{
Vertex v = verticies.get(i);
verticies.set(i, v.rotate(orientation));
}
}
List<Point> points = new ArrayList<Point>();
for (Vertex v : verticies)
{
// Compute canvas location of vertex
Point p = Perspective.worldToCanvas(client,
localX - v.getX(),
localY - v.getZ(),
-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;
}
}

View File

@@ -35,4 +35,12 @@
<groupId>net.runelite.rs</groupId>
<artifactId>api</artifactId>
<name>RuneScape API</name>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;
@@ -31,7 +30,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@Target(
{
ElementType.FIELD, ElementType.METHOD
})
public @interface Export
{
String value();

View File

@@ -30,7 +30,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@Target(
{
ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR
})
public @interface Hook
{
String value();

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;
@@ -31,7 +30,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@Target(
{
ElementType.FIELD, ElementType.METHOD
})
public @interface Import
{
String value();

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;
@@ -35,6 +34,6 @@ import java.lang.annotation.Target;
public @interface ObfuscatedGetter
{
int intValue() default 0;
long longValue() default 0L;
}

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;
@@ -31,7 +30,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Target(
{
ElementType.FIELD, ElementType.METHOD, ElementType.TYPE
})
public @interface ObfuscatedName
{
String value();

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;

View File

@@ -30,7 +30,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
@Target(
{
ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD
})
public @interface ObfuscatedSignature
{
String signature();

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mapping;
import java.lang.annotation.ElementType;

View File

@@ -22,15 +22,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.api.Actor;
import net.runelite.mapping.Import;
public interface Actor extends Renderable
public interface RSActor extends RSRenderable, Actor
{
@Import("interacting")
int getInteracting();
int getRSInteracting();
@Import("inSequence")
boolean inSequence();
@@ -45,14 +45,17 @@ public interface Actor extends Renderable
int getY();
@Import("animation")
@Override
int getAnimation();
@Import("graphic")
@Override
int getGraphic();
@Import("combatInfoList")
CombatInfoList getCombatInfoList();
RSCombatInfoList getCombatInfoList();
@Import("orientation")
@Override
int getOrientation();
}

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface Buffer
public interface RSBuffer
{
@Import("payload")
byte[] getPayload();

View File

@@ -22,16 +22,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface CacheableNode
public interface RSCacheableNode
{
@Import("next")
CacheableNode getNext();
RSCacheableNode getNext();
@Import("previous")
CacheableNode getPrevious();
RSCacheableNode getPrevious();
}

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
public interface RSCanvas

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface XClanMember
public interface RSClanMember
{
@Import("username")
String getUsernameName();

View File

@@ -22,14 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import net.runelite.mapping.Import;
public interface ClassInfo
public interface RSClassInfo
{
@Import("methods")
Method[] getMethods();

View File

@@ -24,47 +24,60 @@
*/
package net.runelite.rs.api;
import net.runelite.api.Client;
import net.runelite.mapping.Import;
public interface Client extends GameEngine
public interface RSClient extends RSGameEngine, Client
{
@Import("cameraX")
@Override
int getCameraX();
@Import("cameraY")
@Override
int getCameraY();
@Import("cameraZ")
@Override
int getCameraZ();
@Import("plane")
@Override
int getPlane();
@Import("cameraPitch")
@Override
int getCameraPitch();
@Import("cameraYaw")
@Override
int getCameraYaw();
@Import("world")
int getWorld();
@Import("FPS")
@Override
int getFPS();
@Import("mapAngle")
@Override
int getMapAngle();
@Import("tileHeights")
@Override
int[][][] getTileHeights();
@Import("tileSettings")
@Override
byte[][][] getTileSettings();
@Import("settings")
@Override
int[] getSettings();
@Import("widgetSettings")
@Override
int[] getWidgetSettings();
@Import("energy")
@@ -74,9 +87,11 @@ public interface Client extends GameEngine
int getWeight();
@Import("baseX")
@Override
int getBaseX();
@Import("baseY")
@Override
int getBaseY();
@Import("boostedSkillLevels")
@@ -89,48 +104,59 @@ public interface Client extends GameEngine
int[] getSkillExperiences();
@Import("gameState")
int getGameState();
int getRSGameState();
@Import("widgets")
Widget[][] getWidgets();
RSWidget[][] getWidgets();
@Import("region")
Region getRegion();
@Override
RSRegion getRegion();
@Import("localPlayer")
Player getLocalPlayer();
@Override
RSPlayer getLocalPlayer();
@Import("cachedNPCs")
NPC[] getCachedNPCs();
@Override
RSNPC[] getCachedNPCs();
@Import("collisionMaps")
CollisionData[] getCollisionMaps();
RSCollisionData[] getCollisionMaps();
@Import("cachedPlayers")
Player[] getCachedPlayers();
@Override
RSPlayer[] getCachedPlayers();
@Import("groundItemDeque")
Deque[][][] getGroundItemDeque();
RSDeque[][][] getGroundItemDeque();
@Import("username")
@Override
String getUsername();
@Import(value = "username", setter = true)
@Override
void setUsername(String username);
@Import("playerOptions")
@Override
String[] getPlayerOptions();
@Import("playerOptionsPriorities")
@Override
boolean[] getPlayerOptionsPriorities();
@Import("playerMenuTypes")
@Override
int[] getPlayerMenuTypes();
@Import("menuTargets")
@Override
String[] getMenuTargets();
@Import("menuOptions")
@Override
String[] getMenuOptions();
@Import("mouseX")
@@ -149,57 +175,67 @@ public interface Client extends GameEngine
int[] getMenuIdentifiers();
@Import("friends")
Friend[] getFriends();
RSFriend[] getFriends();
@Import("ignores")
Ignore[] getIgnores();
RSIgnore[] getIgnores();
@Import("worldList")
World[] getWorldList();
RSWorld[] getWorldList();
@Import("sendGameMessage")
void sendGameMessage(int var1, String var2, String var3);
@Import("getObjectDefinition")
ObjectComposition getObjectDefinition(int objectId);
RSObjectComposition getObjectDefinition(int objectId);
@Import("scale")
@Override
int getScale();
@Import("viewportHeight")
@Override
int getViewportHeight();
@Import("viewportWidth")
@Override
int getViewportWidth();
@Import("isResized")
@Override
boolean isResized();
@Import("widgetPositionX")
@Override
int[] getWidgetPositionsX();
@Import("widgetPositionY")
@Override
int[] getWidgetPositionsY();
@Import("itemContainers")
XHashTable getItemContainers();
RSHashTable getItemContainers();
@Import("getItemDefinition")
ItemComposition getItemDefinition(int itemId);
@Override
RSItemComposition getItemDefinition(int itemId);
@Import("componentTable")
XHashTable getComponentTable();
@Override
RSHashTable getComponentTable();
@Import("grandExchangeOffers")
XGrandExchangeOffer[] getGrandExchangeOffers();
RSGrandExchangeOffer[] getGrandExchangeOffers();
@Import("clanChatCount")
@Override
int getClanChatCount();
@Import("clanMembers")
XClanMember[] getClanMembers();
RSClanMember[] getClanMembers();
@Import("isMenuOpen")
@Override
boolean isMenuOpen();
@Import("gameCycle")
@@ -209,21 +245,26 @@ public interface Client extends GameEngine
void packetHandler();
@Import("revision")
@Override
int getRevision();
@Import("mapRegions")
@Override
int[] getMapRegions();
@Import("xteaKeys")
@Override
int[][] getXteaKeys();
@Import("gameDrawingMode")
@Override
int getGameDrawingMode();
@Import(
value = "gameDrawingMode",
setter = true
)
@Override
void setGameDrawingMode(int gameDrawingMode);
@Import("cycleCntr")
@@ -235,6 +276,7 @@ public interface Client extends GameEngine
/**
* Get the widget top group. widgets[topGroup] contains widgets with
* parentId -1, which are the widget roots.
*
* @return
*/
@Import("widgetRoot")

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface CollisionData
public interface RSCollisionData
{
@Import("flags")
int[][] getFlags();

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface CombatInfo1
public interface RSCombatInfo1
{
@Import("healthRatio")
int getHealthRatio();

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface CombatInfo2
public interface RSCombatInfo2
{
@Import("healthScale")
int getHealthScale();

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
@@ -30,8 +29,8 @@ import net.runelite.mapping.Import;
/**
* Created by bold on 2/2/17.
*/
public interface CombatInfoList
public interface RSCombatInfoList
{
@Import("node")
Node getNode();
RSNode getNode();
}

View File

@@ -22,16 +22,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface CombatInfoListHolder extends Node
public interface RSCombatInfoListHolder extends RSNode
{
@Import("combatInfo1")
CombatInfoList getCombatInfo1();
RSCombatInfoList getCombatInfo1();
@Import("combatInfo2")
CombatInfo2 getCombatInfo2();
RSCombatInfo2 getCombatInfo2();
}

View File

@@ -24,11 +24,14 @@
*/
package net.runelite.rs.api;
import net.runelite.api.DecorativeObject;
import net.runelite.api.Renderable;
import net.runelite.mapping.Import;
public interface DecorativeObject
public interface RSDecorativeObject extends DecorativeObject
{
@Import("hash")
@Override
int getHash();
@Import("x")

View File

@@ -22,16 +22,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface Deque
public interface RSDeque
{
@Import("current")
Node getCurrent();
RSNode getCurrent();
@Import("head")
Node getHead();
RSNode getHead();
}

View File

@@ -22,13 +22,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import java.io.RandomAccessFile;
import net.runelite.mapping.Import;
public interface FileOnDisk
public interface RSFileOnDisk
{
@Import("file")
RandomAccessFile getFile();

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface Friend
public interface RSFriend
{
@Import("name")
String getName();

View File

@@ -27,7 +27,7 @@ package net.runelite.rs.api;
import java.awt.Canvas;
import net.runelite.mapping.Import;
public interface GameEngine
public interface RSGameEngine
{
@Import("canvas")
Canvas getCanvas();

View File

@@ -22,12 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.api.GameObject;
import net.runelite.api.Renderable;
import net.runelite.mapping.Import;
public interface GameObject
public interface RSGameObject extends GameObject
{
@Import("renderable")
Renderable getRenderable();
@@ -48,9 +49,11 @@ public interface GameObject
int getOffsetY();
@Import("x")
@Override
int getX();
@Import("y")
@Override
int getY();
@Import("height")
@@ -60,6 +63,7 @@ public interface GameObject
int getOrientation();
@Import("hash")
@Override
int getHash();
@Import("flags")

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface XGrandExchangeOffer
public interface RSGrandExchangeOffer
{
@Import("quantitySold")
int getQuantitySold();

View File

@@ -24,11 +24,13 @@
*/
package net.runelite.rs.api;
import net.runelite.api.GroundObject;
import net.runelite.mapping.Import;
public interface GroundObject
public interface RSGroundObject extends GroundObject
{
@Import("hash")
@Override
int getHash();
@Import("x")

View File

@@ -22,16 +22,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.api.HashTable;
import net.runelite.mapping.Import;
public interface XHashTable
public interface RSHashTable extends HashTable
{
@Import("size")
int getSize();
@Import("buckets")
Node[] getBuckets();
RSNode[] getBuckets();
}

View File

@@ -22,12 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
import net.runelite.mapping.Import;
public interface Ignore
public interface RSIgnore
{
@Import("name")
String getName();

Some files were not shown because too many files have changed in this diff Show More