use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class VarbitMixin method getSetting.
@Inject
@Override
public int getSetting(Varbits varbit) {
int varbitId = varbit.getId();
RSVarbit v = varbitCache.getIfPresent(varbitId);
if (v == null) {
// load varbit into cache
client.getVarbit(varbitId);
RSNodeCache varbits = client.getVarbitCache();
// get from cache
v = (RSVarbit) varbits.get(varbitId);
varbitCache.put(varbitId, v);
}
int[] varps = getVarps();
int value = varps[v.getIndex()];
int lsb = v.getLeastSignificantBit();
int msb = v.getMostSignificantBit();
int mask = (1 << ((msb - lsb) + 1)) - 1;
return (value >> lsb) & mask;
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSItemContainerMixin method getItems.
@Inject
@Override
public Item[] getItems() {
int[] itemIds = getItemIds();
int[] stackSizes = getStackSizes();
Item[] items = new Item[itemIds.length];
for (int i = 0; i < itemIds.length; ++i) {
RSItem item = client.createItem();
item.setId(itemIds[i]);
item.setQuantity(stackSizes[i]);
items[i] = item;
}
return items;
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSDecorativeObjectMixin method getModel.
@Inject
private RSModel getModel() {
RSRenderable renderable = getRenderable();
if (renderable == null) {
return null;
}
RSModel model;
if (renderable instanceof Model) {
model = (RSModel) renderable;
} else {
model = renderable.getModel();
}
return model;
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSHashTableMixin method getNodes.
@Inject
@Override
public Collection<Node> getNodes() {
// Copied in RSWidgetMixin.getParentId to reduce allocations
List<Node> nodes = new ArrayList<Node>();
RSNode[] buckets = getBuckets();
for (int i = 0; i < buckets.length; ++i) {
Node node = buckets[i];
// It looks like the first node in the bucket is always
// a sentinel
Node cur = node.getNext();
while (cur != node) {
nodes.add(cur);
cur = cur.getNext();
}
}
return nodes;
}
use of net.runelite.api.mixins.Inject in project runelite by runelite.
the class RSModelMixin method getConvexHull.
@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation) {
List<Vertex> vertices = getVertices();
// rotate vertices
for (int i = 0; i < vertices.size(); ++i) {
Vertex v = vertices.get(i);
vertices.set(i, v.rotate(orientation));
}
List<Point> points = new ArrayList<Point>();
for (Vertex v : vertices) {
// Compute canvas location of vertex
Point p = Perspective.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;
}
Aggregations