-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhorse_tamer.js
73 lines (56 loc) · 2.2 KB
/
horse_tamer.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const mineflayer = require('mineflayer')
const {pathfinder,Movements,goals} = require("mineflayer-pathfinder");
const bot = mineflayer.createBot({
host: 'localhost',
username: 'Tamer',
//password: '12345678',
port: 56041,
version: "1.17.1",
// auth: 'mojang'
})
bot.loadPlugin(pathfinder);
bot.on('chat' ,(username, message) => {
if(message === "check"){
const filter = e => e.mobType === 'Horse' && e.position.distanceTo(bot.entity.position) < 16
const entity = bot.nearestEntity(filter)
console.log(entity)
}
if(message === "tame"){
const filter = e => e.mobType === 'Horse' && e.position.distanceTo(bot.entity.position) < 16 && !e.metadata[18]
const entity = bot.nearestEntity(filter)
console.log(entity)
if(entity === null) return;
console.log(entity.metadata[17])
const mcData = require("minecraft-data")(bot.version);
const defaultMove = new Movements(bot, mcData);
defaultMove.canDig = true
bot.pathfinder.setMovements(defaultMove);
bot.pathfinder.setGoal(new goals.GoalFollow(entity, 1))
bot.once("goal_reached", () => {
console.log('bin am Pferd')
bot.activateEntity(entity)
})
console.log("taming")
}
bot.on('entityTaming', (tame) => {
const filter = e => e.mobType === 'Horse' && e.position.distanceTo(bot.entity.position) < 16 && !e.metadata[18]
const entity = bot.nearestEntity(filter)
console.log(entity)
if(entity === null) return;
console.log(entity.metadata[17])
const mcData = require("minecraft-data")(bot.version);
const defaultMove = new Movements(bot, mcData);
defaultMove.canDig = true
bot.pathfinder.setMovements(defaultMove);
bot.pathfinder.setGoal(new goals.GoalFollow(entity, 1))
bot.once("goal_reached", () => {
console.log('bin am Pferd')
bot.activateEntity(entity)
})
})
bot.on('entityTamed', (tame) => {
bot.chat('Pferd gezähmt')
})
})
bot.on('kicked', console.log)
bot.on('error', console.log)