feat(mover): inform when goal reached

cover
jay 3 years ago
parent b519913355
commit 3d5ffe38cd
  1. 19
      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 }
Loading…
Cancel
Save