feat(mover): implement moveY (vertical move up or down)

Doesn't appear to be working properly, bot assumes XZ is goal reached
This commit is contained in:
jay 2021-01-17 13:56:18 +05:00
parent 8a39596b1d
commit 7b2b936f81
2 changed files with 18 additions and 1 deletions

View File

@ -209,6 +209,10 @@ function command(username, message) {
case "closer":
subcommand("go follow close")
break
case "up":
case "down":
cfg.plugins.mover.moveY(player.position)
break
default:
subcommand("go follow once")
}

View File

@ -50,6 +50,19 @@ function moveXZ(pos) {
bot.pathfinder.setGoal(new GoalXZ(pos.x, pos.z))
}
function moveY(pos) {
const { GoalY } = require('mineflayer-pathfinder').goals
if (Array.isArray(pos) && pos.length == 1) {
pos = v(null, pos[0], null)
}
pos = v(pos)
console.log(pos)
cfg.quiet || bot.chat(`moving to ${pos.floored()}`)
bot.pathfinder.setMovements(movements.defaultMove)
bot.pathfinder.setGoal(new GoalY(pos.y))
}
function follow(entity, dynamic = true, distance = 3) {
console.assert(entity)
const { GoalFollow } = require('mineflayer-pathfinder').goals
@ -120,4 +133,4 @@ const unload = () => {
bot.off('goal_reached', goalReached)
}
module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, follow }
module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, moveY, follow }