-
Notifications
You must be signed in to change notification settings - Fork 0
/
wolf_tamer.js
82 lines (65 loc) · 2.5 KB
/
wolf_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
74
75
76
77
78
79
80
81
82
const mineflayer = require('mineflayer')
const {pathfinder,Movements,goals} = require("mineflayer-pathfinder");
const bot = mineflayer.createBot({
host: 'localhost',
username: 'Tamer',
//password: '12345678',
port: 53622,
version: "1.17.1",
// auth: 'mojang'
})
bot.loadPlugin(pathfinder);
bot.on('chat' ,(username, message) => {
if(message === "check"){
const filter = e => e.mobType === 'Wolf' && e.position.distanceTo(bot.entity.position) < 16
const entity = bot.nearestEntity(filter)
console.log(entity)
}
if(message === "tame"){
const bone = bot.inventory.items().find(item => item.name.includes('bone'))
if(!bone) {
bot.chat('Der Bot hat keine Knochen')
return;
}
if(bone) bot.equip(bone, 'hand')
const filter = e => e.mobType === 'Wolf' && 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 Wolf')
bot.activateEntity(entity)
})
bot.activateEntity(entity)
console.log("taming")
}
bot.on('entityTaming', (tame) => {
setTimeout(function () {
const filter = e => e.mobType === 'Wolf' && 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 Wolf')
bot.activateEntity(entity)
})
},500)
})
bot.on('entityTamed', (tame) => {
bot.chat('Wolf gezähmt')
})
})
bot.on('kicked', console.log)
bot.on('error', console.log)