aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/extract.py
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-27 01:37:52 -0500
committermat <github@matdoes.dev>2022-05-27 01:37:52 -0500
commit86cc2a9b7c85b0cb412fa8cbe2ab6b9a7ae5fcfc (patch)
tree5aec2f2d326fc9a832fe153b312323d06310cad4 /codegen/lib/extract.py
parent68ab3d65247c02d469d77e5702f57e46f690965b (diff)
downloadazalea-drasl-86cc2a9b7c85b0cb412fa8cbe2ab6b9a7ae5fcfc.tar.xz
codegen/extract.py
Preparation for azalea-block
Diffstat (limited to 'codegen/lib/extract.py')
-rw-r--r--codegen/lib/extract.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py
new file mode 100644
index 00000000..82ae257d
--- /dev/null
+++ b/codegen/lib/extract.py
@@ -0,0 +1,34 @@
+# Extracting data from the Minecraft jars
+
+from lib.download import get_server_jar, get_burger, get_client_jar
+from lib.utils import get_dir_location
+import json
+import os
+
+
+def generate_data_from_server_jar(version_id: str):
+ if os.path.exists(get_dir_location(f'downloads/generated-{version_id}')):
+ return
+
+ get_server_jar(version_id)
+ os.system(
+ f'java -jar {get_dir_location(f"downloads/server-{version_id}.jar")} --all --output {get_dir_location(f"downloads/generated-{version_id}")}'
+ )
+
+
+def get_block_states(version_id: str):
+ generate_data_from_server_jar(version_id)
+ with open(get_dir_location(f'downloads/generated-{version_id}/reports/blocks.json'), 'r') as f:
+ return json.load(f)
+
+
+def get_burger_data_for_version(version_id: str):
+ if not os.path.exists(get_dir_location(f'downloads/burger-{version_id}.json')):
+ get_burger()
+ get_client_jar(version_id)
+
+ os.system(
+ f'cd {get_dir_location("downloads/Burger")} && python munch.py ../client-{version_id}.jar --output ../burger-{version_id}.json'
+ )
+ with open(get_dir_location(f'downloads/burger-{version_id}.json'), 'r') as f:
+ return json.load(f)