Added a way to specify seam texture via arg

This commit is contained in:
Casey 2024-05-22 13:09:06 +03:00
parent 31cf003692
commit c3f9581b52
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 9 additions and 7 deletions

16
make.py
View File

@ -18,7 +18,6 @@ GLASS_OUTPUT_PATH = (
)
TEXTURES_PATH: str = "assets/minecraft/textures"
SEAM_TEXTURE_NAME: str = "block.dark_oak_planks"
GLASS_COLORS: list[str] = [
"black",
"blue",
@ -117,7 +116,7 @@ async def download_if_missing(url: str, path: Union[Path, str]):
progress.advance(task, fout.write(chunk))
async def main():
async def main(seam_texture: str = "block.dark_oak_planks"):
INPUT_PATH.mkdir(exist_ok=True)
TEXTURES_CACHE.mkdir(exist_ok=True)
GLASS_CACHE_SEAMLESS.mkdir(exist_ok=True)
@ -154,7 +153,7 @@ async def main():
fp_out.write(chunk)
return out_path
extract_texture(SEAM_TEXTURE_NAME)
extract_texture(seam_texture)
for color in GLASS_COLORS:
extract_texture(f"block.{color}_stained_glass")
@ -183,7 +182,7 @@ async def main():
ox, oy = (i % 8) * 16, (i // 8) * 16
ctm_list.append(im.crop((ox, oy, ox + 16, oy + 16)).convert("1"))
border_texture = Image.open(TEXTURES_CACHE / f"{SEAM_TEXTURE_NAME}.png")
border_texture = Image.open(TEXTURES_CACHE / f"{seam_texture}.png")
print("[ + ] Creating connected textures")
for color in GLASS_COLORS:
@ -195,16 +194,18 @@ async def main():
fp.write(f"matchBlocks=seasonsextras:{texture_name}\n")
fp.write(f"tiles=0-46\n")
fp.write(f"connect=block\n")
fp.write(f"resourceCondition=seasonextras:textures/block/{texture_name}.png\n")
fp.write(f"resourceCondition=seasonsextras:textures/block/{texture_name}.png\n")
with Image.open(GLASS_CACHE_SEAMLESS / f"{color}.png") as glass:
for i in range(47):
ctm = Image.composite(border_texture, glass, ctm_list[i])
ctm.save(out_path / f"{i}.png")
if i == 0:
ctm.save(OUTPUT_PATH / "assets/seasonsextras/textures/block/{texture_name}.png")
with (OUTPUT_PATH / "pack.mcmeta").open("w") as fp:
json.dump({
"pack": {
"pack_format": 15,
"description": "CTM support for Fabric Seasons Extras. Also, nicer textures in general"
"description": f"CTM support for Fabric Seasons Extras. {seam_texture}"
}
}, fp, indent=2, ensure_ascii=False)
@ -214,4 +215,5 @@ async def main():
zipf.write(file, Path(*file.parts[1:]))
if __name__ == "__main__":
asyncio.run(main())
from sys import argv
asyncio.run(main(*argv[1:]))