@@ -220,6 +220,8 @@ export const BLUEPRINT_CODEC = new Blockbench.Codec('animated_java_blueprint', {
220220 console . log ( `Parsing Animated Java Blueprint from '${ path } '...` )
221221 if ( ! Project ) throw new Error ( 'No project to parse into' )
222222
223+ Project . loadingPromises = [ ]
224+
223225 Project . save_path = model . meta . save_location || path
224226
225227 if ( model . meta . box_uv !== undefined ) {
@@ -268,22 +270,32 @@ export const BLUEPRINT_CODEC = new Blockbench.Codec('animated_java_blueprint', {
268270 const defaultTexture = Texture . getDefault ( )
269271 for ( const element of model . elements ) {
270272 const newElement = OutlinerElement . fromSave ( element , true )
271- if ( newElement instanceof Cube ) {
272- for ( const face in newElement . faces ) {
273- if ( element . faces ) {
274- const texture =
275- element . faces [ face ] . texture !== undefined &&
276- Texture . all [ element . faces [ face ] . texture ]
277- if ( texture ) {
278- newElement . faces [ face ] . texture = texture . uuid
273+ switch ( true ) {
274+ case newElement instanceof Cube : {
275+ for ( const face in newElement . faces ) {
276+ if ( element . faces ) {
277+ const texture =
278+ element . faces [ face ] . texture !== undefined &&
279+ Texture . all [ element . faces [ face ] . texture ]
280+ if ( texture ) {
281+ newElement . faces [ face ] . texture = texture . uuid
282+ }
283+ } else if (
284+ defaultTexture &&
285+ newElement . faces &&
286+ newElement . faces [ face ] . texture !== undefined
287+ ) {
288+ newElement . faces [ face ] . texture = defaultTexture . uuid
279289 }
280- } else if (
281- defaultTexture &&
282- newElement . faces &&
283- newElement . faces [ face ] . texture !== undefined
284- ) {
285- newElement . faces [ face ] . texture = defaultTexture . uuid
286290 }
291+ break
292+ }
293+ case newElement instanceof AnimatedJava . API . TextDisplay :
294+ case newElement instanceof AnimatedJava . API . VanillaItemDisplay :
295+ case newElement instanceof AnimatedJava . API . VanillaBlockDisplay : {
296+ // ES-Lint doesn't like the types here for some reason, so I'm casing them to please it.
297+ Project . loadingPromises . push ( newElement . waitForReady ( ) as Promise < void > )
298+ break
287299 }
288300 }
289301 }
@@ -537,39 +549,51 @@ export const BLUEPRINT_FORMAT = new Blockbench.ModelFormat({
537549 }
538550 }
539551
552+ const thisProject = Project
540553 Project . variants ??= [ ]
541554 Project . last_used_export_namespace = Project . animated_java . export_namespace
542555 const updateBoundingBoxIntervalId = setInterval ( ( ) => {
543556 updateBoundingBox ( )
544557 } , 500 )
545558 events . UNLOAD . subscribe ( ( ) => clearInterval ( updateBoundingBoxIntervalId ) , true )
546559 events . UNINSTALL . subscribe ( ( ) => clearInterval ( updateBoundingBoxIntervalId ) , true )
547- requestAnimationFrame ( ( ) => {
548- Project ! . pluginMode = new Valuable ( Project ! . animated_java . enable_plugin_mode )
549- // Remove the default title
550- const element = document . querySelector ( '#tab_bar_list .icon-armor_stand.icon' )
551- element ?. remove ( )
552- // Custom title
553- void injectSvelteCompomponent ( {
554- elementSelector : ( ) => {
555- const titles = [
556- ...document . querySelectorAll ( `.project_tab[title="${ project . name } "]` ) ,
557- ]
558- if ( titles . length ) {
559- return titles [ 0 ]
560- }
561- } ,
562- prepend : true ,
563- svelteComponent : ProjectTitleSvelte ,
564- svelteComponentProperties : { pluginMode : Project ! . pluginMode } ,
565- } )
566560
567- Project ! . materials [ TRANSPARENT_TEXTURE . uuid ] = TRANSPARENT_TEXTURE_MATERIAL
568- TRANSPARENT_TEXTURE . updateMaterial ( )
561+ thisProject . materials [ TRANSPARENT_TEXTURE . uuid ] = TRANSPARENT_TEXTURE_MATERIAL
562+ TRANSPARENT_TEXTURE . updateMaterial ( )
569563
570- if ( Variant . all . length === 0 ) new Variant ( 'Default' , true )
571- Variant . selectDefault ( )
572- } )
564+ Project . loadingPromises ??= [ ]
565+ Project . loadingPromises . push (
566+ new Promise < void > ( resolve => {
567+ requestAnimationFrame ( ( ) => {
568+ thisProject . pluginMode = new Valuable (
569+ thisProject . animated_java . enable_plugin_mode
570+ )
571+ // Remove the default title
572+ const element = document . querySelector ( '#tab_bar_list .icon-armor_stand.icon' )
573+ element ?. remove ( )
574+ // Custom title
575+ void injectSvelteCompomponent ( {
576+ elementSelector : ( ) => {
577+ const titles = [
578+ ...document . querySelectorAll (
579+ `.project_tab[title="${ project . name } "]`
580+ ) ,
581+ ]
582+ if ( titles . length ) {
583+ return titles [ 0 ]
584+ }
585+ } ,
586+ prepend : true ,
587+ svelteComponent : ProjectTitleSvelte ,
588+ svelteComponentProperties : { pluginMode : thisProject . pluginMode } ,
589+ } )
590+
591+ if ( Variant . all . length === 0 ) new Variant ( 'Default' , true )
592+ Variant . selectDefault ( )
593+ } )
594+ resolve ( )
595+ } )
596+ )
573597 } ,
574598
575599 onActivation ( ) {
0 commit comments