Skip to content

Commit 6a88e5c

Browse files
committed
🐛 Fix item displays not rendering block models
1 parent e6ffc3b commit 6a88e5c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/systems/minecraft/itemModelManager.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ function getItemResourceLocation(item: string) {
5050

5151
async function parseItemModel(location: string, childModel?: IItemModel): Promise<ItemModelMesh> {
5252
const modelPath = getPathFromResourceLocation(location, 'models')
53-
const model = getJSONAsset(modelPath + '.json') as IItemModel
53+
let model: IItemModel
54+
try {
55+
model = getJSONAsset(modelPath + '.json')
56+
} catch {
57+
// Fallback to block model if item model doesn't exist
58+
model = getJSONAsset(modelPath.replace('item/', 'block/') + '.json')
59+
}
5460

5561
if (childModel) {
5662
// if (childModel.ambientocclusion !== undefined)
@@ -69,6 +75,7 @@ async function parseItemModel(location: string, childModel?: IItemModel): Promis
6975

7076
if (model.parent) {
7177
const resource = parseResourceLocation(model.parent)
78+
console.log('Parsed resource:', resource)
7279
if (resource.type === 'block') {
7380
return await parseBlockModel({ model: model.parent, isItemModel: true }, model)
7481
}

0 commit comments

Comments
 (0)