final String dropList[] = {"Logs", "Oak logs", "Willow logs", "Maple logs", "Yew logs", "Magic logs", "Redwood logs"};
final String target_tree = "Maple tree";
final Coordinate coord_player = Players.getLocal().getPosition();
final boolean collect_birds_nest = true;
if (Inventory.isFull()) {
//go through twice in case we miss any logs
//shift drop all the logs...
Keyboard.pressKey(KeyEvent.VK_SHIFT);
for (int i = 0; i < 2; i++) {
SpriteItemQueryResults items = Inventory.getItems(dropList);
for (SpriteItem item: items) {
item.click();
}
}
Keyboard.releaseKey(KeyEvent.VK_SHIFT);
return false;
}
if (collect_birds_nest) {
GroundItem birdNest = GroundItems.newQuery().filter(o-> o.getDefinition() !=null && o.getDefinition().getName().contains("nest")).results().first();
if (birdNest != null) {
birdNest.interact("Take");
return false;
}
}
//get some more logs
GameObject targetTree = GameObjects.newQuery().names(target_tree).actions("Chop down").filter(o-> o.distanceTo(coord_player, Algorithm.EUCLIDEAN) < 4).results().nearest(Algorithm.EUCLIDEAN_SQUARED);
if (targetTree != null) {
if (!targetTree.isVisible()) {
BresenhamPath path = BresenhamPath.buildTo(targetTree.getPosition());
if (path != null) {
path.step();
Execution.delayUntil(()-> Players.getLocal().isMoving(), 750, 1500);
return false;
}
}
//I had a few issues in the past where the target tree was right next to a bank and would try
//to interact with the tree while the interface was still open...
if (com.runemate.game.api.hybrid.local.hud.interfaces.Bank.isOpen())
com.runemate.game.api.hybrid.local.hud.interfaces.Bank.close();
else if (com.runemate.game.api.hybrid.local.hud.interfaces.DepositBox.isOpen())
com.runemate.game.api.hybrid.local.hud.interfaces.DepositBox.close();
//InteractablePoint inter = obj.getInteractionPoint();
boolean res = targetTree.interact("Chop down");
if (!res) {
Camera.turnTo(targetTree);
targetTree.interact("Chop down");
}
Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 750, 1500);
}