fix: window title sometimes was not showing up on old versions
This commit is contained in:
parent
bc2972fe99
commit
8f62fbd4da
2 changed files with 21 additions and 2 deletions
|
|
@ -118,6 +118,14 @@ export const formatMessage = (message: MessageInput, mcData: IndexedData = globa
|
|||
return msglist
|
||||
}
|
||||
|
||||
export const messageToString = (message: MessageInput | string) => {
|
||||
if (typeof message === 'string') {
|
||||
return message
|
||||
}
|
||||
const msglist = formatMessage(message)
|
||||
return msglist.map(msg => msg.text).join('')
|
||||
}
|
||||
|
||||
const blockToItemRemaps = {
|
||||
water: 'water_bucket',
|
||||
lava: 'lava_bucket',
|
||||
|
|
|
|||
|
|
@ -57,12 +57,23 @@ export const onGameLoad = () => {
|
|||
return type
|
||||
}
|
||||
|
||||
const maybeParseNbtJson = (data: any) => {
|
||||
if (typeof data === 'string') {
|
||||
try {
|
||||
data = JSON.parse(data)
|
||||
} catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return nbt.simplify(data) ?? data
|
||||
}
|
||||
|
||||
bot.on('windowOpen', (win) => {
|
||||
const implementedWindow = implementedContainersGuiMap[mapWindowType(win.type as string, win.inventoryStart)]
|
||||
if (implementedWindow) {
|
||||
openWindow(implementedWindow, nbt.simplify(win.title as any))
|
||||
openWindow(implementedWindow, maybeParseNbtJson(win.title))
|
||||
} else if (options.unimplementedContainers) {
|
||||
openWindow('ChestWin', nbt.simplify(win.title as any))
|
||||
openWindow('ChestWin', maybeParseNbtJson(win.title))
|
||||
} else {
|
||||
// todo format
|
||||
displayClientChat(`[client error] cannot open unimplemented window ${win.id} (${win.type}). Slots: ${win.slots.map(item => getItemName(item)).filter(Boolean).join(', ')}`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue