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

This commit is contained in:
jay 2021-01-15 00:36:17 +05:00
parent b1dab1968c
commit b519913355
2 changed files with 16 additions and 3 deletions

View File

@ -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

View File

@ -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 }