Compare commits
5 Commits
de0af4d2ac
...
nogameplay
Author | SHA1 | Date | |
---|---|---|---|
|
bf45a53f08 | ||
|
a7ccb08d43 | ||
|
8e4eb7748f | ||
|
47a944fe2a | ||
|
1a3c345017 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env
|
||||||
.env.local
|
.env.local
|
||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
|
@@ -29,7 +29,7 @@ let plugins = {}
|
|||||||
function loadplugin(pluginname, pluginpath) {
|
function loadplugin(pluginname, pluginpath) {
|
||||||
try {
|
try {
|
||||||
plugins[pluginname] = require(pluginpath)
|
plugins[pluginname] = require(pluginpath)
|
||||||
plugins[pluginname]?.load(cfg)
|
plugins[pluginname].load(cfg)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code == 'MODULE_NOT_FOUND') {
|
if (error.code == 'MODULE_NOT_FOUND') {
|
||||||
console.warn('plugin not used:', pluginpath)
|
console.warn('plugin not used:', pluginpath)
|
||||||
@@ -44,7 +44,7 @@ function unloadplugin(pluginname, pluginpath) {
|
|||||||
const plugin = require.resolve(pluginpath)
|
const plugin = require.resolve(pluginpath)
|
||||||
try {
|
try {
|
||||||
if (plugin && require.cache[plugin]) {
|
if (plugin && require.cache[plugin]) {
|
||||||
require.cache[plugin].exports?.unload()
|
require.cache[plugin].exports.unload()
|
||||||
delete plugins[pluginname]
|
delete plugins[pluginname]
|
||||||
delete require.cache[plugin]
|
delete require.cache[plugin]
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ bot.once("spawn", () => {
|
|||||||
inventory: require('./plugins/inventory'),
|
inventory: require('./plugins/inventory'),
|
||||||
eater: require('./plugins/eater'),
|
eater: require('./plugins/eater'),
|
||||||
finder: require('./plugins/finder'),
|
finder: require('./plugins/finder'),
|
||||||
miner: require('./plugins/miner'),
|
// miner: require('./plugins/miner.js'),
|
||||||
// statemachine: require('./plugins/statemachine'),
|
// statemachine: require('./plugins/statemachine'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,13 +1,6 @@
|
|||||||
|
|
||||||
let pathfinder
|
let pathfinder
|
||||||
//TODO replace with simple pathfinder motions
|
//TODO replace with simple pathfinder motions
|
||||||
const {
|
|
||||||
gameplay,
|
|
||||||
MoveTo,
|
|
||||||
MoveToInteract,
|
|
||||||
ObtainItem,
|
|
||||||
// Craft
|
|
||||||
} = require('prismarine-gameplay')
|
|
||||||
|
|
||||||
let cfg = {}
|
let cfg = {}
|
||||||
let bot = {}
|
let bot = {}
|
||||||
@@ -33,42 +26,33 @@ function sleep(quiet) {
|
|||||||
}
|
}
|
||||||
if (bed && bedstatus == "") {
|
if (bed && bedstatus == "") {
|
||||||
bot.lookAt(bed.position)
|
bot.lookAt(bed.position)
|
||||||
// const nearbed =
|
bot.waitForChunksToLoad(() => {
|
||||||
bot.gameplay.solveFor(
|
cfg.plugins.moveNear(bed.position)
|
||||||
new MoveTo((bed.position.range = 2) && bed.position), (err) => {
|
bot.sleep(bed, (err) => {
|
||||||
// new MoveTo(bed.position), (err) => {
|
|
||||||
// new MoveToInteract(bed.position), (err) => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
!quiet && bot.chat(`can't reach bed: ${err.message}`)
|
!quiet && bot.chat(`can't sleep: ${err.message}`)
|
||||||
} else {
|
} else {
|
||||||
bot.waitForChunksToLoad(() => {
|
!quiet && bot.chat("zzz")
|
||||||
bot.sleep(bed, (err) => {
|
console.log("sleeping? ", bot.isSleeping)
|
||||||
if (err) {
|
// hack until this is fixed
|
||||||
!quiet && bot.chat(`can't sleep: ${err.message}`)
|
// bot.isSleeping = bot.isSleeping ? bot.isSleeping : true
|
||||||
} else {
|
bot.isSleeping = true
|
||||||
!quiet && bot.chat("zzz")
|
|
||||||
console.log("sleeping? ", bot.isSleeping)
|
|
||||||
// hack until this is fixed
|
|
||||||
// bot.isSleeping = bot.isSleeping ? bot.isSleeping : true
|
|
||||||
bot.isSleeping = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// } else if (bed){
|
})
|
||||||
} else if (inv && inv.equipItem("red_bed", "hand", true)) {
|
} else if (inv && inv.equipItem("red_bed", "hand", true)) {
|
||||||
// doesn't work fortunately
|
// doesn't work fortunately
|
||||||
// FIXME: DONT IMPLEMENT until it is detected as NOT NETHER
|
// FIXME: DONT IMPLEMENT until it is detected as NOT NETHER
|
||||||
bot.placeBlock()
|
// bot.placeBlock()
|
||||||
} else {
|
} else {
|
||||||
bot.gameplay.solveFor(
|
// TODO: use mover
|
||||||
new ObtainItem("bed"), (err) => {
|
// bot.gameplay.solveFor(
|
||||||
if (err) {
|
// new ObtainItem("bed"), (err) => {
|
||||||
!quiet && bot.chat(`need a${bedstatus} bed: may not see if just placed`)
|
// if (err) {
|
||||||
}
|
// !quiet && bot.chat(`need a${bedstatus} bed: may not see if just placed`)
|
||||||
}
|
// }
|
||||||
)
|
// }
|
||||||
|
// )
|
||||||
// bot.chat('/afk')
|
// bot.chat('/afk')
|
||||||
}
|
}
|
||||||
bot.pathfinder.movements
|
bot.pathfinder.movements
|
||||||
@@ -104,7 +88,6 @@ const load = (config) => {
|
|||||||
|
|
||||||
pathfinder = bot.pathfinder || require('mineflayer-pathfinder').pathfinder
|
pathfinder = bot.pathfinder || require('mineflayer-pathfinder').pathfinder
|
||||||
// bot.loadPlugin(pathfinder)
|
// bot.loadPlugin(pathfinder)
|
||||||
bot.loadPlugin(gameplay)
|
|
||||||
inv = cfg.plugins["inventory"]
|
inv = cfg.plugins["inventory"]
|
||||||
bot.on("time", autoSleep)
|
bot.on("time", autoSleep)
|
||||||
|
|
||||||
|
@@ -42,7 +42,6 @@
|
|||||||
"prismarine-block": "^1",
|
"prismarine-block": "^1",
|
||||||
"prismarine-chat": "^1",
|
"prismarine-chat": "^1",
|
||||||
"prismarine-entity": "^1.1.0",
|
"prismarine-entity": "^1.1.0",
|
||||||
"prismarine-gameplay": "github:TheDudeFromCI/prismarine-gameplay#crafting",
|
|
||||||
"prismarine-item": "^1.5.0",
|
"prismarine-item": "^1.5.0",
|
||||||
"prismarine-nbt": "^1.3",
|
"prismarine-nbt": "^1.3",
|
||||||
"prismarine-recipe": "^1",
|
"prismarine-recipe": "^1",
|
||||||
|
Reference in New Issue
Block a user