Skip to content

Commit 353ba2e

Browse files
committed
fix: some blocks textures were not update in hotbar after texturepack change
1 parent 53cbff7 commit 353ba2e

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

renderer/viewer/three/renderSlot.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export type ResolvedItemModelRender = {
1010

1111
export const renderSlot = (model: ResolvedItemModelRender, resourcesManager: ResourcesManagerCommon, debugIsQuickbar = false, fullBlockModelSupport = false): {
1212
texture: string,
13-
blockData?: Record<string, { slice, path }> & { resolvedModel: BlockModel },
14-
scale?: number,
15-
slice?: number[],
16-
modelName?: string,
17-
} | undefined => {
13+
blockData: Record<string, { slice, path }> & { resolvedModel: BlockModel } | null,
14+
scale: number | null,
15+
slice: number[] | null,
16+
modelName: string | null,
17+
} => {
1818
let itemModelName = model.modelName
1919
const isItem = loadedData.itemsByName[itemModelName]
2020

@@ -37,6 +37,8 @@ export const renderSlot = (model: ResolvedItemModelRender, resourcesManager: Res
3737
texture: 'gui',
3838
slice: [x, y, atlas.tileSize, atlas.tileSize],
3939
scale: 0.25,
40+
blockData: null,
41+
modelName: null
4042
}
4143
}
4244
}
@@ -63,14 +65,18 @@ export const renderSlot = (model: ResolvedItemModelRender, resourcesManager: Res
6365
return {
6466
texture: itemTexture.type,
6567
slice: itemTexture.slice,
66-
modelName: itemModelName
68+
modelName: itemModelName,
69+
blockData: null,
70+
scale: null
6771
}
6872
} else {
6973
// is block
7074
return {
7175
texture: 'blocks',
7276
blockData: itemTexture,
73-
modelName: itemModelName
77+
modelName: itemModelName,
78+
slice: null,
79+
scale: null
7480
}
7581
}
7682
}

src/inventoryWindows.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ export const upInventoryItems = (isInventory: boolean, invWindow = lastWindow) =
259259
// inv.pwindow.inv.slots[2].blockData = getBlockData('dirt')
260260
const customSlots = mapSlots((isInventory ? bot.inventory : bot.currentWindow)!.slots)
261261
invWindow.pwindow.setSlots(customSlots)
262+
return customSlots
262263
}
263264

264265
export const onModalClose = (callback: () => any) => {

src/react/HotbarRenderApp.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const HotbarInner = () => {
115115
container.current.appendChild(inv.canvas)
116116
const upHotbarItems = () => {
117117
if (!appViewer.resourcesManager?.itemsAtlasParser) return
118-
upInventoryItems(true, inv)
118+
globalThis.debugHotbarItems = upInventoryItems(true, inv)
119119
}
120120

121121
canvasManager.canvas.onclick = (e) => {
@@ -127,6 +127,7 @@ const HotbarInner = () => {
127127
}
128128
}
129129

130+
globalThis.debugUpHotbarItems = upHotbarItems
130131
upHotbarItems()
131132
bot.inventory.on('updateSlot', upHotbarItems)
132133
appViewer.resourcesManager.on('assetsTexturesUpdated', upHotbarItems)

0 commit comments

Comments
 (0)