-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
62 lines (55 loc) · 2.04 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var util = require('util');
var mineflayer = require('mineflayer');
var bot = mineflayer.createBot({ username: 'Lumberjack' });
bot.on('chat', function(username, message) {
// navigate to whoever talks
// if (username === bot.username) return;
// var target = bot.players[username].entity;
console.log(username+' says: '+message)
// if (message === 'come') {
// bot.navigate.to(target.position);
// } else if (message === 'stop') {
// bot.navigate.stop();
// } else if (message === 'test') {
// test();
// } else if (message === 'desc') {
// describe();
// }
});
bot.on('login', function() {
console.log("I've logged in.");
});
// install the plugin
require('mineflayer-navigate')(mineflayer)(bot);
bot.navigate.on('pathFound', function (path) {
console.log('navigate: found path. I can get there in ' + path.length + ' moves.');
});
bot.navigate.on('cannotFind', function () {
console.log('navigate: unable to find path');
});
bot.navigate.on('arrived', function () {
console.log('navigate: I have arrived');
});
bot.navigate.on('stop', function() {
console.log('navigate: stopping');
});
require('./lumberjack.js')(mineflayer)(bot);
require('./repl.js')(mineflayer)(bot);
require('./extend.js')(mineflayer)(bot);
require('mineflayer-voxel')(mineflayer)(bot, {port: 8080});
// bot.on('blockUpdate', function(oldBlock, newBlock) {
// // if (!oldBlock || !newBlock) {
// // console.log('newBlock or oldBlock is undefined!')
// // console.dir(oldBlock);
// // console.dir(newBlock);
// // console.trace();
// // }
// //
// var ignoredNames = ['snow', 'tallgrass', 'grass', 'leaves']
// var isIgnoredBlockType = ignoredNames.some(function(name) { return name === newBlock.name || name === oldBlock.name });
// // var isSameType = (oldBlock.type === newBlock.type);
// // if (!isIgnoredBlockType && !isSameType && newBlock.position.distanceTo(bot.entity.position) < 10) {
// if (!isIgnoredBlockType) {
// console.log(newBlock.position+' turned from '+oldBlock.name+' into '+newBlock.name);
// }
// })