Skip to content

Commit d03c2b6

Browse files
committed
🚧 Add a non-generated item model warning.
1 parent 2979e77 commit d03c2b6

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/components/blueprintSettingsDialog.svelte

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
2020
import fontUrl from '../assets/MinecraftFull.ttf'
2121
import { resolvePath } from '../util/fileUtil'
22+
import { getJSONAsset } from '../systems/minecraft/assetManager'
23+
import type { IItemModel } from '../systems/minecraft/model'
24+
2225
if (![...document.fonts.keys()].some(v => v.family === 'MinecraftFull')) {
2326
void new FontFace('MinecraftFull', fontUrl, {}).load().then(font => {
2427
document.fonts.add(font)
@@ -118,6 +121,32 @@
118121
),
119122
}
120123
} else {
124+
let asset: IItemModel
125+
try {
126+
asset = getJSONAsset(
127+
'assets/minecraft/models/item/' + value.replace('minecraft:', '') + '.json',
128+
)
129+
} catch (e) {
130+
console.error(e)
131+
return {
132+
type: 'error',
133+
message: translate(
134+
'dialog.blueprint_settings.display_item.error.item_model_not_found',
135+
),
136+
}
137+
}
138+
139+
if (
140+
!(asset.parent === 'item/generated' || asset.parent === 'minecraft:item/generated')
141+
) {
142+
return {
143+
type: 'warning',
144+
message: translate(
145+
'dialog.blueprint_settings.display_item.warning.item_model_not_generated',
146+
),
147+
}
148+
}
149+
121150
return { type: 'success', message: '' }
122151
}
123152
}
@@ -501,7 +530,7 @@
501530
/>
502531

503532
<NumberSlider
504-
label={translate('dialog.blueprint_settings.custom_model_data_offset.title',)}
533+
label={translate('dialog.blueprint_settings.custom_model_data_offset.title')}
505534
tooltip={translate('dialog.blueprint_settings.custom_model_data_offset.description')}
506535
bind:value={customModelDataOffset}
507536
/>

src/lang/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ animated_java.dialog.blueprint_settings.display_item.error.no_item_selected: No
102102
animated_java.dialog.blueprint_settings.display_item.error.invalid_item_id.no_namespace: The provided item ID is invalid! Item IDs should be in the format namespace:item_id.
103103
animated_java.dialog.blueprint_settings.display_item.error.invalid_item_id.whitespace: The provided item ID is invalid! Item IDs should not contain any whitespace.
104104
animated_java.dialog.blueprint_settings.display_item.warning.item_does_not_exist: The selected item does not exist in vanilla!
105+
animated_java.dialog.blueprint_settings.display_item.warning.item_model_not_generated: The selected item does not use 'minecraft:item/generated' as its parent. This may cause model issues in-game.
106+
animated_java.dialog.blueprint_settings.display_item.error.item_model_not_found: The selected item does not have a model file in the vanilla resource pack!
105107

106108
animated_java.dialog.blueprint_settings.custom_model_data_offset.title: CMD Offset
107109
animated_java.dialog.blueprint_settings.custom_model_data_offset.description: The offset to use for the Custom Model Data of the Display Item. Allows multiple Blueprints on the same item, but in separate, unaffiliated Resource Packs.

0 commit comments

Comments
 (0)