@@ -26,29 +26,7 @@ export default async function compileResourcePack(options: {
26
26
lastUsedExportNamespace ,
27
27
options . resourcePackFolder
28
28
)
29
- if ( aj . resource_pack_export_mode === 'raw' ) {
30
- ajmeta . read ( )
31
-
32
- PROGRESS_DESCRIPTION . set ( 'Removing Old Resource Pack Files...' )
33
- PROGRESS . set ( 0 )
34
- MAX_PROGRESS . set ( ajmeta . oldFiles . size )
35
-
36
- const removedFolders = new Set < string > ( )
37
- for ( const file of ajmeta . oldFiles ) {
38
- if ( fs . existsSync ( file ) ) await fs . promises . unlink ( file )
39
- let folder = PathModule . dirname ( file )
40
- while (
41
- ! removedFolders . has ( folder ) &&
42
- fs . existsSync ( folder ) &&
43
- ( await fs . promises . readdir ( folder ) ) . length === 0
44
- ) {
45
- await fs . promises . rm ( folder , { recursive : true } )
46
- removedFolders . add ( folder )
47
- folder = PathModule . dirname ( folder )
48
- }
49
- PROGRESS . set ( PROGRESS . get ( ) + 1 )
50
- }
51
- }
29
+ ajmeta . read ( )
52
30
53
31
const exportedFiles = new Map < string , string | Buffer > ( )
54
32
@@ -65,6 +43,7 @@ export default async function compileResourcePack(options: {
65
43
'assets/minecraft/atlases/blocks.json'
66
44
)
67
45
let blockAtlas : ITextureAtlas = { sources : [ ] }
46
+ console . log ( 'Block atlas file:' , blockAtlasFile , fs . existsSync ( blockAtlasFile ) )
68
47
if ( fs . existsSync ( blockAtlasFile ) ) {
69
48
const content = await fs . promises . readFile ( blockAtlasFile , 'utf-8' ) . catch ( ( ) => {
70
49
throw new IntentionalExportError (
@@ -78,6 +57,9 @@ export default async function compileResourcePack(options: {
78
57
`Failed to parse block atlas file: ${ e . message as string } `
79
58
)
80
59
}
60
+ console . log ( 'Pre-existing Block atlas:' , blockAtlas )
61
+ } else {
62
+ console . log ( 'Block atlas file does not exist. Creating a new one.' )
81
63
}
82
64
if (
83
65
blockAtlas . sources . some (
@@ -95,6 +77,7 @@ export default async function compileResourcePack(options: {
95
77
prefix : 'blueprint/' ,
96
78
} )
97
79
}
80
+ console . log ( 'Block atlas:' , blockAtlas )
98
81
exportedFiles . set ( blockAtlasFile , autoStringify ( blockAtlas ) )
99
82
100
83
// Internal Models
@@ -180,6 +163,28 @@ export default async function compileResourcePack(options: {
180
163
// Do nothing
181
164
console . log ( 'Plugin mode enabled. Skipping resource pack export.' )
182
165
} else if ( aj . resource_pack_export_mode === 'raw' ) {
166
+ // Clean up old files
167
+ PROGRESS_DESCRIPTION . set ( 'Removing Old Resource Pack Files...' )
168
+ PROGRESS . set ( 0 )
169
+ MAX_PROGRESS . set ( ajmeta . oldFiles . size )
170
+
171
+ const removedFolders = new Set < string > ( )
172
+ for ( const file of ajmeta . oldFiles ) {
173
+ if ( fs . existsSync ( file ) ) await fs . promises . unlink ( file )
174
+ let folder = PathModule . dirname ( file )
175
+ while (
176
+ ! removedFolders . has ( folder ) &&
177
+ fs . existsSync ( folder ) &&
178
+ ( await fs . promises . readdir ( folder ) ) . length === 0
179
+ ) {
180
+ await fs . promises . rm ( folder , { recursive : true } )
181
+ removedFolders . add ( folder )
182
+ folder = PathModule . dirname ( folder )
183
+ }
184
+ PROGRESS . set ( PROGRESS . get ( ) + 1 )
185
+ }
186
+
187
+ // Write new files
183
188
ajmeta . files = new Set ( exportedFiles . keys ( ) )
184
189
ajmeta . write ( )
185
190
0 commit comments