-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (38 loc) · 1.22 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
const mineflayer = require('mineflayer')
const navigatePlugin = require("mineflayer-navigate")(mineflayer);
const bot = mineflayer.createBot({
host: process.env.server,
port: process.env.port,
username: process.env.username, //process.env.email
password: process.env.password,
version: process.env.version,
auth: 'microsoft'
})
navigatePlugin(bot);
bot.on("chat", function(username, message){
if(username === bot.username) return;
let msg = message.toString();
if(msg.startsWith(".execute")){
let text = msg.split(" ").slice(1).join(" ");
bot.chat(text)
}
if (msg === ".walk"){
bot.navigate.to(bot.players[username].entity.position);
}
if(msg.startsWith(".fight")){
let enemy = msg.split(" ").slice(1).join("");
innt2 = setInterval(async ()=>{
bot.players[enemy].entity.position.y = bot.entitiy.position.y
await bot.navigate.to(bot.players[enemy].entity.position)
},100)
innt = setInterval(()=>{
if(!bot.players[enemy].entity){
clearInterval(innt);
clearInterval(innt2);
return;
}
bot.attack(bot.players[enemy].entity, true);
bot.lookAt(bot.players[enemy].entity.position.offset(0,1,0));
},800)
}
})