refactor: remove sleeper's prismarine-gameplay dependence

This commit is contained in:
jay 2020-12-24 10:35:01 +05:00
parent 8e4eb7748f
commit a7ccb08d43

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,15 +26,8 @@ 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) => {
if (err) {
!quiet && bot.chat(`can't reach bed: ${err.message}`)
} else {
bot.waitForChunksToLoad(() => {
cfg.plugins.moveNear(bed.position)
bot.sleep(bed, (err) => {
if (err) {
!quiet && bot.chat(`can't sleep: ${err.message}`)
@ -54,21 +40,19 @@ function sleep(quiet) {
}
})
})
}
})
// } 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)