diff --git a/scripts/cleanup.py b/scripts/cleanup.py deleted file mode 100644 index c8a4775..0000000 --- a/scripts/cleanup.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Cleans up existing datapack files to replace empty / {} files with properly formatted -empty recipes. -""" - -import json -import os - -for root, dirs, files in os.walk("./data"): - for file in files: - try: - with open(f"{root}/{file}", "r", encoding="utf-8") as fh: - raw_data = fh.read().strip() - if raw_data and json.loads(raw_data) != {}: - print(f"Skipped {root}/{file} - has content") - continue - data = { - "type": "minecraft:crafting_shapeless", - "ingredients": [{"item": "minecraft:air"}], - "result": {"item": "minecraft:air"}, - } - with open(f"{root}/{file}", "w", encoding="utf-8") as fh: - fh.write(json.dumps(data)) - except Exception as exc: - print(f"Failed to clean {root}/{file}: {exc}") diff --git a/scripts/emendatus_unification.py b/scripts/emendatus_unification.py deleted file mode 100644 index 7da2d7f..0000000 --- a/scripts/emendatus_unification.py +++ /dev/null @@ -1,137 +0,0 @@ -import json -import os -import sys -import zipfile -from json.decoder import JSONDecodeError -from typing import Collection, Dict, List, Tuple - -from deepdiff import DeepDiff - -EMENDATUS_METALS = [ - "copper", - "tin", - "silver", - "lead", - "nickel", - "uranium", - "osmium", - "aluminum", - "zinc", - "cobalt", - "bronze", - "brass", - "constantan", - "electrum", - "steel", - "invar", - "signalum", - "lumium", - "enderium", -] - -MATERIAL_TYPES = ["dust", "ingot", "nugget"] - - -def _repl_with_ee_variant(item: str) -> str: - try: - namespace, path = item.split(":") - except ValueError: - # Means that it's a minecraft item because namespace not included - return item - - # Already converted case - if namespace == "emendatusenigmatica": - return item - - for metal in EMENDATUS_METALS: - for mat in MATERIAL_TYPES: - if path == f"{metal}_{mat}" or path == f"{mat}_{metal}": - return f"emendatusenigmatica:{metal}_{mat}" - return item - - -def _walk_json(obj): - """Walks a json file""" - ret = {} - if isinstance(obj, dict): - for key, val in obj.items(): - if isinstance(val, dict): - rest = _walk_json(val) - ret[key] = rest - elif isinstance(val, list): - rest = [_walk_json(x) for x in val] - ret[key] = rest - elif key == "item": # leaf - ret[key] = _repl_with_ee_variant(val) - - return ret - elif isinstance(obj, list): - ret = [] - for val in obj: - if isinstance(val, dict): - rest = _walk_json(val) - ret.append(rest) - elif isinstance(val, list): - rest = [_walk_json(x) for x in val] - ret.append(rest) - else: - return val - return ret - else: - return obj - - -def main() -> None: - """The main runfunction of this file""" - - for root, _, files in os.walk("./mods"): - for file in files: - if not file.endswith(".jar"): - continue - - with zipfile.ZipFile(f"{root}/{file}", "r") as zip_fh: - recipe_files: List[zipfile.ZipInfo] = [] - # Only include the files that end with .json and are in the recipes folder somewhere - for zip_item in zip_fh.infolist(): - if ( - "data/" in zip_item.filename - and "recipes/" in zip_item.filename - and zip_item.filename.endswith(".json") - ): - recipe_files.append(zip_item) - - for recipe in recipe_files: - try: - data = zip_fh.read(recipe).decode("utf-8") - json_data = json.loads(data) - except JSONDecodeError: - print(f"Recipe {recipe.filename} in {file} is not a valid JSON") - continue - # Iterate over every possible K/V Pair in the JSON - walked = _walk_json(json_data) - ddiff = DeepDiff(walked, json_data, ignore_order=True) - if ddiff != {}: - print(ddiff) - # TODO: verify if any change was made - # TODO: verify that file doesn't already exist before writing - break - - # for metal in EMENDATUS_METALS: - # for mat in MATERIAL_TYPES: - # if not ( - # "crafting_shaped" in data - # or "crafting_shapeless" in data - # ): - # if f"{metal}_{mat}" in data or f"{mat}_{metal}" in data: - # if not f"emendatusenigmatica:{metal}_{mat}" in data: - # print( - # f"Found the following non-Emendatus {mat} output:" - # ) - # print(data) - # print( - # "---------------------------------------------" - # ) - - -if __name__ == "__main__": - main() diff --git a/scripts/gen_rod_molds.py b/scripts/gen_rod_molds.py deleted file mode 100644 index 7ff3b35..0000000 --- a/scripts/gen_rod_molds.py +++ /dev/null @@ -1,43 +0,0 @@ -import json - -TEMPLATE = """{ - "type": "thermal:press", - "ingredients": [ - {"tag": ""}, - {"item": "immersiveengineering:mold_rod"} - ], - "result": [{"item": "", "count": 2}] -}""" - -METALS = [ - "iron", - "gold", - "copper", - "tin", - "aluminum", - "silver", - "lead", - "nickel", - "uranium", - "osmium", - "zinc", - "cobalt", - "bronze", - "constantan", - "brass", - "electrum", - "steel", - "invar", - "signalum", - "lumium", - "enderium", -] - -for metal in METALS: - input = f"forge:ingots/{metal}" - output = f"emendatusenigmatica:{metal}_rod" - - with open(f"./{metal}_rod.json", "w") as fh: - fh.write( - TEMPLATE.replace("", input).replace("", output) - ) diff --git a/scripts/plate_compat_recipes.py b/scripts/plate_compat_recipes.py deleted file mode 100644 index 2cd8aa2..0000000 --- a/scripts/plate_compat_recipes.py +++ /dev/null @@ -1,62 +0,0 @@ -import json - -TAGS = { - "forge:ingots/netherite": "createdeco:netherite_sheet", - # "forge:ingots/iron": "emendatusenigmatica:iron_plate", - # "forge:ingots/gold": "emendatusenigmatica:gold_plate", - # "forge:ingots/copper": "emendatusenigmatica:copper_plate", - # "forge:ingots/silver": "emendatusenigmatica:silver_plate", - # "forge:ingots/lead": "emendatusenigmatica:lead_plate", - # "forge:ingots/nickel": "emendatusenigmatica:nickel_plate", - # "forge:ingots/osmium": "emendatusenigmatica:osmium_plate", - # "forge:ingots/tin": "emendatusenigmatica:tin_plate", - # "forge:ingots/zinc": "emendatusenigmatica:zinc_plate", - # "forge:ingots/cobalt": "emendatusenigmatica:cobalt_plate", - # "forge:ingots/bronze": "emendatusenigmatica:bronze_plate", - # "forge:ingots/constantan": "emendatusenigmatica:constantan_plate", - # "forge:ingots/electrum": "emendatusenigmatica:electrum_plate", - # "forge:ingots/invar": "emendatusenigmatica:invar_plate", - "forge:ingots/signalum": "emendatusenigmatica:signalum_plate", - "forge:ingots/lumium": "emendatusenigmatica:lumium_plate", - "forge:ingots/enderium": "emendatusenigmatica:enderium_plate", -} - - -TEMPLATES = { - # "create_pressing_template": { - # "_root": "./pressing", - # "_templ": { - # "type": "create:pressing", - # "ingredients": [{"tag": ""}], - # "results": [{"item": ""}], - # }, - # }, - # "multiservo_press_template": { - # "_root": "./multiservo_press", - # "_templ": { - # "type": "thermal:press", - # "ingredient": {"tag": ""}, - # "result": [{"item": ""}], - # }, - # }, - "metal_press_template": { - "_root": "./metal_press", - "_templ": { - "type": "immersiveengineering:metal_press", - "mold": {"item": "immersiveengineering:mold_plate"}, - "input": {"tag": ""}, - "result": {"item": ""}, - "energy": 2400, - }, - }, -} - - -for tag in TAGS: - for template in TEMPLATES: - output = TAGS[tag] - file_name = output[output.index(":") + 1 :] - with open(f"{TEMPLATES[template]['_root']}/{file_name}.json", "w") as fh: - data = json.dumps(TEMPLATES[template]["_templ"]) - data = data.replace("", tag).replace("", TAGS[tag]) - fh.write(data)