use of org.powerbot.bot.rt6.client.ItemNode in project powerbot by powerbot.
the class GroundItems method get.
protected List<GroundItem> get(int radius) {
if (radius < 1) {
radius = 110;
}
final List<GroundItem> items = new ArrayList<GroundItem>();
final Client client = ctx.client();
if (client == null) {
return items;
}
final HashTable table = client.getItemTable();
if (table.isNull()) {
return items;
}
final int plane = client.getFloor();
long id;
NodeListCache cache;
final Tile base = ctx.game.mapOffset();
final Tile player = ctx.players.local().tile();
if (base == Tile.NIL || player == Tile.NIL || !player.matrix(ctx).valid()) {
return items;
}
final int bx = base.x(), mx = bx + 103, by = base.y(), my = by + 103;
for (int x = Math.max(bx, player.x() - radius); x <= Math.min(mx, player.x() + radius); x++) {
for (int y = Math.max(by, player.y() - radius); y <= Math.min(my, player.y() + radius); y++) {
id = x | y << 14 | plane << 28;
cache = org.powerbot.bot.rt6.HashTable.lookup(table, id, NodeListCache.class);
if (cache.isNull()) {
continue;
}
for (final ItemNode item : NodeQueue.get(cache.getDeque(), ItemNode.class)) {
items.add(new GroundItem(ctx, new Tile(x, y, plane), item));
}
}
}
return items;
}
use of org.powerbot.bot.rt6.client.ItemNode in project powerbot by powerbot.
the class GroundItems method get.
private List<GroundItem> get(int radius, final int floor) {
if (radius < 1) {
radius = 110;
}
final List<GroundItem> r = new CopyOnWriteArrayList<GroundItem>();
final Client client = ctx.client();
final NodeDeque[][][] dequeArray;
if (client == null || (dequeArray = client.getGroundItems()) == null) {
return r;
}
final NodeDeque[][] rows;
if (floor > -1 && floor < dequeArray.length) {
rows = dequeArray[floor];
} else {
rows = null;
}
if (rows == null) {
return r;
}
final List<GroundItem> list = new LinkedList<GroundItem>();
final Tile tile = new Tile(client.getOffsetX(), client.getOffsetY(), floor);
final Tile ct = ctx.players.local().tile().derive(-tile.x(), -tile.y());
for (int x = Math.max(0, ct.x() - radius); x < Math.min(rows.length, ct.x() + radius + 1); x++) {
final NodeDeque[] row = rows[x];
if (row == null) {
continue;
}
for (int y = Math.max(0, ct.y() - radius); y < Math.min(row.length, ct.y() + radius + 1); y++) {
for (final ItemNode n : NodeQueue.get(row[y], ItemNode.class)) {
list.add(new GroundItem(ctx, tile.derive(x, y), n));
}
}
}
return list;
}
Aggregations