Clean up .py scripts

This commit is contained in:
oitsjustjose 2022-01-09 22:52:59 -06:00
commit 2d3bd212e7
3 changed files with 0 additions and 77 deletions

View file

@ -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}")

View file

@ -1,77 +0,0 @@
import json
DATA = [{
"modid": "atmospheric",
"name": "morado",
"tag": "morado_logs",
"plank": "morado_planks"
}, {
"modid": "atmospheric",
"name": "rosewood",
"tag": "rosewood_logs",
"plank": "rosewood_planks"
}, {
"modid": "atmospheric",
"name": "yucca",
"tag": "yucca_logs",
"plank": "yucca_planks"
}, {
"modid": "upgrade_aquatic",
"name": "river",
"tag": "river_logs",
"plank": "river_planks"
}, {
"modid": "upgrade_aquatic",
"name": "driftwood",
"tag": "driftwood_logs",
"plank": "driftwood_planks"
}, {
"modid": "autumnity",
"name": "maple",
"tag": "maple_logs",
"plank": "maple_planks"
}, {
"modid": "enhanced_mushrooms",
"name": "red_mushroom",
"tag": "red_mushroom_stems",
"plank": "red_mushroom_planks"
}, {
"modid": "enhanced_mushrooms",
"name": "brown_mushroom",
"tag": "brown_mushroom_stems",
"plank": "brown_mushroom_planks"
}]
BLOCK_TYPES = [{
"name": "palisade",
"requires": "tag",
"creates": 4
}, {
"name": "beam",
"requires": "tag",
"creates": 1
}, {
"name": "seat",
"requires": "plank",
"creates": 1
}, {
"name": "support",
"requires": "plank",
"creates": 1
}]
for d in DATA:
for b in BLOCK_TYPES:
datapack = {
"type": "corail_woodcutter:woodcutting",
"ingredient": {
"tag": f"{d['modid']}:{d['tag']}"
} if b["requires"] == "tag" else {
"item": f"{d['modid']}:{d['plank']}"
},
"result": f"decorative_blocks_abnormals:{d['name']}_{b['name']}",
"count": b["creates"]
}
with open(f"{d['name']}_{b['name']}.json", "w") as fh:
fh.write(json.dumps(datapack))