@@ -356,6 +356,14 @@ def generateCarpetAssets(carpet):
356
356
with open (block_model_file , "w" ) as f :
357
357
json .dump (block_model_data , f , indent = 4 )
358
358
359
+ def writeMetadata (args ):
360
+ edition = args .edition
361
+ if isinstance (edition , list ): edition = " " .join (args .edition )
362
+ with open ("./input/pack.mcmeta" ) as infile , open ("pack.mcmeta" , "w" ) as outfile :
363
+ for line in infile :
364
+ line = line .replace ("${version}" , args .version ).replace ("${edition}" , edition )
365
+ outfile .write (line )
366
+
359
367
# See https://stackoverflow.com/a/1855118
360
368
def zipdir (path , ziph ):
361
369
# ziph is zipfile handle
@@ -366,8 +374,8 @@ def zipdir(path, ziph):
366
374
os .path .join (path , '..' )))
367
375
368
376
# Creates a compressed zip file
369
- def makeZip (version ):
370
- with zipfile .ZipFile ('Better-Leaves-Lite-' + version + ".zip" , 'w' , zipfile .ZIP_DEFLATED ) as zipf :
377
+ def makeZip (filename ):
378
+ with zipfile .ZipFile (filename , 'w' , zipfile .ZIP_DEFLATED ) as zipf :
371
379
zipdir ('assets/' , zipf )
372
380
zipf .write ('pack.mcmeta' )
373
381
zipf .write ('pack.png' )
@@ -383,7 +391,8 @@ def makeZip(version):
383
391
epilog = 'Feel free to ask for help at http://discord.midnightdust.eu/' )
384
392
385
393
parser .add_argument ('version' , type = str )
386
- parser .add_argument ('--legacy' , '-l' , action = 'store_true' )
394
+ parser .add_argument ('edition' , nargs = "*" , type = str , default = "§cCustom Edition" , help = "Define your edition name" )
395
+ parser .add_argument ('--legacy' , '-l' , action = 'store_true' , help = "Use legacy models (from 8.1) for all leaves" )
387
396
args = parser .parse_args ()
388
397
389
398
print (f"Arguments: { args } " )
@@ -398,9 +407,10 @@ def makeZip(version):
398
407
f .close ()
399
408
400
409
autoGen (data , args );
410
+ writeMetadata (args )
401
411
print ()
402
412
print ("Zipping it up..." )
403
- makeZip (args .version );
413
+ makeZip (f"Better-Leaves- { args .version } .zip" );
404
414
print ("Done!" )
405
415
print ("--- Finished in %s seconds ---" % (round ((time .perf_counter () - start_time )* 1000 )/ 1000 ))
406
416
0 commit comments