Remove unused wscripts
This commit is contained in:
parent
c5c2611aac
commit
ee8917d8ca
4 changed files with 0 additions and 267 deletions
|
|
@ -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}")
|
|
||||||
|
|
@ -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()
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
import json
|
|
||||||
|
|
||||||
TEMPLATE = """{
|
|
||||||
"type": "thermal:press",
|
|
||||||
"ingredients": [
|
|
||||||
{"tag": "<INPUT_ITEM>"},
|
|
||||||
{"item": "immersiveengineering:mold_rod"}
|
|
||||||
],
|
|
||||||
"result": [{"item": "<OUTPUT_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_ITEM>", input).replace("<OUTPUT_ITEM>", output)
|
|
||||||
)
|
|
||||||
|
|
@ -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": "<INPUT_ITEM>"}],
|
|
||||||
# "results": [{"item": "<OUTPUT_ITEM>"}],
|
|
||||||
# },
|
|
||||||
# },
|
|
||||||
# "multiservo_press_template": {
|
|
||||||
# "_root": "./multiservo_press",
|
|
||||||
# "_templ": {
|
|
||||||
# "type": "thermal:press",
|
|
||||||
# "ingredient": {"tag": "<INPUT_ITEM>"},
|
|
||||||
# "result": [{"item": "<OUTPUT_ITEM>"}],
|
|
||||||
# },
|
|
||||||
# },
|
|
||||||
"metal_press_template": {
|
|
||||||
"_root": "./metal_press",
|
|
||||||
"_templ": {
|
|
||||||
"type": "immersiveengineering:metal_press",
|
|
||||||
"mold": {"item": "immersiveengineering:mold_plate"},
|
|
||||||
"input": {"tag": "<INPUT_ITEM>"},
|
|
||||||
"result": {"item": "<OUTPUT_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("<INPUT_ITEM>", tag).replace("<OUTPUT_ITEM>", TAGS[tag])
|
|
||||||
fh.write(data)
|
|
||||||
Loading…
Reference in a new issue