Compare commits

..

5 Commits

Author SHA1 Message Date
jay
bf45a53f08 refactor: remove gameplay
temporarily remove gameplay until it is fixed and more stable

miner plugin won't work now
2020-12-24 10:40:46 +05:00
jay
a7ccb08d43 refactor: remove sleeper's prismarine-gameplay dependence 2020-12-24 10:35:01 +05:00
jay
8e4eb7748f style: fix crlf to lf 2020-12-24 09:33:08 +05:00
jay
47a944fe2a fix: 🐛 compat: don't use ?. for compat with older node.js 2020-12-24 09:19:32 +05:00
jay
1a3c345017 chore: 🙈 ignore .env 2020-12-24 09:16:11 +05:00
7 changed files with 257 additions and 274 deletions

1
.gitignore vendored
View File

@@ -13,6 +13,7 @@
# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local

View File

@@ -29,7 +29,7 @@ let plugins = {}
function loadplugin(pluginname, pluginpath) {
try {
plugins[pluginname] = require(pluginpath)
plugins[pluginname]?.load(cfg)
plugins[pluginname].load(cfg)
} catch (error) {
if (error.code == 'MODULE_NOT_FOUND') {
console.warn('plugin not used:', pluginpath)
@@ -44,7 +44,7 @@ function unloadplugin(pluginname, pluginpath) {
const plugin = require.resolve(pluginpath)
try {
if (plugin && require.cache[plugin]) {
require.cache[plugin].exports?.unload()
require.cache[plugin].exports.unload()
delete plugins[pluginname]
delete require.cache[plugin]
}
@@ -99,7 +99,7 @@ bot.once("spawn", () => {
inventory: require('./plugins/inventory'),
eater: require('./plugins/eater'),
finder: require('./plugins/finder'),
miner: require('./plugins/miner'),
// miner: require('./plugins/miner.js'),
// statemachine: require('./plugins/statemachine'),
}

View File

@@ -1,13 +1,6 @@
let pathfinder
//TODO replace with simple pathfinder motions
const {
gameplay,
MoveTo,
MoveToInteract,
ObtainItem,
// Craft
} = require('prismarine-gameplay')
let cfg = {}
let bot = {}
@@ -33,42 +26,33 @@ function sleep(quiet) {
}
if (bed && bedstatus == "") {
bot.lookAt(bed.position)
// const nearbed =
bot.gameplay.solveFor(
new MoveTo((bed.position.range = 2) && bed.position), (err) => {
// new MoveTo(bed.position), (err) => {
// new MoveToInteract(bed.position), (err) => {
bot.waitForChunksToLoad(() => {
cfg.plugins.moveNear(bed.position)
bot.sleep(bed, (err) => {
if (err) {
!quiet && bot.chat(`can't reach bed: ${err.message}`)
!quiet && bot.chat(`can't sleep: ${err.message}`)
} else {
bot.waitForChunksToLoad(() => {
bot.sleep(bed, (err) => {
if (err) {
!quiet && bot.chat(`can't sleep: ${err.message}`)
} else {
!quiet && bot.chat("zzz")
console.log("sleeping? ", bot.isSleeping)
// hack until this is fixed
// bot.isSleeping = bot.isSleeping ? bot.isSleeping : true
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)) {
// doesn't work fortunately
// FIXME: DONT IMPLEMENT until it is detected as NOT NETHER
bot.placeBlock()
// bot.placeBlock()
} else {
bot.gameplay.solveFor(
new ObtainItem("bed"), (err) => {
if (err) {
!quiet && bot.chat(`need a${bedstatus} bed: may not see if just placed`)
}
}
)
// TODO: use mover
// bot.gameplay.solveFor(
// new ObtainItem("bed"), (err) => {
// if (err) {
// !quiet && bot.chat(`need a${bedstatus} bed: may not see if just placed`)
// }
// }
// )
// bot.chat('/afk')
}
bot.pathfinder.movements
@@ -104,7 +88,6 @@ const load = (config) => {
pathfinder = bot.pathfinder || require('mineflayer-pathfinder').pathfinder
// bot.loadPlugin(pathfinder)
bot.loadPlugin(gameplay)
inv = cfg.plugins["inventory"]
bot.on("time", autoSleep)

View File

@@ -42,7 +42,6 @@
"prismarine-block": "^1",
"prismarine-chat": "^1",
"prismarine-entity": "^1.1.0",
"prismarine-gameplay": "github:TheDudeFromCI/prismarine-gameplay#crafting",
"prismarine-item": "^1.5.0",
"prismarine-nbt": "^1.3",
"prismarine-recipe": "^1",