feat(mover): implement moving to X Z goal (without y)

cover
jay 3 years ago
parent b1dab1968c
commit b519913355
  1. 4
      lib/plugins/command.js
  2. 15
      lib/plugins/mover.js

@ -240,8 +240,8 @@ function command(username, message) {
} }
break break
case 2: case 2:
todo() //TODO this isn't near
// bot.lookAt({}) goalxz? cfg.plugins.mover.moveXZ(message_parts2)
break break
case 3: case 3:
//TODO more checks //TODO more checks

@ -37,6 +37,19 @@ function moveNear(pos, distance = 3) {
bot.pathfinder.setGoal(new GoalNear(pos.x, pos.y, pos.z, distance)) 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) { function follow(entity, dynamic = true, distance = 3) {
console.assert(entity) console.assert(entity)
const { GoalFollow } = require('mineflayer-pathfinder').goals const { GoalFollow } = require('mineflayer-pathfinder').goals
@ -88,4 +101,4 @@ const unload = () => {
stop() stop()
} }
module.exports = { load, unload, stop, initMoves, moveNear, follow } module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, follow }
Loading…
Cancel
Save