Ok so,
when you call:
Entity tree = objects.closest("Tree");
You're getting the closest object which matches the name "Tree" and that only. So you could get a tree which is closest to you, but isn't in the area, and so it won't click it.
The code i posted finds the closest object using a filter and only gets objects which have the name "Tree" AND are in the area you specified.
let me know if i wasn't clear.
Edit:
here is another example of how you can write it, might be easier to understand:
RS2Object tree = getObjects().closest(new Filter<RS2Object>() {
@[member=Override]
public boolean match(RS2Object o) {
if(o != null && o.getName().equals("TREE_NAME") && AREA_HERE.contains(o)) {
return true;
}
return false;
}
});
Precise.