feat(informer): ✨ add block info based on player position or manually provided coords
This paves the way to get block info based on positions relative from the player
This commit is contained in:
parent
050e2b3bd9
commit
ccf0c598e8
|
@ -14,13 +14,21 @@ let cfg = {
|
||||||
quiet: null,
|
quiet: null,
|
||||||
bot: bot
|
bot: bot
|
||||||
}
|
}
|
||||||
function block(pos) {
|
|
||||||
const block = pos ? bot.blockAt(v(pos)) : bot.blockAtCursor()
|
function isVec3(vec) {
|
||||||
console.log(block, block && block.getProperties())
|
return this.x && this.y && this.z
|
||||||
|
}
|
||||||
|
|
||||||
|
function block(entity = bot.entity, pos = entity?.position?.offset(0, -1, 0)) {
|
||||||
|
console.assert(pos || entity)
|
||||||
|
const block = isVec3(pos) ? bot.blockAt(v(pos))
|
||||||
|
: pos
|
||||||
|
console.log(block, block?.getProperties && block.getProperties())
|
||||||
if (!block) {
|
if (!block) {
|
||||||
quiet || bot.chat("empty block")
|
quiet || bot.chat("empty block")
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
bot.lookAt(block?.position)
|
||||||
let info = [block.type, block.name]
|
let info = [block.type, block.name]
|
||||||
if (block.metadata) info.push(Object.entries(block.getProperties()))
|
if (block.metadata) info.push(Object.entries(block.getProperties()))
|
||||||
quiet || bot.chat(info.join(": "))
|
quiet || bot.chat(info.join(": "))
|
||||||
|
@ -89,7 +97,7 @@ function command(message_parts, player) {
|
||||||
} else {
|
} else {
|
||||||
// TODO dispatch on instance of entity, block, etc..
|
// TODO dispatch on instance of entity, block, etc..
|
||||||
// TODO have the logic inside the function or with a utility function
|
// TODO have the logic inside the function or with a utility function
|
||||||
block(player.position || player?.entity.position || null)
|
block()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -106,6 +114,9 @@ function command(message_parts, player) {
|
||||||
case "entity":
|
case "entity":
|
||||||
entity()
|
entity()
|
||||||
break
|
break
|
||||||
|
case "me":
|
||||||
|
block(player)
|
||||||
|
break
|
||||||
case "b":
|
case "b":
|
||||||
case "block":
|
case "block":
|
||||||
default:
|
default:
|
||||||
|
@ -134,7 +145,7 @@ function command(message_parts, player) {
|
||||||
case "b":
|
case "b":
|
||||||
case "block":
|
case "block":
|
||||||
default:
|
default:
|
||||||
block(message_parts.slice(1))
|
block(undefined, message_parts.slice(1))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user