Skip to content

Commit 39aca17

Browse files
authored
fix: custom item model data on 1.21.4+ (#392)
1 parent e9320c6 commit 39aca17

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/mineflayer/items.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,17 @@ export const getItemMetadata = (item: GeneralInputItem, resourcesManager: Resour
5858
}
5959
if (customModelDataDefinitions) {
6060
const customModelDataComponent: any = componentMap.get('custom_model_data')
61-
if (customModelDataComponent?.data && typeof customModelDataComponent.data === 'number') {
62-
const customModelData = customModelDataComponent.data
63-
if (customModelDataDefinitions[customModelData]) {
61+
if (customModelDataComponent?.data) {
62+
let customModelData: number | undefined
63+
if (typeof customModelDataComponent.data === 'number') {
64+
customModelData = customModelDataComponent.data
65+
} else if (typeof customModelDataComponent.data === 'object'
66+
&& 'floats' in customModelDataComponent.data
67+
&& Array.isArray(customModelDataComponent.data.floats)
68+
&& customModelDataComponent.data.floats.length > 0) {
69+
customModelData = customModelDataComponent.data.floats[0]
70+
}
71+
if (customModelData && customModelDataDefinitions[customModelData]) {
6472
customModel = customModelDataDefinitions[customModelData]
6573
}
6674
}

0 commit comments

Comments
 (0)