-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoBot_plugin.js
73 lines (63 loc) · 2.47 KB
/
autoBot_plugin.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
/*
Experimental Minecraft Bot - plugin
The goal of this framework is to allow people to write bots at a high level
that can function independantly from an operator by responding to behaviour
events.
*/
'use strict';
const pathfinder = require('./pathfinder/pathfinder').pathfinder;
const Movements = require('./pathfinder/pathfinder').Movements;
//const { GoalBlock, GoalNear, GoalGetToBlock } = require('./pathfinder/pathfinder').goals;
const minecraftData = require('minecraft-data');
const sleep = require('./behaviours/autobotLib').sleep;
const Autocraft = require('./behaviours/Autocraft');
const BehaviourSelect = require('./behaviours/behaviourSelect');
const CollectDrops = require('./behaviours/CollectDrops');
const GetUnstuck = require('./behaviours/GetUnstuck');
const Inventory = require('./behaviours/Inventory');
const Landscaping = require('./behaviours/Landscaping');
const Lumberjack = require('./behaviours/Lumberjack');
const Mining = require('./behaviours/Mining');
const Navigator = require('./behaviours/Navigator');
const Smelting = require('./behaviours/Smelting');
const Stash = require('./behaviours/Stash');
/*****************************************************************************/
function inject (bot) {
bot.mcData = null;
bot.autobot = {};
bot.autobot.autocraft = new Autocraft(bot);
bot.autobot.behaviourSelect = new BehaviourSelect(bot);
bot.autobot.collectDrops = new CollectDrops(bot);
bot.autobot.getUnstuck = new GetUnstuck(bot);
bot.autobot.inventory = new Inventory(bot);
bot.autobot.landscaping = new Landscaping(bot);
bot.autobot.lumberjack = new Lumberjack(bot);
bot.autobot.mining = new Mining(bot);
bot.autobot.navigator = new Navigator(bot);
bot.autobot.smelting = new Smelting(bot);
bot.autobot.stash = new Stash(bot);
bot.loadPlugin(pathfinder);
bot.once('spawn', autoBotLoader);
function autoBotLoader() {
bot.mcData = minecraftData(bot.version);
bot.defaultMove = new Movements(bot, bot.mcData);
bot.pathfinder.setMovements(bot.defaultMove);
bot.on('goal_reached', bot.autobot.navigator.onGoalReached);
bot.on('physicTick', bot.autobot.navigator.monitorMovement);
bot.waitForChunksToLoad(() => {
sleep(5000).then(() => {
bot.autobot.homePosition = bot.autobot.navigator.setHomePosition();
const eventName = "autobot.ready";
let result = {
error: false,
resultCode: "ready",
description: "autoBot is ready to run"
};
bot.emit(eventName, result);
});
});
}
}
module.exports = {
autoBot: inject
}