Skip to content

Commit

Permalink
Remove object wrappers and use mixins to inject functionality
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Adam- committed Aug 19, 2017
1 parent 07c8442 commit 5955289
Show file tree
Hide file tree
Showing 124 changed files with 2,257 additions and 1,814 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ If you have any questions please join our IRC channel on [irc.rizon.net #runelit
- http-service - Service for api.runelite.net
- model-viewer - RS Model, NPC/Object, and terrain viewer
- runelite-api - runelite api, use this for plugin development
- runescape-api - mappings correspond to these interfaces, runelite-api wraps this
- runescape-client-injector - builds the injection from the vanilla client and the mappings
- runelite-mixins - Mixins which are injected into the injected client's classes
- runescape-api - mappings correspond to these interfaces, runelite-api is a subset of this
- runescape-client-injector - builds the injected client from the vanilla client and the mappings
- runescape-client - decompiled RuneScape client, contains mappings

## Usage
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<module>model-viewer-rsmv</module>
<module>runelite-api</module>
<module>runelite-client</module>
<module>runelite-mixins</module>
<module>runescape-api</module>
<module>runescape-client</module>
<module>runescape-client-injector</module>
Expand Down
6 changes: 0 additions & 6 deletions runelite-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
<name>Runelite API</name>

<dependencies>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
168 changes: 15 additions & 153 deletions runelite-api/src/main/java/net/runelite/api/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,172 +27,34 @@
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.Objects;
import net.runelite.rs.api.CombatInfo1;
import net.runelite.rs.api.CombatInfo2;
import net.runelite.rs.api.CombatInfoList;
import net.runelite.rs.api.CombatInfoListHolder;
import net.runelite.rs.api.Node;

public abstract class Actor extends Renderable
public interface Actor extends Renderable
{
int getCombatLevel();

private final Client client;
private net.runelite.rs.api.Actor actor;
String getName();

public Actor(Client client, net.runelite.rs.api.Actor actor)
{
super(actor);
Actor getInteracting();

this.client = client;
this.actor = actor;
}
int getHealthRatio();

@Override
public int hashCode()
{
int hash = 5;
hash = 47 * hash + Objects.hashCode(this.client);
return hash;
}
int getHealth();

@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Actor other = (Actor) obj;
if (!Objects.equals(this.client, other.client))
{
return false;
}
return true;
}
Point getLocalLocation();

public abstract int getCombatLevel();
int getOrientation();

public abstract String getName();
int getAnimation();

public Actor getInteracting()
{
int i = actor.getInteracting();
if (i == -1)
{
return null;
}
int getGraphic();

if (i < 0x8000)
{
return client.getNpc(i);
}
int getModelHeight();

i -= 0x8000;
return client.getPlayer(i);
}
Polygon getCanvasTilePoly();

public int getHealthRatio()
{
CombatInfoList combatInfoList = actor.getCombatInfoList();
if (combatInfoList != null)
{
Node node = combatInfoList.getNode();
Node next = node.getNext();
if (next instanceof CombatInfoListHolder)
{
CombatInfoListHolder combatInfoListWrapper = (CombatInfoListHolder) next;
CombatInfoList combatInfoList1 = combatInfoListWrapper.getCombatInfo1();
Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset);

Node node2 = combatInfoList1.getNode();
Node next2 = node2.getNext();
if (next2 instanceof CombatInfo1)
{
CombatInfo1 combatInfo = (CombatInfo1) next2;
return combatInfo.getHealthRatio();
}
}
}
return -1;
}
Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset);

public int getHealth()
{
CombatInfoList combatInfoList = actor.getCombatInfoList();
if (combatInfoList != null)
{
Node node = combatInfoList.getNode();
Node next = node.getNext();
if (next instanceof CombatInfoListHolder)
{
CombatInfoListHolder combatInfoListWrapper = (CombatInfoListHolder) next;
CombatInfo2 cf = combatInfoListWrapper.getCombatInfo2();
return cf.getHealthScale();
}
}
return -1;
}

public Point getLocalLocation()
{
return new Point(getX(), getY());
}

private int getX()
{
return actor.getX();
}

private int getY()
{
return actor.getY();
}

public int getOrientation()
{
return actor.getOrientation();
}

public int getAnimation()
{
return actor.getAnimation();
}

public int getGraphic()
{
return actor.getGraphic();
}

public int getModelHeight()
{
return actor.getModelHeight();
}

public Polygon getCanvasTilePoly()
{
return Perspective.getCanvasTilePoly(client, getLocalLocation());
}

public Point getCanvasTextLocation(Graphics2D graphics, String text, int zOffset)
{
return Perspective.getCanvasTextLocation(client, graphics, getLocalLocation(), text, zOffset);
}

public Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset)
{
return Perspective.getCanvasImageLocation(client, graphics, getLocalLocation(), image, zOffset);
}

public Point getMinimapLocation()
{
return Perspective.worldToMiniMap(client, getX(), getY());
}
Point getMinimapLocation();
}
Loading

0 comments on commit 5955289

Please sign in to comment.