use of com.adamki11s.pathing.PathingResult in project CyanBot by XjCyan1de.
the class MoveTask method runPathing.
public void runPathing(final Location start, final Location end, final int range) {
try {
// create our pathfinder
AStar path = new AStar(bot.getWorld(), start, end, range);
// get the list of nodes to walk to as a Tile object
ArrayList<Tile> route = path.iterate();
// get the result of the path trace
PathingResult result = path.getPathingResult();
switch(result) {
case SUCCESS:
// Path was successful. Do something here.
moveAlong(start, route);
System.out.println("Path was found! :D");
break;
case NO_PATH:
// No path found, throw error.
System.out.println("No path found!");
// c.chat.sendMessage("No path was found :(");
break;
default:
// c.chat.sendMessage("Well... appearently we didn't find a path and we did... at the same time");
break;
}
} catch (AStar.InvalidPathException e) {
// InvalidPathException will be thrown if start or end block is air
if (e.isEndNotSolid()) {
// System.out.println("End block is not walkable");
// c.chat.sendMessage("Unable to walk on the block you are standing on.");
}
if (e.isStartNotSolid()) {
System.out.println("Start block is not walkable");
}
}
}
Aggregations