From 42aed5ad2eef66b0c470703b87d763827f69797d Mon Sep 17 00:00:00 2001 From: oitsjustjose Date: Wed, 9 Feb 2022 10:34:01 -0600 Subject: [PATCH] New script to list off entities --- scripts/entity_lister.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/entity_lister.py diff --git a/scripts/entity_lister.py b/scripts/entity_lister.py new file mode 100644 index 0000000..a3198bc --- /dev/null +++ b/scripts/entity_lister.py @@ -0,0 +1,33 @@ +""" +@author: Jose Stovall | oitsjustjose @ github | twitter | anywhere really +A tool for scanning your mods folder for any particular item to figure out which mod did it, where, etc.. +""" + +import os +import zipfile + +def fmt(filename: str) -> str: + """Formats a given data path to the modid:entity format""" + modid = filename[5:][:filename[5:].index("/")] + entity = filename[filename.rindex("/") + 1:].replace(".json", "") + return f"{modid}:{entity}" + + +def main() -> None: + """ The main runfunction of this file """ + entity_loot_tables = [] + for root, _, files in os.walk("./mods"): + for file in files: + if not file.endswith(".jar"): + continue + zip_fh = zipfile.ZipFile(f"{root}/{file}", "r") + for zip_item in zip_fh.infolist(): + if "loot_tables/entities" in zip_item.filename and zip_item.filename.endswith(".json"): + entity_loot_tables.append(zip_item.filename) + entity_loot_tables = list( map( fmt, entity_loot_tables ) ) + print("\n".join(entity_loot_tables)) + + + +if __name__ == "__main__": + main()