fix: some blocks textures were not update in hotbar after texturepack change

This commit is contained in:
Vitaly Turovsky 2025-08-08 21:52:55 +03:00
commit 353ba2ecb3
3 changed files with 16 additions and 8 deletions

View file

@ -10,11 +10,11 @@ export type ResolvedItemModelRender = {
export const renderSlot = (model: ResolvedItemModelRender, resourcesManager: ResourcesManagerCommon, debugIsQuickbar = false, fullBlockModelSupport = false): {
texture: string,
blockData?: Record<string, { slice, path }> & { resolvedModel: BlockModel },
scale?: number,
slice?: number[],
modelName?: string,
} | undefined => {
blockData: Record<string, { slice, path }> & { resolvedModel: BlockModel } | null,
scale: number | null,
slice: number[] | null,
modelName: string | null,
} => {
let itemModelName = model.modelName
const isItem = loadedData.itemsByName[itemModelName]
@ -37,6 +37,8 @@ export const renderSlot = (model: ResolvedItemModelRender, resourcesManager: Res
texture: 'gui',
slice: [x, y, atlas.tileSize, atlas.tileSize],
scale: 0.25,
blockData: null,
modelName: null
}
}
}
@ -63,14 +65,18 @@ export const renderSlot = (model: ResolvedItemModelRender, resourcesManager: Res
return {
texture: itemTexture.type,
slice: itemTexture.slice,
modelName: itemModelName
modelName: itemModelName,
blockData: null,
scale: null
}
} else {
// is block
return {
texture: 'blocks',
blockData: itemTexture,
modelName: itemModelName
modelName: itemModelName,
slice: null,
scale: null
}
}
}

View file

@ -259,6 +259,7 @@ export const upInventoryItems = (isInventory: boolean, invWindow = lastWindow) =
// inv.pwindow.inv.slots[2].blockData = getBlockData('dirt')
const customSlots = mapSlots((isInventory ? bot.inventory : bot.currentWindow)!.slots)
invWindow.pwindow.setSlots(customSlots)
return customSlots
}
export const onModalClose = (callback: () => any) => {

View file

@ -115,7 +115,7 @@ const HotbarInner = () => {
container.current.appendChild(inv.canvas)
const upHotbarItems = () => {
if (!appViewer.resourcesManager?.itemsAtlasParser) return
upInventoryItems(true, inv)
globalThis.debugHotbarItems = upInventoryItems(true, inv)
}
canvasManager.canvas.onclick = (e) => {
@ -127,6 +127,7 @@ const HotbarInner = () => {
}
}
globalThis.debugUpHotbarItems = upHotbarItems
upHotbarItems()
bot.inventory.on('updateSlot', upHotbarItems)
appViewer.resourcesManager.on('assetsTexturesUpdated', upHotbarItems)