@@ -150,7 +150,6 @@ export type AnyRenderedNode = IRenderedNodes[keyof IRenderedNodes]
150
150
export interface IRenderedVariantModel {
151
151
model : IRenderedModel | null
152
152
custom_model_data : number
153
- model_path : string
154
153
resource_location : string
155
154
}
156
155
@@ -350,7 +349,6 @@ function renderGroup(
350
349
display : { head : { rotation : [ 0 , 180 , 0 ] } } ,
351
350
} ,
352
351
custom_model_data : - 1 , // This is calculated when constructing the resource pack.
353
- model_path : path ,
354
352
resource_location : parsed . resourceLocation ,
355
353
}
356
354
}
@@ -554,20 +552,25 @@ function renderCamera(camera: ICamera, rig: IRenderedRig) {
554
552
function renderVariantModels ( variant : Variant , rig : IRenderedRig ) {
555
553
const models : Record < string , IRenderedVariantModel > = { }
556
554
555
+ const defaultVariant = Variant . getDefault ( )
556
+ const defaultModels = rig . variants [ defaultVariant . uuid ] . models
557
+
558
+ // debugger
557
559
for ( const [ uuid , bone ] of Object . entries ( rig . nodes ) ) {
558
560
if ( bone . type !== 'bone' ) continue
559
561
if ( variant . excludedNodes . find ( v => v . value === uuid ) ) continue
560
562
const textures : IRenderedModel [ 'textures' ] = { }
561
563
562
- // Is set false if any texture other than the internal transparency texture is found.
563
- let isTransparent = true
564
+ let isOnlyTransparent = true
565
+ const unreplacedTextures = new Set < string > ( Object . keys ( defaultModels [ uuid ] . model ! . textures ) )
564
566
565
567
for ( const [ fromUUID , toUUID ] of variant . textureMap . map . entries ( ) ) {
566
568
const fromTexture = Texture . all . find ( t => t . uuid === fromUUID )
567
569
if ( ! fromTexture ) throw new Error ( `From texture not found: ${ fromUUID } ` )
568
570
if ( toUUID === TRANSPARENT_TEXTURE . uuid ) {
569
571
textures [ fromTexture . id ] = TRANSPARENT_TEXTURE_RESOURCE_LOCATION
570
572
rig . textures [ TRANSPARENT_TEXTURE . id ] = TRANSPARENT_TEXTURE
573
+ unreplacedTextures . delete ( fromTexture . id )
571
574
} else {
572
575
const toTexture = Texture . all . find ( t => t . uuid === toUUID )
573
576
if ( ! toTexture ) throw new Error ( `To texture not found: ${ toUUID } ` )
@@ -576,12 +579,22 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
576
579
rig
577
580
) . resourceLocation
578
581
rig . textures [ toTexture . id ] = toTexture
579
- isTransparent = false
582
+ isOnlyTransparent = false
580
583
}
581
584
}
582
585
583
- // Don't export models without any texture changes, or that are fully transparent.
584
- if ( isTransparent || Object . keys ( textures ) . length === 0 ) continue
586
+ // Don't export models without any texture changes
587
+ if ( Object . keys ( textures ) . length === 0 ) continue
588
+
589
+ // Use empty model if all textures are transparent
590
+ if ( isOnlyTransparent && unreplacedTextures . size === 0 ) {
591
+ models [ uuid ] = {
592
+ model : null ,
593
+ custom_model_data : 1 ,
594
+ resource_location : 'animated_java:empty' ,
595
+ }
596
+ continue
597
+ }
585
598
586
599
const modelParent = PathModule . join (
587
600
rig . model_export_folder ,
@@ -609,7 +622,6 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
609
622
textures,
610
623
} ,
611
624
custom_model_data : - 1 , // This is calculated when constructing the resource pack.
612
- model_path : modelPath ,
613
625
resource_location : parsedModelPath . resourceLocation ,
614
626
}
615
627
}
0 commit comments