private void GoToMill2() throws InterruptedException {
Position outsideMill = new Position(3166, 3300, 0);
Position insideMill = new Position(3166, 3305, 0);
if (!getMap().canReach(outsideMill)) {
if (getDoorHandler().handleNextObstacle(outsideMill)) {
ConditionalSleep2.sleep(5000, 500, () -> getMap().canReach(outsideMill));
}
} else {
WalkingEvent walk = new WalkingEvent(outsideMill);
execute(walk);
}
// OR
if (!getMap().canReach(outsideMill)) {
RS2Object gate = getObjects().closest(o -> o.getName().equalsIgnoreCase("Gate") && o.hasAction("Open"));
if (gate.interact("Open"))
ConditionalSleep2.sleep(5000, 500, () -> getMap().canReach(outsideMill));
} else {
WalkingEvent walk = new WalkingEvent(outsideMill);
execute(walk);
}
}
Basically the first method, it tries to use the DoorHandler API, which you pass in the position where you want to go to, and it will handle the obstacles, that will not let it reach the position
https://osbot.org/api/org/osbot/rs07/api/DoorHandler.html
The second method, is you handling the obstacle manually(without using the DoorHandler API)
Both should work, but make sure to only keep one of the both methods.