Compare commits
5 Commits
nogameplay
...
086251bce6
Author | SHA1 | Date | |
---|---|---|---|
|
086251bce6 | ||
|
0ae961521f | ||
|
eae4e95803 | ||
|
fb066ee8a5 | ||
|
f4445749e6 |
29
lib/index.js
29
lib/index.js
@@ -9,19 +9,22 @@ let cfg = {
|
|||||||
const mineflayer = require("mineflayer");
|
const mineflayer = require("mineflayer");
|
||||||
// const { createGetAccessor } = require('typescript');
|
// const { createGetAccessor } = require('typescript');
|
||||||
|
|
||||||
const bot =
|
const options = !isNaN(parseInt(process.argv[3])) && parseInt(process.argv[3]) > 1e2 ?
|
||||||
!isNaN(parseInt(process.argv[3])) && parseInt(process.argv[3]) > 1e2 ?
|
{
|
||||||
mineflayer.createBot({
|
host: process.argv[2] || process.env.MINECRAFT_HOST || env.MINECRAFT_HOST || 'localhost', // Change this to the ip you want.
|
||||||
host: process.argv[2] || process.env.MINECRAFT_HOST || env.MINECRAFT_HOST || 'localhost', // Change this to the ip you want.
|
port: parseInt(process.argv[3]) || process.env.MINECRAFT_PORT || env.MINECRAFT_PORT // || 58471,
|
||||||
port: parseInt(process.argv[3]) || process.env.MINECRAFT_PORT || env.MINECRAFT_PORT // || 58471,
|
}
|
||||||
})
|
:
|
||||||
:
|
{
|
||||||
mineflayer.createBot({
|
host: process.argv[2] || process.env.MINECRAFT_HOST || env.MINECRAFT_HOST || 'localhost', // Change this to the ip you want.
|
||||||
host: process.argv[2] || process.env.MINECRAFT_HOST || env.MINECRAFT_HOST || 'localhost', // Change this to the ip you want.
|
username: process.argv[3] || process.env.MINECRAFT_USER || env.MINECRAFT_USER,
|
||||||
username: process.argv[3] || process.env.MINECRAFT_USER || env.MINECRAFT_USER,
|
password: process.argv[4] || process.env.MINECRAFT_PASS || env.MINECRAFT_PASS,
|
||||||
password: process.argv[4] || process.env.MINECRAFT_PASS || env.MINECRAFT_PASS,
|
// port: process.argv[5] || process.env.MINECRAFT_PORT || 58471,
|
||||||
// port: process.argv[5] || process.env.MINECRAFT_PORT || 58471,
|
}
|
||||||
})
|
|
||||||
|
const bot = mineflayer.createBot(options)
|
||||||
|
|
||||||
|
cfg.botOptions = options
|
||||||
|
|
||||||
|
|
||||||
let plugins = {}
|
let plugins = {}
|
||||||
|
@@ -46,7 +46,17 @@ const events = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
, chat: command
|
, chat: command
|
||||||
, kicked: (reason, loggedIn) => console.warn(reason, loggedIn)
|
, kicked: function rejoin(reason, loggedIn) {
|
||||||
|
console.warn(reason, loggedIn && "logged_in")
|
||||||
|
if (reason.extra && reason.extra[0].text === "Server closed") {
|
||||||
|
bot.quit()
|
||||||
|
bot.end()
|
||||||
|
// TODO implement all startup features (maybe refactor all into a single function / module?)
|
||||||
|
setTimeout((bot, cfg) => {
|
||||||
|
bot = mineflayer.createBot(cfg.botOptions)
|
||||||
|
}, 15 * 60 * 1000, bot, cfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const events_registered = []
|
const events_registered = []
|
||||||
@@ -183,7 +193,7 @@ function command(username, message) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "follow":
|
case "follow":
|
||||||
subcommand("go follow me")
|
subcommand("go follow " + message_parts.slice(2).join(" "))
|
||||||
break;
|
break;
|
||||||
case "come":
|
case "come":
|
||||||
subcommand("go follow once")
|
subcommand("go follow once")
|
||||||
|
@@ -16,12 +16,18 @@ let movements = []
|
|||||||
|
|
||||||
|
|
||||||
function initMoves(bot = bot, mcData = require('minecraft-data')(bot.version)) {
|
function initMoves(bot = bot, mcData = require('minecraft-data')(bot.version)) {
|
||||||
|
console.info(movements)
|
||||||
|
if (movements.length > 0) {
|
||||||
|
bot.pathfinder.setMovements(defaultMove)
|
||||||
|
return console.warn("movements already initialized!")
|
||||||
|
}
|
||||||
let defaultMove = new Movements(bot, mcData)
|
let defaultMove = new Movements(bot, mcData)
|
||||||
defaultMove.canDig = false
|
defaultMove.canDig = false
|
||||||
defaultMove.scafoldingBlocks.push(mcData.blocksByName.slime_block.id)
|
defaultMove.scafoldingBlocks.push(mcData.blocksByName.slime_block.id)
|
||||||
// defaultMove.blocksCantBreak.add(mcData.blocksByName.glass.id)
|
// defaultMove.blocksCantBreak.add(mcData.blocksByName.glass.id)
|
||||||
// defaultMove.blocksToAvoid.add(mcData.blocksByName.magma.id)
|
// defaultMove.blocksToAvoid.add(mcData.blocksByName.magma.id)
|
||||||
movements.defaultMove = defaultMove
|
movements.push(defaultMove)
|
||||||
|
movements.defaultMove = movements[0]
|
||||||
|
|
||||||
bot.pathfinder.setMovements(defaultMove)
|
bot.pathfinder.setMovements(defaultMove)
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ function sleep(quiet) {
|
|||||||
if (bed && bedstatus == "") {
|
if (bed && bedstatus == "") {
|
||||||
bot.lookAt(bed.position)
|
bot.lookAt(bed.position)
|
||||||
bot.waitForChunksToLoad(() => {
|
bot.waitForChunksToLoad(() => {
|
||||||
cfg.plugins.moveNear(bed.position)
|
cfg.plugins.mover.moveNear(bed.position)
|
||||||
bot.sleep(bed, (err) => {
|
bot.sleep(bed, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
!quiet && bot.chat(`can't sleep: ${err.message}`)
|
!quiet && bot.chat(`can't sleep: ${err.message}`)
|
||||||
|
Reference in New Issue
Block a user