use of org.powerbot.bot.rt4.client.Varbit in project powerbot by powerbot.
the class Npc method id.
@Override
public int id() {
final Client client = ctx.client();
if (client == null) {
return -1;
}
final NpcConfig c = npc == null ? new NpcConfig(client.reflector, null) : npc.getConfig();
if (c.isNull()) {
return -1;
}
final int varbit = c.getVarbit(), si = c.getVarpbitIndex();
int index = -1;
if (varbit != -1) {
final Cache cache = client.getVarbitCache();
final Varbit varBit = HashTable.lookup(cache.getTable(), varbit, Varbit.class);
if (!varBit.isNull()) {
final int mask = lookup[varBit.getEndBit() - varBit.getStartBit()];
index = ctx.varpbits.varpbit(varBit.getIndex()) >> varBit.getStartBit() & mask;
}
} else if (si != -1) {
index = ctx.varpbits.varpbit(si);
}
if (index >= 0) {
final int[] configs = c.getConfigs();
if (index < configs.length && configs[index] != -1) {
return configs[index];
}
}
return c.getId();
}
use of org.powerbot.bot.rt4.client.Varbit in project powerbot by powerbot.
the class GameObject method id.
@Override
public int id() {
final Client client = ctx.client();
if (client == null) {
return -1;
}
final int id = object != null ? (object.getUid() >> 14) & 0xffff : -1;
if (object == null) {
return id;
}
int index = -1;
final CacheObjectConfig c = CacheObjectConfig.load(Bot.CACHE_WORKER, id);
if (c == null) {
return id;
}
if (c.stageOperationId != -1) {
final Cache cache = client.getVarbitCache();
final Varbit varBit = new Varbit(object.object.reflector, HashTable.lookup(cache.getTable(), c.stageOperationId, Varbit.class));
if (varBit.obj.get() != null) {
final int mask = lookup[varBit.getEndBit() - varBit.getStartBit()];
index = ctx.varpbits.varpbit(varBit.getIndex()) >> varBit.getStartBit() & mask;
}
} else if (c.stageIndex >= 0) {
index = ctx.varpbits.varpbit(c.stageIndex);
}
if (index >= 0) {
final int[] configs = c.materialPointers;
if (configs != null && index < configs.length && configs[index] != -1) {
return configs[index];
}
}
return id;
}