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
case 2:
todo()
// bot.lookAt({}) goalxz?
//TODO this isn't near
cfg.plugins.mover.moveXZ(message_parts2)
break
case 3:
//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))
}
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 }
module.exports = { load, unload, stop, initMoves, moveNear, moveXZ, follow }