-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
193 lines (136 loc) · 4.19 KB
/
index.js
File metadata and controls
193 lines (136 loc) · 4.19 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
const mineflayer = require('mineflayer')
const pvp = require('mineflayer-pvp').plugin
const { pathfinder, Movements, goals} = require('mineflayer-pathfinder')
const armorManager = require('mineflayer-armor-manager')
const MinecraftData = require('minecraft-data')
const autoeat = require('mineflayer-auto-eat')
const fs = require('fs');
var navigatePlugin = require('mineflayer-navigate')(mineflayer);
let accountraw = fs.readFileSync('account.json');
let accountdata = JSON.parse(accountraw);
const bot = mineflayer.createBot({
host: process.argv[2] || '147.135.124.101',
port: process.argv[3] || '25565',
username: process.argv[4] || accountdata['email'],
password: process.argv[5] || accountdata['password'],
logErrors: false
})
bot.loadPlugin(pvp)
bot.loadPlugin(armorManager)
bot.loadPlugin(pathfinder)
bot.loadPlugin(autoeat)
navigatePlugin(bot);
bot.on('playerEquip', (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)
})
let guardPos = null
function guardArea (pos) {
guardPos = pos.clone()
if (!bot.pvp.target) {
moveToGuardPos()
}
}
function stopGuarding () {
guardPos = null
bot.pvp.stop()
bot.pathfinder.setGoal(null)
}
function moveToGuardPos () {
const mcData = require('minecraft-data')(bot.version)
bot.pathfinder.setMovements(new Movements(bot, mcData))
bot.pathfinder.setGoal(new goals.GoalBlock(guardPos.x, guardPos.y, guardPos.z))
}
bot.on('stoppedAttacking', () => {
if (guardPos) {
moveToGuardPos()
}
})
bot.on('physicTick', () => {
if (bot.pvp.target) return
if (bot.pathfinder.isMoving()) return
const entity = bot.nearestEntity()
if (entity) bot.lookAt(entity.position.offset(0, entity.height, 0))
})
bot.on('physicTick', () => {
if (!guardPos) return
const filter = e => e.type === 'mob' && e.position.distanceTo(bot.entity.position) < 16 &&
e.mobType !== 'Armor Stand' // Mojang classifies armor stands as mobs for some reason?
const entity = bot.nearestEntity(filter)
if (entity) {
bot.pvp.attack(entity)
}
const RANGE_GOAL = 3 // get within this radius of the player
})
// auto eat
bot.on("health", () => {
if (bot.health === 20) bot.autoEat.disable()
// Disable the plugin if the bot is at 20 food points
else bot.autoEat.enable() // Else enable the plugin again
})
// come command
// WELCOMER
var items = [523, 3452, 334, 31];
var item = items[Math.floor(Math.random() * items.length)];
bot.on('playerJoined', (player) => {
if (player.username !== bot.username) {
bot.chat(item)
}
})
bot.on('chat', (username, message) => {
if (message === '!guard') {
const player = bot.players[username]
bot.on('chat',(username, message) => {
if (message === '!follow') {
bot.navigate.to [username] // WIP
const RANGE_goal = 2
}
})
if (!player) {
bot.chat("> I can't see you.")
return
}
bot.chat('> I will guard that location.')
guardArea(player.entity.position)
}
if (message === '!fightme') {
const player = bot.players[username]
if (!player) {
bot.chat("> I can't see you.")
return
}
bot.chat('>Prepare to fight!')
bot.pvp.attack(player.entity)
}
if (message === '!stop') {
bot.chat('>I will no longer guard this area.')
stopGuarding()
}
// COMMANDS VVVV
setInterval(() => bot.chat('You can use !help to see my commands'), 600000)
if (message === '!help') {
bot.chat('>My commands so far are !discord, !fightme, !stop, !bruh, !guard, !kys, and !ping')
}
if (message === '!discord') {
bot.chat('> 3B3T Discord: https://discord.gg/FtGvtjbNef')
}
if (message === '!kys') {
bot.chat('> okay bet')
bot.chat('/kill')
}
if (message === '!ping') {
bot.chat('> Pong!')
}
if (message === '!bruh') {
bot.chat('> bruh moment')
}
if (message === '!author') {
bot.chat('> tk746 is the author of 3b3tbot :)')
}
if (message === '!locate') {
bot.chat('my location is X: '+ bot.entity.position.x + ' Y:' + bot.entity.position.y + ' Z:' + bot.entity.position.z)
}
})