feat(informer): ✨ add reverse mcdata lookup by block or item id
This commit is contained in:
parent
3c9d62441f
commit
69b1ab0b0b
|
@ -133,6 +133,22 @@ function entity(name) {
|
|||
return entity
|
||||
}
|
||||
|
||||
function blockOrItemFromId(num, quiet = cfg.info.quiet) {
|
||||
const block = mcData?.blocks[num]
|
||||
const item = mcData?.items[num]
|
||||
// const entity = mcData?.entities[num]
|
||||
if (block || item) {
|
||||
quiet || bot.chat(
|
||||
(block && `block: ${block.name}, ` || "")
|
||||
+ (item && `item: ${item.name}, ` || "")
|
||||
// + (entity && `entity: ${entity.name}, ` || "")
|
||||
)
|
||||
} else {
|
||||
quiet || bot.chat("info: nonexistent block or item")
|
||||
}
|
||||
return { block, item }
|
||||
}
|
||||
|
||||
function command(message_parts, player) {
|
||||
if (message_parts.length > 0) {
|
||||
cfg.info.recentCommand = message_parts
|
||||
|
@ -166,8 +182,15 @@ function command(message_parts, player) {
|
|||
break
|
||||
case "b":
|
||||
case "block":
|
||||
default:
|
||||
block()
|
||||
break
|
||||
default:
|
||||
const num = parseInt(message_parts[0])
|
||||
if (isFinite(num)) {
|
||||
blockOrItemFromId(num)
|
||||
} else {
|
||||
quiet || bot.chat("info usage: `!info [me|i|e|b|<num>|quiet]`")
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user