@@ -5,8 +5,8 @@ import { IRenderedNodes, IRenderedRig } from './rigRenderer'
5
5
import { sortObjectKeys , zip } from './util'
6
6
7
7
interface IPredicateItemModel {
8
- parent : string
9
- textures : any
8
+ parent ? : string
9
+ textures : Record < string , string >
10
10
overrides : Array < {
11
11
predicate : { custom_model_data : number }
12
12
model : string
@@ -19,8 +19,8 @@ class PredicateItemModel {
19
19
private overrides = new Map < number , string > ( )
20
20
private externalOverrides = new Map < number , string > ( )
21
21
public rigs : Record < string , number [ ] > = { }
22
-
23
- // constructor() {}
22
+ public parent ? = 'item/generated'
23
+ public textures : IPredicateItemModel [ 'textures' ] = { }
24
24
25
25
setOverride ( id : number , model : string ) {
26
26
this . overrides . set ( id , model )
@@ -52,6 +52,11 @@ class PredicateItemModel {
52
52
// TODO Inform the user that they are attempting to merge into a non-animated_java model. And give them the option to cancel.
53
53
}
54
54
55
+ // Assert parent
56
+ if ( file . parent ) this . parent = file . parent
57
+ // Assert textures
58
+ if ( file . textures ) this . textures = file . textures
59
+
55
60
// Assert important fields
56
61
file . overrides ??= [ ]
57
62
file . animated_java ??= { }
@@ -99,10 +104,13 @@ class PredicateItemModel {
99
104
const exportNamespace = Project ! . animated_java . export_namespace
100
105
101
106
return {
102
- parent : 'item/generated' ,
103
- textures : {
104
- layer0 : `${ displayItemNamespace } :item/${ displayItemName } ` ,
105
- } ,
107
+ parent : this . parent ,
108
+ textures :
109
+ Object . keys ( this . textures ) . length > 0
110
+ ? this . textures
111
+ : {
112
+ layer0 : `${ displayItemNamespace } :item/${ displayItemName } ` ,
113
+ } ,
106
114
overrides : [ ...this . externalOverrides . entries ( ) , ...this . overrides . entries ( ) ]
107
115
. sort ( ( a , b ) => a [ 0 ] - b [ 0 ] )
108
116
. map ( ( [ id , model ] ) => ( {
@@ -297,17 +305,17 @@ export async function compileResourcePack(options: {
297
305
}
298
306
}
299
307
300
- // Write display item model
301
- console . log ( 'Display Item Model' , displayItemModel . toJSON ( ) )
302
- exportedFiles . set ( displayItemPath , autoStringify ( displayItemModel . toJSON ( ) ) )
303
-
304
308
if ( aj . enable_plugin_mode ) {
305
309
// Do nothing
306
310
console . log ( 'Plugin mode enabled. Skipping resource pack export.' )
307
311
} else if ( aj . resource_pack_export_mode === 'raw' ) {
308
312
ajmeta . files = new Set ( exportedFiles . keys ( ) )
309
313
ajmeta . write ( )
310
314
315
+ // Since we don't want to erase the display item every export, we add it's model file after the files have been added to the ajmeta.
316
+ console . log ( 'Display Item Model' , displayItemModel . toJSON ( ) )
317
+ exportedFiles . set ( displayItemPath , autoStringify ( displayItemModel . toJSON ( ) ) )
318
+
311
319
PROGRESS_DESCRIPTION . set ( 'Writing Resource Pack...' )
312
320
PROGRESS . set ( 0 )
313
321
MAX_PROGRESS . set ( exportedFiles . size )
0 commit comments