From 9d4f738d4e66adf0796e163d1c9368aaba906bba Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 10 Feb 2023 01:56:45 +0000 Subject: make blockstate good --- codegen/lib/extract.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'codegen/lib/extract.py') diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py index 7cbeff30..09035e86 100755 --- a/codegen/lib/extract.py +++ b/codegen/lib/extract.py @@ -4,6 +4,7 @@ from lib.download import get_server_jar, get_burger, get_client_jar, get_pixlyze from lib.utils import get_dir_location from zipfile import ZipFile import subprocess +import requests import json import sys import re @@ -114,7 +115,20 @@ def get_pixlyzer_data(version_id: str, category: str): target_dir = get_dir_location(f'downloads/pixlyzer-{version_id}') - if not os.path.exists(get_dir_location(target_dir)): + # TODO: right now this False is hard-coded, it should retry with this + # enabled if # initially getting the data fails + if False or (os.path.exists(target_dir) and not os.path.exists(f'{target_dir}/{category}.min.json')): + print('Downloading', category, 'from pixlyzer-data.') + data = requests.get(f'https://gitlab.com/Bixilon/pixlyzer-data/-/raw/master/version/{version_id}/{category}.min.json?inline=false').text + try: + os.mkdir(target_dir) + except: + pass + with open(f'{target_dir}/{category}.min.json', 'w') as f: + f.write(data) + return json.loads(data) + + if not os.path.exists(target_dir): pixlyzer_dir = get_pixlyzer() # for some reason pixlyzer doesn't work right unless the mvn clean @@ -231,7 +245,6 @@ def get_pixlyzer_data(version_id: str, category: str): with open(f'{target_dir}/{category}.min.json', 'r') as f: return json.load(f) - def get_file_from_jar(version_id: str, file_dir: str): get_client_jar(version_id) with ZipFile(get_dir_location(f'downloads/client-{version_id}.jar')) as z: -- cgit v1.2.3