A library to help your mineflayer bot navigate around the 3D world using the A* algorithm.
var mineflayer = ;var navigatePlugin = mineflayer;var bot = mineflayer;// install the plugin;// optional configurationbotnavigateblocksToAvoid132 = true; // avoid tripwirebotnavigateblocksToAvoid59 = false; // ok to trample cropsbotnavigate;botnavigate;botnavigate;botnavigate;bot;
Finds a path to the specified location and goes there.
point- the block you want your feet to be standing on
bot.navigate when a partial path is found.
path is an array
bot.navigate when a complete path is found.
path is an array
Emitted when a path cannot be found.
vec3instance - the closest point that you could navigate to.
Emitted when the destination is reached.
Emitted when navigation has been aborted.
Aborts an in progress navigation job.
Finds a path to
end. Can be used to see if it is possible to navigate to a
Returns an object that looks like:
status: 'success' // one of ['success', 'noPath', 'timeout', 'tooFar']path: startPoint point1 point2 ... endPoint
The value of
status has several meanings:
pathis an array of points that can be passed to
noPath- there is no path to
end. Try a larger
pathis the path to the closest reachable point to end.
timeout- no path could be found in the allotted time. Try a larger
pathis the path to the closest reachable point to end that could be found in the allotted time.
endis too far away, so
pathcontains the path to walk 100 meters in the general direction of
end- the block you want your feet to be standing on
options- optional parameters which come with sensible defaults
isEnd- function(node) - passed on to the A* library.
node.pointis a vec3 instance.
endRadius- used for default
isEnd. Effectively defaults to 0.
timeout- passed on to the A* library. Default 10 seconds.
endis greater than
tooFarThreshold, this function will search instead for a path to walk 100 meters in the general direction of end.
Note: does not emit events
Walks the bot along the path and calls the callback function when it has arrived.
bot.navigate.stop() to interrupt walking.
path- array of points to be navigated.
callback(stopReason)- (optional) - called when the bot has arrived.
stopReasoncan be: ['obstructed', 'arrived', 'interrupted']
arrivedtwice. (thanks Benjamin Grosse)
stopReasonwhen it happens.
bot.navigate.stop()is called elsewhere. Also it now has a
endRadiustoo low (thanks vogonistic)
cannotFindevent now has
closestPointparameter, the closest point it could get to
bot.navigate.blocksToAvoidis a map of block id to boolean value which tells whether to avoid the block. comes with sensible defaults like avoiding fire and crops.