Compare commits
No commits in common. "8e719d5ccf42d95e28290a0cca2d87660814e36a" and "902732c6ddab081273293ed5dca3bad2fb488856" have entirely different histories.
8e719d5ccf
...
902732c6dd
|
@ -431,16 +431,15 @@ function command(username, message) {
|
||||||
case "toss":
|
case "toss":
|
||||||
case "drop":
|
case "drop":
|
||||||
if (!message_parts[1]) { return false } // FIXME, works but ugly
|
if (!message_parts[1]) { return false } // FIXME, works but ugly
|
||||||
|
// TODO use cfg.plugins.inventory.itemByName
|
||||||
|
const item = cfg.plugins.inventory.itemByName(message_parts[1])
|
||||||
if (!mcData.findItemOrBlockByName(message_parts[1])) {
|
if (!mcData.findItemOrBlockByName(message_parts[1])) {
|
||||||
console.log("doesn't exist:", message_parts[1])
|
console.log("doesn't exist:", message_parts[1])
|
||||||
cfg.quiet || bot.chat(`item doesn't exist: ${message_parts[1]}`)
|
cfg.quiet || bot.chat(`item doesn't exist: ${message_parts[1]}`)
|
||||||
return false
|
return false
|
||||||
}
|
} else if (!item) {
|
||||||
const item = cfg.plugins.inventory.itemByName(message_parts[1])
|
|
||||||
if (!item) {
|
|
||||||
console.log("don't have:", message_parts[1])
|
console.log("don't have:", message_parts[1])
|
||||||
cfg.quiet || bot.chat(`don't have item: ${message_parts[1]}`)
|
cfg.quiet || bot.chat(`don't have item: ${message_parts[1]}`)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
switch (message_parts.length) {
|
switch (message_parts.length) {
|
||||||
case 2:
|
case 2:
|
||||||
|
|
|
@ -7,32 +7,27 @@ let bot = {}
|
||||||
let inv
|
let inv
|
||||||
// cfg.autosleep = false
|
// cfg.autosleep = false
|
||||||
|
|
||||||
function sleep(quiet = cfg.sleep.quiet) {
|
function sleep(quiet) {
|
||||||
|
quiet = quiet !== undefined ? quiet : cfg.sleep.quiet
|
||||||
if(bot.game.dimension !== "minecraft:overworld" || cfg.sleep.force){
|
if(bot.game.dimension !== "minecraft:overworld" || cfg.sleep.force){
|
||||||
!quiet && bot.chat("can't sleep, not in overworld now")
|
!quiet && bot.chat("can't sleep, not in overworld now")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (bot.isSleeping && !cfg.sleep.force) {
|
|
||||||
!quiet && bot.chat("already in bed!")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let bed = bot.findBlock({
|
let bed = bot.findBlock({
|
||||||
matching: block => bot.isABed(block)
|
matching: block => bot.isABed(block)
|
||||||
})
|
})
|
||||||
let bed_occupied = bed && bot.parseBedMetadata(bed).occupied
|
let bedstatus = bed && bot.parseBedMetadata(bed).occupied ? "n unoccupied" : ""
|
||||||
if (bed && bed_occupied) {
|
if(bed && bedstatus == "n unoccupied"){
|
||||||
bot.lookAt(bed.position)
|
bot.lookAt(bed.position)
|
||||||
bed = bot.findBlock({
|
bed = bot.findBlock({
|
||||||
matching: block => bot.isABed(block) && !bot.parseBedMetadata(block).occupied
|
matching: block => bot.isABed(block) && !bot.parseBedMetadata(block).occupied
|
||||||
}) || bed
|
}) || bed
|
||||||
bed_occupied = bot.parseBedMetadata(bed).occupied
|
bedstatus = bot.parseBedMetadata(bed).occupied ? "n unoccupied" : ""
|
||||||
}
|
}
|
||||||
if (bed && !bed_occupied) {
|
if (bed && bedstatus == "") {
|
||||||
bot.lookAt(bed.position)
|
bot.lookAt(bed.position)
|
||||||
bot.waitForChunksToLoad(() => {
|
bot.waitForChunksToLoad(() => {
|
||||||
cfg.plugins.mover && cfg.plugins.mover.moveNear(bed.position, 2)
|
cfg.plugins.mover.moveNear(bed.position)
|
||||||
bot.once('goal_reached', (goal) => {
|
|
||||||
console.info(goal)
|
|
||||||
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}`)
|
||||||
|
@ -40,42 +35,21 @@ function sleep(quiet = cfg.sleep.quiet) {
|
||||||
!quiet && bot.chat("zzz")
|
!quiet && bot.chat("zzz")
|
||||||
console.log("sleeping? ", bot.isSleeping)
|
console.log("sleeping? ", bot.isSleeping)
|
||||||
// hack until this is fixed
|
// hack until this is fixed
|
||||||
// TODO confirm this is fixed
|
// bot.isSleeping = bot.isSleeping ? bot.isSleeping : true
|
||||||
// bot.isSleeping = true
|
bot.isSleeping = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
} else if (inv && inv.equipItem("red_bed", "hand", true)) {
|
||||||
} else if (bed = bot.inventory.items().filter(bot.isABed)[0]) {
|
// doesn't work fortunately
|
||||||
const v = require('vec3')
|
// FIXME: DONT IMPLEMENT until it is detected as NOT NETHER
|
||||||
bot.equip(bed, "hand", (err) => { if (err) console.error(err) })
|
// bot.placeBlock()
|
||||||
bot.waitForChunksToLoad(() => {
|
|
||||||
let refBlock =
|
|
||||||
// FIXME hack to get around findBlock returning null
|
|
||||||
bot.blockAt(bot.entity.position.offset(1, 0, 1), false)
|
|
||||||
// bot.findBlock({
|
|
||||||
// matching: (block) => {
|
|
||||||
// // if (block && block.type !== 0 && block.position) {
|
|
||||||
// if (block && block.position) {
|
|
||||||
// console.info("found", block)
|
|
||||||
// const blockAbove = bot.blockAt(block.position.offset(0, 1, 0))
|
|
||||||
// return !blockAbove || blockAbove.type === 0
|
|
||||||
// }
|
|
||||||
// // console.info("not found", block)
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// , maxDistance: 10
|
|
||||||
// })
|
|
||||||
console.log(refBlock)
|
|
||||||
bot.placeBlock(refBlock, new v.Vec3(0, 1, 0), console.error)
|
|
||||||
setTimeout(sleep, 3000, true)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: use mover
|
// TODO: use mover
|
||||||
// bot.gameplay.solveFor(
|
// bot.gameplay.solveFor(
|
||||||
// new ObtainItem("bed"), (err) => {
|
// new ObtainItem("bed"), (err) => {
|
||||||
// if (err) {
|
// if (err) {
|
||||||
!quiet && bot.chat(`need a${bed_occupied ? "n unoccupied" : ""} bed: may not see if just placed`)
|
// !quiet && bot.chat(`need a${bedstatus} bed: may not see if just placed`)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// )
|
// )
|
||||||
|
@ -98,7 +72,7 @@ function autoSleep() {
|
||||||
if (!bot.time.isDay && !cfg.sleep.timeoutFn && cfg.sleep.auto && !bot.isSleeping) {
|
if (!bot.time.isDay && !cfg.sleep.timeoutFn && cfg.sleep.auto && !bot.isSleeping) {
|
||||||
sleep()
|
sleep()
|
||||||
cfg.sleep.timeoutFn = setTimeout(() => { cfg.sleep.timeoutFn = null }, cfg.sleep.timeout)
|
cfg.sleep.timeoutFn = setTimeout(() => { cfg.sleep.timeoutFn = null }, cfg.sleep.timeout)
|
||||||
console.log("sleeping?", bot.isSleeping, bot.time.isDay, bot.time.timeOfDay)
|
console.log("sleeping?", bot.isSleeping, bot.time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user