diff --git a/lib/plugins/mover.js b/lib/plugins/mover.js index ce95992..9c40b01 100644 --- a/lib/plugins/mover.js +++ b/lib/plugins/mover.js @@ -73,6 +73,23 @@ function hit(blockOrEntity) { bot.chat(`hitting ${entity.name || entity.type}`) } +function goalReached(goal) { + console.log(goal) + const entity = goal?.entity + let entityInfo = "" + if (entity) { + entityInfo += entity.type + ": " + switch (entity.type) { + case "player": + entityInfo += entity.username + break; + default: + break; + } + } + cfg.quiet || bot.chat(`goal reached: ${entityInfo}; pos: [x:${goal?.x}, y:${goal?.y}, z:${goal?.z}]`) +} + function stop() { bot.pathfinder.setGoal(null) bot.stopDigging() @@ -94,11 +111,13 @@ const load = (config) => { // initMoves(bot, mcData) setTimeout(initMoves, 500, bot, mcData) + bot.on('goal_reached', goalReached) } const unload = () => { stop() + bot.off('goal_reached', goalReached) } module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, follow } \ No newline at end of file