-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmovement.js
More file actions
48 lines (37 loc) · 1.01 KB
/
movement.js
File metadata and controls
48 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder')
const GoalFollow = goals.GoalFollow
let bot
function load(botclass) {
bot = botclass
bot.loadPlugin(pathfinder)
bot.moveTo = moveTo
bot.stopMoving = stopMoving
}
function moveTo(position) {
/*
Pathfinds and move to the given
coordinates, breaking or placing
blocks if needed.
This action can be interrupted
with stopMoving()
*/
if (position) {
const mcData = require('minecraft-data')(bot.version)
const movements = new Movements(bot, mcData)
bot.pathfinder.setMovements(movements)
bot.pathfinder.setGoal(new goals.GoalBlock(position.x, position.y, position.z), false)
}
}
function stopMoving() {
/*
Stops any current movement
actions
*/
const mcData = require('minecraft-data')(bot.version)
const movements = new Movements(bot, mcData)
bot.pathfinder.setMovements(movements)
bot.pathfinder.stop()
}
module.exports = {
load: load,
}