/
bot.js
40 lines (38 loc) · 1.11 KB
/
bot.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
const mineflayer = require('mineflayer');
console.log('Starting...')
function createBot () {
const bot = mineflayer.createBot({
host: "localhost",
port: "25565",
username: "Test",
version: false
})
bot.on('login', function() {
bot.chat('/reginster 123123123 123123123')
})
bot.on('chat', (username, message) => {
if (username === bot.username) return
target = bot.players[username].entity
let entity
switch (message) {
case ';start':
bot.setControlState('forward', true)
bot.setControlState('jump', true)
bot.setControlState('sprint', true)
break
case ';stop':
bot.clearControlStates()
break
}
})
bot.on('spawn', function() {
bot.chat('Spawned')
})
bot.on('death', function() {
bot.chat('I died, respawn')
})
bot.on('kicked', (reason, loggedIn) => console.log(reason, loggedIn))
bot.on('error', err => console.log(err))
bot.on('end', createBot)
}
createBot()