-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
77 lines (52 loc) · 1.7 KB
/
index.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
const mineflayer = require('mineflayer')
const pvp = require('mineflayer-pvp').plugin
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder')
const armorManager = require('mineflayer-armor-manager')
const bot = mineflayer.createBot({
host: 'localHost',
port: ,
username: ''
})
bot.loadPlugin(pvp)
bot.loadPlugin(armorManager)
bot.loadPlugin(pathfinder)
bot.on('playerCollect', (collector, itemDrop) => {
if (collector !== bot.entity) return
setTimeout(() => {
const sword = bot.inventory.items().find(item => item.name.includes('sword'))
if (sword) bot.equip(sword, 'hand')
}, 150)
})
bot.on('playerCollect', (collector, itemDrop) => {
if (collector !== bot.entity) return
setTimeout(() => {
const shield = bot.inventory.items().find(item => item.name.includes('shield'))
if (shield) bot.equip(shield, 'off-hand')
}, 250)
})
const entity = bot.nearestPlayer()
if (entity) bot.lookAt(entity.position.offset(0, entity.height, 0))
function defense() {
const filter = e => e.type === 'player' && e.position.distanceTo(bot.entity.position) < 5 &&
e.mobType != 'Armor Stand'
const enemy = bot.nearestEntity(filter)
bot.on("entityHurt", (entity) => {
if (entity != bot.entity) return;
bot.pvp.attack(enemy)
});
if (message === 'xd') {
const boss = bot.players[username]
}
if (message === 'fight me') {
const player = bot.players[username]
bot.chat('DIIEEE')
bot.pvp.attack(player.entity)
}
if (message === 'defend') {
const player = bot.players[username]
if (player === boss) {
bot.setControlState('jump')
defense()
}
}
}