Dynamically customize metadata

This commit is contained in:
Martin Prokoph
2024-12-26 12:01:07 +01:00
parent 5e7137ff6f
commit 8c9896bb5f
6 changed files with 23 additions and 7 deletions

View File

@@ -356,6 +356,14 @@ def generateCarpetAssets(carpet):
with open(block_model_file, "w") as f:
json.dump(block_model_data, f, indent=4)
def writeMetadata(args):
edition = args.edition
if isinstance(edition, list): edition = " ".join(args.edition)
with open("./input/pack.mcmeta") as infile, open("pack.mcmeta", "w") as outfile:
for line in infile:
line = line.replace("${version}", args.version).replace("${edition}", edition)
outfile.write(line)
# See https://stackoverflow.com/a/1855118
def zipdir(path, ziph):
# ziph is zipfile handle
@@ -366,8 +374,8 @@ def zipdir(path, ziph):
os.path.join(path, '..')))
# Creates a compressed zip file
def makeZip(version):
with zipfile.ZipFile('Better-Leaves-Lite-'+version+".zip", 'w', zipfile.ZIP_DEFLATED) as zipf:
def makeZip(filename):
with zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
zipdir('assets/', zipf)
zipf.write('pack.mcmeta')
zipf.write('pack.png')
@@ -383,7 +391,8 @@ if __name__ == '__main__':
epilog='Feel free to ask for help at http://discord.midnightdust.eu/')
parser.add_argument('version', type=str)
parser.add_argument('--legacy', '-l', action='store_true')
parser.add_argument('edition', nargs="*", type=str, default="§cCustom Edition", help="Define your edition name")
parser.add_argument('--legacy', '-l', action='store_true', help="Use legacy models (from 8.1) for all leaves")
args = parser.parse_args()
print(f"Arguments: {args}")
@@ -398,9 +407,10 @@ if __name__ == '__main__':
f.close()
autoGen(data, args);
writeMetadata(args)
print()
print("Zipping it up...")
makeZip(args.version);
makeZip(f"Better-Leaves-{args.version}.zip");
print("Done!")
print("--- Finished in %s seconds ---" % (round((time.perf_counter() - start_time)*1000)/1000))

7
input/pack.mcmeta Normal file
View File

@@ -0,0 +1,7 @@
{
"pack": {
"pack_format": 15,
"supported_formats": [15, 99],
"description": "§2Version ${version} §a${edition}\n§e©Motschen 2024 | MIT Licence"
}
}

View File

@@ -1 +0,0 @@
{"meta":{"format_version":"4.10","model_format":"java_block","box_uv":false},"name":"leaves","parent":"block/block","ambientocclusion":true,"front_gui_light":false,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":32,"height":32},"elements":[{"name":"cube","box_uv":false,"rescale":false,"locked":false,"light_emission":0,"render_order":"default","allow_mirror_modeling":true,"from":[0,0,0],"to":[16,16,16],"autouv":0,"color":2,"origin":[0,0,0],"faces":{"north":{"uv":[8,8,24,24],"tint":0,"cullface":"north","texture":0},"east":{"uv":[8,8,24,24],"tint":0,"cullface":"east","texture":0},"south":{"uv":[8,8,24,24],"tint":0,"cullface":"south","texture":0},"west":{"uv":[8,8,24,24],"tint":0,"cullface":"west","texture":0},"up":{"uv":[8,8,24,24],"tint":0,"cullface":"up","texture":0},"down":{"uv":[8,8,24,24],"tint":0,"cullface":"down","texture":0}},"type":"cube","uuid":"0677d295-59fc-3179-85fb-172d66f519c0"},{"name":"cube","box_uv":false,"rescale":false,"locked":false,"light_emission":0,"render_order":"default","allow_mirror_modeling":true,"from":[-5.5,-6,14],"to":[26.5,22,14],"autouv":0,"color":4,"rotation":[0,45,0],"origin":[2,0,14],"faces":{"north":{"uv":[0,2,32,30],"tint":0,"texture":0},"east":{"uv":[0,0,0,0],"texture":null},"south":{"uv":[0,2,32,30],"tint":0,"texture":0},"west":{"uv":[0,0,0,0],"texture":null},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"b54ae4f7-8bc2-fc49-57d2-cc620245963f"},{"name":"cube","box_uv":false,"rescale":false,"locked":false,"light_emission":0,"render_order":"default","allow_mirror_modeling":true,"from":[-5.5,-6,2],"to":[26.5,22,2],"autouv":0,"color":4,"rotation":[0,-45,0],"origin":[2,0,2],"faces":{"north":{"uv":[0,2,32,30],"tint":0,"texture":0},"east":{"uv":[0,0,0,0],"texture":null},"south":{"uv":[0,2,32,30],"tint":0,"texture":0},"west":{"uv":[0,0,0,0],"texture":null},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"c1a53dc9-7942-a72f-b289-5ad6c45f762a"}],"outliner":["0677d295-59fc-3179-85fb-172d66f519c0","b54ae4f7-8bc2-fc49-57d2-cc620245963f","c1a53dc9-7942-a72f-b289-5ad6c45f762a"],"textures":[{"path":"","name":"#all","folder":"","namespace":"","id":"all","group":"","width":16,"height":16,"uv_width":32,"uv_height":32,"particle":true,"use_as_default":false,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"3d387c5e-c9eb-ff67-154e-060ff81133ae","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAHtJREFUOE/dUzEOwCAI1IUfOPH/nykLvsCFBpsmDDQRupUFFo47OKqISEnGGKNUBdACAMpaK5SJ6AZg5nCzDptznjNAxC3UDgsxaK1tACv3rww8rXri4x1429aTHV/BTrJNKQZvYI9jXR98ZhD5iZATvUfbTuy9ixbZuAARBIdMI/Rl8wAAAABJRU5ErkJggg=="},{"path":"/home/martin/Dokumente/GitHub/BetterLeavesLite/assets/minecraft/textures/block/oak_leaves.png","name":"oak_leaves.png","folder":"block","namespace":"minecraft","id":"1","group":"","width":32,"height":32,"uv_width":32,"uv_height":32,"particle":false,"use_as_default":false,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"898d09b0-bc9e-012e-77bc-08939e1b0a64","relative_path":"../../textures/block/oak_leaves.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAlFJREFUWEe1V8tpAzEU1FZgUsKSFOBLGjABn31LAYZsA8E1mDSwgRSQm8+G4EoStoTgCjaMYMTsi7Raee1cgm3Ne0/zfqPKFf4126bfPG9c99N5ZPPSVLvXXV8/1K777tz+bV+VmCw67B1um54OFncLB8cIon1vw/f4fPw69uunddZ+9gCc0TgMI4D2ow0OcevVeuXgDOdwhgFOCSIbAIycjid3/j17u3CuDpCK+r72ATAVNgjgU6mJBsDI6Rw0M9/KBr7jWaYGaSEjMbytj38BKAg30xum2NC0AIMbI+gY3tZFNADrFCA45/f4T5pBO25FivUccRavQYymQOmGYdJHA7YjNAgWJVMXw+O3EACMLR+X4WYxuplvDYwMoEhL8GTQBwCDaCf2dIpunQN2BlyCB2OBAe3hGF2aazKQmgFT8WDBB8Aq1hbRIUKGdBYoS4fPw2A+aHsqwxaPOhkUIeuAhWPTo7MeQXEAMfBL8H606oTD59iMV+e2QOfgPQNj+cVQYZ/rJuSQ4TbkGVsfOXxgQG+t0xA3t7nTeaAjWLuI0zCHDwxwn+t6ZZVz8tHZmB4oxYcVGtvnOpK10KbqgSl4v0Jz+3yuHhjDewam7PO5eiCFH+wCUJvb53P1gMUPJiHZGNvnMXVUogcsPnRByT6fqwcUH1KAYizd51fVA5z73NO31AO69AbLiCv51npAlXVSkln5dU09kGTg1nog9jbIPkxUrs3RA0UPE2VC16t2ifbzmB6wD5HswyQGYIuW6oEpL+VsCmxAVnDG9EDu1vr7H2D/VKRfkhR8AAAAAElFTkSuQmCC"}]}

View File

@@ -2,6 +2,6 @@
"pack": {
"pack_format": 15,
"supported_formats": [15, 99],
"description": "§2Version 0.1 §aby Motschen §e©Motschen 2024 | MIT Licence"
"description": "§2Version 9.0 §aVanilla Edition\n§e©Motschen 2024 | MIT Licence"
}
}
}

BIN
pack.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 20 KiB