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 - http-service - Service for api.runelite.net
- model-viewer - RS Model, NPC/Object, and terrain viewer - model-viewer - RS Model, NPC/Object, and terrain viewer
- runelite-api - runelite api, use this for plugin development - runelite-api - runelite api, use this for plugin development
- runescape-api - mappings correspond to these interfaces, runelite-api wraps this - runelite-mixins - Mixins which are injected into the injected client's classes
- runescape-client-injector - builds the injection from the vanilla client and the mappings - 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 - runescape-client - decompiled RuneScape client, contains mappings
## Usage ## Usage

View File

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

View File

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

View File

@@ -27,172 +27,34 @@ package net.runelite.api;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.image.BufferedImage; 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; String getName();
private net.runelite.rs.api.Actor actor;
public Actor(Client client, net.runelite.rs.api.Actor actor) Actor getInteracting();
{
super(actor);
this.client = client; int getHealthRatio();
this.actor = actor;
}
@Override int getHealth();
public int hashCode()
{
int hash = 5;
hash = 47 * hash + Objects.hashCode(this.client);
return hash;
}
@Override Point getLocalLocation();
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;
}
public abstract int getCombatLevel(); int getOrientation();
public abstract String getName(); int getAnimation();
public Actor getInteracting() int getGraphic();
{
int i = actor.getInteracting();
if (i == -1)
{
return null;
}
if (i < 0x8000) int getModelHeight();
{
return client.getNpc(i);
}
i -= 0x8000; Polygon getCanvasTilePoly();
return client.getPlayer(i);
}
public int getHealthRatio() Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset);
{
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();
Node node2 = combatInfoList1.getNode(); Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset);
Node next2 = node2.getNext();
if (next2 instanceof CombatInfo1)
{
CombatInfo1 combatInfo = (CombatInfo1) next2;
return combatInfo.getHealthRatio();
}
}
}
return -1;
}
public int getHealth() Point getMinimapLocation();
{
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());
}
} }

View File

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

View File

@@ -31,63 +31,7 @@ import java.awt.Polygon;
* *
* @author Adam * @author Adam
*/ */
public class DecorativeObject extends TileObject public interface DecorativeObject extends TileObject
{ {
private final net.runelite.rs.api.DecorativeObject decorativeObject; Polygon getConvexHull();
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());
}
} }

View File

@@ -30,63 +30,7 @@ import java.awt.Polygon;
* *
* @author Adam * @author Adam
*/ */
public class GameObject extends TileObject public interface GameObject extends TileObject
{ {
private final net.runelite.rs.api.GameObject gameObject; Polygon getConvexHull();
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());
}
} }

View File

@@ -24,31 +24,6 @@
*/ */
package net.runelite.api; 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; 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) int getQuantity();
{
super(item);
this.item = item;
}
public int getId()
{
return item.getId();
}
public int getQuantity()
{
return item.getQuantity();
}
} }

View File

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

View File

@@ -24,46 +24,11 @@
*/ */
package net.runelite.api; 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) Renderable getMiddle();
{
super(client);
this.itemLayer = itemLayer;
}
@Override Renderable getTop();
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());
}
} }

View File

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

View File

@@ -24,32 +24,13 @@
*/ */
package net.runelite.api; 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) String getSender();
{
this.messageNode = messageNode;
}
public ChatMessageType getType() String getValue();
{
return ChatMessageType.of(messageNode.getType());
}
public String getSender() void setValue(String value);
{
return messageNode.getSender();
}
public String getValue()
{
return messageNode.getValue();
}
public void setValue(String value)
{
messageNode.setValue(value);
}
} }

View File

@@ -24,71 +24,13 @@
*/ */
package net.runelite.api; package net.runelite.api;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.runelite.api.model.Triangle; import net.runelite.api.model.Triangle;
import net.runelite.api.model.Vertex; 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) List<Triangle> getTriangles();
{
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;
}
} }

View File

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

View File

@@ -24,58 +24,11 @@
*/ */
package net.runelite.api; 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) Node getPrevious();
{
this.node = node;
}
@Override long getHash();
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);
}
} }

View File

@@ -156,7 +156,7 @@ public class Perspective
int xx = y * sin + cos * x >> 16; int xx = y * sin + cos * x >> 16;
int yy = sin * x - y * cos >> 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; x = (miniMapX + 167 / 2) + xx;
y = (167 / 2 - 1) + yy; y = (167 / 2 - 1) + yy;

View File

@@ -25,115 +25,13 @@
package net.runelite.api; package net.runelite.api;
import java.awt.Polygon; 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 @Override
public String getName() int getCombatLevel();
{
return player.getName().replace('\u00A0', ' '); PlayerComposition getPlayerComposition();
}
Polygon[] getPolygons();
@Override
public int getCombatLevel()
{
return player.getCombatLevel();
}
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;
}
} }

View File

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

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) 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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -24,27 +24,7 @@
*/ */
package net.runelite.api; package net.runelite.api;
import java.util.Arrays; public interface Region
public class Region
{ {
private final Client client; Tile[][][] getTiles();
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);
}
} }

View File

@@ -24,34 +24,7 @@
*/ */
package net.runelite.api; package net.runelite.api;
public class Renderable extends Node public interface Renderable extends Node
{ {
private final net.runelite.rs.api.Renderable renderable; Model getModel();
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);
}
} }

View File

@@ -24,83 +24,20 @@
*/ */
package net.runelite.api; package net.runelite.api;
import java.util.Arrays; public interface Tile
public class 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. * Get the decorative object for this tile.
* *
* @return * @return
*/ */
public DecorativeObject getDecorativeObject() DecorativeObject getDecorativeObject();
{
net.runelite.rs.api.DecorativeObject decorativeObject = tile.getDecorativeObject();
if (decorativeObject == null) GameObject[] getGameObjects();
{
return null; ItemLayer getItemLayer();
}
GroundObject getGroundObject();
return new DecorativeObject(client, decorativeObject);
} WallObject getWallObject();
public GameObject[] getGameObjects()
{
net.runelite.rs.api.GameObject[] objects = tile.getObjects();
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);
}
} }

View File

@@ -26,113 +26,28 @@ package net.runelite.api;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; 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) int getX();
{
this.client = client; int getY();
}
int getId();
protected abstract int getHash();
Point getWorldLocation();
protected abstract int getLocalX();
Point getLocalLocation();
protected abstract int getLocalY();
Point getCanvasLocation();
public int getId()
{ Polygon getCanvasTilePoly();
int hash = getHash();
return hash >> 14 & 32767; Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset);
}
Point getMinimapLocation();
public Point getWorldLocation()
{ Polygon getConvexHull(Model model, int orientation);
Point localLocation = getLocalLocation();
return Perspective.localToWorld(client, localLocation);
}
public Point getLocalLocation()
{
return new Point(getLocalX(), getLocalY());
}
public Point getCanvasLocation()
{
Point locaLocation = getLocalLocation();
return Perspective.worldToCanvas(client, locaLocation.getX(), locaLocation.getY(), 0);
}
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 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;
}
} }

View File

@@ -29,31 +29,6 @@ package net.runelite.api;
* *
* @author Adam * @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; package net.runelite.api;
public class WidgetNode extends Node public interface WidgetNode extends Node
{ {
private final net.runelite.rs.api.WidgetNode widgetNode; int getId();
public WidgetNode(net.runelite.rs.api.WidgetNode widgetNode)
{
super(widgetNode);
this.widgetNode = widgetNode;
}
public int getId()
{
return widgetNode.getId();
}
} }

View File

@@ -35,7 +35,7 @@ import java.util.Objects;
public class DecorativeObjectQuery extends TileObjectQuery<DecorativeObject, DecorativeObjectQuery> public class DecorativeObjectQuery extends TileObjectQuery<DecorativeObject, DecorativeObjectQuery>
{ {
@Override @Override
protected DecorativeObject[] result(Client client) public DecorativeObject[] result(Client client)
{ {
return getDecorativeObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(DecorativeObject[]::new); 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> public class GameObjectQuery extends TileObjectQuery<GameObject, GameObjectQuery>
{ {
@Override @Override
protected GameObject[] result(Client client) public GameObject[] result(Client client)
{ {
return getGameObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(GameObject[]::new); 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> public class GroundObjectQuery extends TileObjectQuery<GroundObject, GroundObjectQuery>
{ {
@Override @Override
protected GroundObject[] result(Client client) public GroundObject[] result(Client client)
{ {
return getGroundObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(GroundObject[]::new); 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> public class NPCQuery extends ActorQuery<NPC, NPCQuery>
{ {
@Override @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(Objects::nonNull)
.filter(predicate) .filter(predicate)
.toArray(NPC[]::new); .toArray(NPC[]::new);

View File

@@ -33,9 +33,9 @@ import java.util.Objects;
public class PlayerQuery extends ActorQuery<Player, PlayerQuery> public class PlayerQuery extends ActorQuery<Player, PlayerQuery>
{ {
@Override @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(Objects::nonNull)
.filter(predicate) .filter(predicate)
.toArray(Player[]::new); .toArray(Player[]::new);

View File

@@ -35,7 +35,7 @@ import java.util.Objects;
public class WallObjectQuery extends TileObjectQuery<WallObject, WallObjectQuery> public class WallObjectQuery extends TileObjectQuery<WallObject, WallObjectQuery>
{ {
@Override @Override
protected WallObject[] result(Client client) public WallObject[] result(Client client)
{ {
return getWallObjects(client).stream().filter(Objects::nonNull).filter(predicate).toArray(WallObject[]::new); 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 @Override
protected WidgetItem[] result(Client client) public WidgetItem[] result(Client client)
{ {
Widget widget = client.getWidget(widgetInfo); Widget widget = client.getWidget(widgetInfo);
if (widget != null) if (widget != null)

View File

@@ -25,320 +25,60 @@
package net.runelite.api.widgets; package net.runelite.api.widgets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; 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.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; int getType();
private final net.runelite.rs.api.Widget widget;
public Widget(Client client, net.runelite.rs.api.Widget widget) int getContentType();
{
this.client = client; Widget getParent();
this.widget = widget;
} int getParentId();
public int getId() Widget getChild(int index);
{
return widget.getId(); Widget[] getDynamicChildren();
}
Widget[] getStaticChildren();
public int getType()
{ Widget[] getNestedChildren();
return widget.getType();
} int getRelativeX();
public int getContentType() int getRelativeY();
{
return widget.getContentType(); String getText();
}
void setText(String text);
public Widget getParent()
{ int getTextColor();
int id = getParentId();
if (id == -1) String getName();
{
return null; int getModelId();
}
int getSpriteId();
return client.getWidget(TO_GROUP(id), TO_CHILD(id));
} boolean isHidden();
public int getParentId() Point getCanvasLocation();
{
int parentId = widget.getParentId(); int getWidth();
if (parentId != -1)
{ int getHeight();
return parentId;
} Rectangle getBounds();
int i = TO_GROUP(getId()); Collection<WidgetItem> getWidgetItems();
XHashTable componentTable = client.getComponentTable();
for (Node node : componentTable.getNodes()) WidgetItem getWidgetItem(int index);
{
WidgetNode wn = (WidgetNode) node; int getItemId();
if (i == wn.getId()) int getItemQuantity();
{
return (int) wn.getHash();
}
}
return -1;
}
public Widget getChild(int index)
{
net.runelite.rs.api.Widget[] widgets = widget.getChildren();
if (widgets == null || widgets[index] == null)
{
return null;
}
return new Widget(client, widgets[index]);
}
public Widget[] getDynamicChildren()
{
net.runelite.rs.api.Widget[] children = widget.getChildren();
if (children == null)
{
return new Widget[0];
}
return Arrays.stream(children)
.filter(Objects::nonNull)
.filter(w -> w.getParentId() == getId())
.map(w -> new Widget(client, w))
.toArray(Widget[]::new);
}
public Widget[] getStaticChildren()
{
return Arrays.stream(client.getGroup(TO_GROUP(getId())))
.filter(Objects::nonNull)
.filter(w -> w.getParentId() == getId())
.toArray(Widget[]::new);
}
public Widget[] getNestedChildren()
{
XHashTable 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];
}
return Arrays.stream(client.getGroup(group))
.filter(w -> w.getParentId() == getId())
.toArray(Widget[]::new);
}
private int getRelativeX()
{
return widget.getRelativeX();
}
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();
}
} }

View File

@@ -87,7 +87,13 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.runelite.rs</groupId> <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> <version>${project.version}</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
@@ -148,13 +154,16 @@
<shadedClassifierName>shaded</shadedClassifierName> <shadedClassifierName>shaded</shadedClassifierName>
<filters> <filters>
<!-- <!-- include runtime apis -->
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.
-->
<filter> <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> <includes>
<include>**</include> <include>**</include>
</includes> </includes>

View File

@@ -52,6 +52,7 @@ import javax.swing.UnsupportedLookAndFeelException;
import joptsimple.OptionParser; import joptsimple.OptionParser;
import joptsimple.OptionSet; import joptsimple.OptionSet;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Query;
import net.runelite.client.account.AccountSession; import net.runelite.client.account.AccountSession;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.events.SessionClose; import net.runelite.client.events.SessionClose;
@@ -428,4 +429,9 @@ public class RuneLite
{ {
return infoBoxManager; 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.Graphics;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.MainBufferProvider;
import net.runelite.api.MenuAction; import net.runelite.api.MenuAction;
import net.runelite.api.MessageNode;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import net.runelite.client.events.*; 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.task.Scheduler;
import net.runelite.client.ui.overlay.OverlayRenderer; import net.runelite.client.ui.overlay.OverlayRenderer;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager; 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.Logger;
import org.slf4j.LoggerFactory; 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 // Hook is fired prior to actually setting these on the MessageNode, so send them
// in the event too. // in the event too.
SetMessage setMessage = new SetMessage(); SetMessage setMessage = new SetMessage();
setMessage.setMessageNode(new net.runelite.api.MessageNode(messageNode)); setMessage.setMessageNode(messageNode);
setMessage.setType(ChatMessageType.of(type)); setMessage.setType(ChatMessageType.of(type));
setMessage.setName(name); setMessage.setName(name);
setMessage.setSender(sender); setMessage.setSender(sender);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Item; import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.ItemLayer; import net.runelite.api.ItemLayer;
import net.runelite.api.Node; import net.runelite.api.Node;
import net.runelite.api.Player; 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.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.http.api.item.ItemPrice; import net.runelite.http.api.item.ItemPrice;
import net.runelite.rs.api.ItemComposition;
public class GroundItemsOverlay extends Overlay 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 STATIC_SPAWN = 1618;
private static final int DYNAMIC_SPAWN = 1633; 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 ImplingsConfig config;
private final List<Integer> ids; private final List<Integer> ids;
private final Client client = RuneLite.getClient();
public ImplingsOverlay(Implings plugin) public ImplingsOverlay(Implings plugin)
{ {
super(OverlayPosition.DYNAMIC); super(OverlayPosition.DYNAMIC);
@@ -75,7 +76,7 @@ public class ImplingsOverlay extends Overlay
} }
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids)); NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids));
NPC[] implings = client.runQuery(implingQuery); NPC[] implings = runelite.runQuery(implingQuery);
for (NPC imp : implings) for (NPC imp : implings)
{ {
//Spawns have the name "null", so they get changed to "Spawn" //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[] targets = client.getMenuTargets();
String[] options = client.getMenuOptions(); String[] options = client.getMenuOptions();
int count = client.getMenuCount() - 1; int count = client.getMenuOptionCount() - 1;
if (count < 0 || count >= targets.length || count >= options.length) 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 static final Logger logger = LoggerFactory.getLogger(PestControlOverlay.class);
private final RuneLite runelite = RuneLite.getRunelite();
private final Client client = RuneLite.getClient(); private final Client client = RuneLite.getClient();
private final PestControl plugin; private final PestControl plugin;
// Pest control game // Pest control game
@@ -107,7 +109,7 @@ public class PestControlOverlay extends Overlay
private void renderSpinners(Graphics2D graphics) private void renderSpinners(Graphics2D graphics)
{ {
Query query = new NPCQuery().nameEquals("Spinner"); 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)); Arrays.stream(result).forEach(npc -> OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN));
} }

View File

@@ -93,7 +93,7 @@ public class XpGlobesOverlay extends Overlay
} }
//check the width of the client if we can draw properly //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) if (clientWidth <= 0)
{ {
return null; return null;

View File

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

View File

@@ -84,13 +84,14 @@ final class ClientPanel extends JPanel
return; return;
} }
if (!(rs instanceof net.runelite.rs.api.Client)) if (!(rs instanceof Client))
{ {
logger.error("Injected client does not implement Client!"); logger.error("Injected client does not implement Client!");
System.exit(-1); System.exit(-1);
} }
Client client = new Client((net.runelite.rs.api.Client) rs); Client client = (Client) rs;
RuneLite.setClient(client); RuneLite.setClient(client);
// This causes the whole game frame to be redrawn each frame instead // 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())); overlays.sort((o1, o2) -> o2.getPriority().compareTo(o1.getPriority()));
int y = BORDER_TOP; int y = BORDER_TOP;
int clientWidth = client.getClientWidth(); int clientWidth = client.getCanvas().getWidth();
int clientHeight = client.getClientHeight(); int clientHeight = client.getCanvas().getHeight();
for (Overlay overlay : overlays) 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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.api; package net.runelite.mixins;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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; @Inject
@Override
public XHashTable(net.runelite.rs.api.XHashTable hashtable)
{
this.hashtable = hashtable;
}
public Collection<Node> getNodes() 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) 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 // It looks like the first node in the bucket is always
// a sentinel // a sentinel
net.runelite.rs.api.Node cur = node.getNext(); Node cur = node.getNext();
while (cur != node) while (cur != node)
{ {
nodes.add(Node.of(cur)); nodes.add(cur);
cur = cur.getNext(); 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> <groupId>net.runelite.rs</groupId>
<artifactId>api</artifactId> <artifactId>api</artifactId>
<name>RuneScape API</name> <name>RuneScape API</name>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project> </project>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -22,7 +22,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
@@ -30,8 +29,8 @@ import net.runelite.mapping.Import;
/** /**
* Created by bold on 2/2/17. * Created by bold on 2/2/17.
*/ */
public interface CombatInfoList public interface RSCombatInfoList
{ {
@Import("node") @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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
public interface CombatInfoListHolder extends Node public interface RSCombatInfoListHolder extends RSNode
{ {
@Import("combatInfo1") @Import("combatInfo1")
CombatInfoList getCombatInfo1(); RSCombatInfoList getCombatInfo1();
@Import("combatInfo2") @Import("combatInfo2")
CombatInfo2 getCombatInfo2(); RSCombatInfo2 getCombatInfo2();
} }

View File

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

View File

@@ -22,16 +22,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
public interface Deque public interface RSDeque
{ {
@Import("current") @Import("current")
Node getCurrent(); RSNode getCurrent();
@Import("head") @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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
public interface FileOnDisk public interface RSFileOnDisk
{ {
@Import("file") @Import("file")
RandomAccessFile getFile(); RandomAccessFile getFile();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -22,16 +22,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import net.runelite.api.HashTable;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
public interface XHashTable public interface RSHashTable extends HashTable
{ {
@Import("size") @Import("size")
int getSize(); int getSize();
@Import("buckets") @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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.rs.api; package net.runelite.rs.api;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
public interface Ignore public interface RSIgnore
{ {
@Import("name") @Import("name")
String getName(); String getName();

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