-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
101 lines (87 loc) · 2.52 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const mineflayer = require('mineflayer')
const cmd = require('mineflayer-cmd').plugin
const fs = require('fs');
let rawdata = fs.readFileSync('config.json');
let data = JSON.parse(rawdata);
var lasttime = -1;
var moving = 0;
var first = false;
var connected = 0;
var actions = [ 'forward', 'back', 'left', 'right']
var lastaction;
var pi = 3.14159;
var moveinterval = 2; // 2 second movement interval
var maxrandom = 5; // 0-5 seconds added to movement interval (randomly)
var host = data["ip"];
var username = data["name"]
var nightskip = data["auto-night-skip"]
var bot = mineflayer.createBot({
host: host,
port:data["port"],
username: username
});
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
bot.loadPlugin(cmd)
bot.on('login',function(){
console.log("Trying to login")
if(data["login-enabled"] == "true"){
bot.chat(data["register-cmd"])
bot.chat(data["login-cmd"])
}
for (let i=0; i<10; i++) {
task(i);
}
console.log("Logged In")
bot.chat("hello");
});
function task(i) {
setTimeout(function() {
if(first == true){
bot.chat("Subscribe To Easy Gamer : https://www.youtube.com/channel/UCk575VDlrCsv1Gy2XZQ1bSA")
first = false;
}
else{
bot.chat("Subscribe To MannuG : https://www.youtube.com/channel/UCSZHRnBue50ImBKeR6k6eDg")
first = true;
}
}, 3600000 * i);
}
bot.on('time', function(time) {
if(nightskip == "true"){
if(bot.time.timeOfDay >= 13000){
bot.chat('/time set day')
}}
if (connected <1) {
return;
}
if (lasttime<0) {
lasttime = bot.time.age;
} else {
var randomadd = Math.random() * maxrandom * 20;
var interval = moveinterval*20 + randomadd;
if (bot.time.age - lasttime > interval) {
if (moving == 1) {
bot.setControlState(lastaction,false);
moving = 0;
lasttime = bot.time.age;
} else {
var yaw = Math.random()*pi - (0.5*pi);
var pitch = Math.random()*pi - (0.5*pi);
bot.look(yaw,pitch,false);
lastaction = actions[Math.floor(Math.random() * actions.length)];
bot.setControlState(lastaction,true);
moving = 1;
lasttime = bot.time.age;
bot.activateItem();
}
}
}
});
bot.on('spawn',function() {
connected=1;
});
bot.on('death',function() {
bot.emit("respawn")
});