i meant use filters;
NPC chicken = getNpcs().closest(new Filter<NPC>({
@Override
public boolean match(NPC npc){
return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0;
}
});
Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really.
Much more efficient/cleaner/easy to read & understand