diff --git a/lib/plugins/command.js b/lib/plugins/command.js index e6e3f50..eeb107b 100644 --- a/lib/plugins/command.js +++ b/lib/plugins/command.js @@ -240,8 +240,8 @@ function command(username, message) { } break case 2: - todo() - // bot.lookAt({}) goalxz? + //TODO this isn't near + cfg.plugins.mover.moveXZ(message_parts2) break case 3: //TODO more checks diff --git a/lib/plugins/mover.js b/lib/plugins/mover.js index c0c6e2b..ce95992 100644 --- a/lib/plugins/mover.js +++ b/lib/plugins/mover.js @@ -37,6 +37,19 @@ function moveNear(pos, distance = 3) { bot.pathfinder.setGoal(new GoalNear(pos.x, pos.y, pos.z, distance)) } +function moveXZ(pos) { + const { GoalXZ } = require('mineflayer-pathfinder').goals + cfg.quiet || bot.chat(`moving to ${pos}`) + + if (Array.isArray(pos) && pos.length == 2) { + pos = v(pos[0], 0, pos[1]) + } + pos = v(pos) + console.log(pos) + bot.pathfinder.setMovements(movements.defaultMove) + bot.pathfinder.setGoal(new GoalXZ(pos.x, pos.z)) +} + function follow(entity, dynamic = true, distance = 3) { console.assert(entity) const { GoalFollow } = require('mineflayer-pathfinder').goals @@ -88,4 +101,4 @@ const unload = () => { stop() } -module.exports = { load, unload, stop, initMoves, moveNear, follow } \ No newline at end of file +module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, follow } \ No newline at end of file