@@ -10,6 +10,8 @@ import * as Backend from './Backend.js'
1010import chalk from 'chalk'
1111import { createSpinner } from 'nanospinner'
1212
13+ //D:\.MCAddons\projects\Firework Testing
14+
1315function CompileFile ( source , path , endPath , config ) {
1416 //console.log('Compiling entity from ' + source + ' to ' + endPath + ' with ' + path)
1517
@@ -48,7 +50,7 @@ export async function Start(path, com){
4850 const spinner = createSpinner ( 'Waiting for bridge to compile...' ) . start ( )
4951
5052 while ( ! fs . existsSync ( com + '/development_behavior_packs/' + projectName + ' BP' ) || ! fs . existsSync ( com + '/development_behavior_packs/' + projectName + ' BP/manifest.json' ) ) {
51- await ( sleep ( 1000 ) )
53+ await sleep ( 1000 )
5254 }
5355
5456 spinner . success ( )
@@ -59,18 +61,18 @@ export async function Start(path, com){
5961 await sleep ( 100 )
6062
6163 while ( ! fs . existsSync ( com + '/development_behavior_packs/' + projectName + ' BP' ) || ! fs . existsSync ( com + '/development_behavior_packs/' + projectName + ' BP/manifest.json' ) ) {
62- await ( sleep ( 100 ) )
64+ await sleep ( 100 )
6365 }
6466
65- try {
67+ // try{
6668 let mainfest = null
6769
6870 while ( ! mainfest || ! fs . existsSync ( com + '/development_behavior_packs/' + projectName + ' BP/entities/' ) ) {
6971 try {
7072 mainfest = JSON . parse ( fs . readFileSync ( com + '/development_behavior_packs/' + projectName + ' BP/manifest.json' ) )
7173 } catch { }
7274
73- await ( sleep ( 100 ) )
75+ await sleep ( 100 )
7476 }
7577
7678 if ( ! mainfest . firework || forced ) {
@@ -116,29 +118,44 @@ export async function Start(path, com){
116118 }
117119 }
118120
119- searchFolderForEntity ( com + '/development_behavior_packs/' + projectName + ' BP/entities')
120-
121+ searchFolderForEntity ( path + '/BP/entities' )
122+
121123 for ( let i = 0 ; i < files . length ; i ++ ) {
122124 const targetFileName = files [ i ] . substring ( 0 , files [ i ] . length - 5 ) + '.frw'
123125 const targetFilePath = com + '/development_behavior_packs/' + projectName + ' BP/firework/' + fileRelPaths [ i ] + targetFileName
124126 const sourceFilePath = com + '/development_behavior_packs/' + projectName + ' BP/entities/' + fileRelPaths [ i ] + files [ i ]
127+ const projectSourceFilePath = path + '/BP/firework/' + fileRelPaths [ i ] + targetFileName
125128
126- if ( fs . existsSync ( sourceFilePath ) ) {
127- if ( fs . existsSync ( targetFilePath ) ) {
128- const result = CompileFile ( sourceFilePath , targetFilePath , com + '/development_behavior_packs/' + projectName + ' BP' , JSON . parse ( fs . readFileSync ( path + '/.firework/config.json' ) ) )
129+ if ( ! fs . existsSync ( projectSourceFilePath ) ) {
130+ console . log ( chalk . hex ( '#ffc825' ) . bold ( 'Warning:' ) + ' Skipping ' + files [ i ] )
129131
130- if ( result instanceof Backend . Error ) {
131- console . log ( chalk . hex ( '#ea323c' ) . bold ( 'Error:' ) + ' ' + result . message )
132+ continue
133+ }
132134
133- break
134- } else {
135- console . log ( chalk . hex ( '#5ac54f' ) . bold ( `Compiled ${ targetFileName } !` ) )
136- }
137- } else {
138- //console.log(chalk.hex('#ffc825').bold('Warning:') + ' Could not find file for ' + targetFileName)
139- }
135+ const spinner = createSpinner ( 'Waiting for source of ' + files [ i ] + '...' ) . start ( )
136+
137+ while ( ! fs . existsSync ( sourceFilePath ) ) {
138+ await sleep ( 100 )
139+ }
140+
141+ spinner . success ( )
142+
143+ const spinner2 = createSpinner ( 'Waiting for target of ' + targetFileName + '...' ) . start ( )
144+
145+ while ( ! fs . existsSync ( targetFilePath ) ) {
146+ await sleep ( 100 )
147+ }
148+
149+ spinner2 . success ( )
150+
151+ const result = CompileFile ( sourceFilePath , targetFilePath , com + '/development_behavior_packs/' + projectName + ' BP' , JSON . parse ( fs . readFileSync ( path + '/.firework/config.json' ) ) )
152+
153+ if ( result instanceof Backend . Error ) {
154+ console . log ( chalk . hex ( '#ea323c' ) . bold ( 'Error:' ) + ' ' + result . message )
155+
156+ break
140157 } else {
141- // console.log(chalk.hex('#ffc825 ').bold('Warning:') + ' Could not find file for ' + files[i] )
158+ console . log ( chalk . hex ( '#5ac54f ' ) . bold ( `Compiled ${ targetFileName } !` ) )
142159 }
143160 }
144161
@@ -151,8 +168,8 @@ export async function Start(path, com){
151168
152169 fs . writeFileSync ( com + '/development_behavior_packs/' + projectName + ' BP/manifest.json' , JSON . stringify ( mainfest , null , 2 ) )
153170 }
154- } catch ( err ) {
155- console . log ( chalk . hex ( '#ffc825' ) . bold ( 'Warning:' ) + ' Ignored error: ' + err . toString ( ) )
156- }
171+ // }catch (err){
172+ // console.log(chalk.hex('#ffc825').bold('Warning:') + ' Ignored error: ' + err.toString())
173+ // }
157174 }
158175}
0 commit comments