diff --git a/lib/plugins/command.js b/lib/plugins/command.js index aa25f3e..f04bb41 100644 --- a/lib/plugins/command.js +++ b/lib/plugins/command.js @@ -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") } diff --git a/lib/plugins/mover.js b/lib/plugins/mover.js index 854bb7c..d131b79 100644 --- a/lib/plugins/mover.js +++ b/lib/plugins/mover.js @@ -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 } \ No newline at end of file +module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, moveY, follow } \ No newline at end of file