feat(mover): ✨ implement moving to X Z goal (without y)
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 } | ||||
		Reference in New Issue
	
	Block a user