diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2026-03-24 11:15:56 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-24 11:15:56 -0500 |
| commit | eeaf1435e81d9cbd8daa0efa22029c1f259a64b5 (patch) | |
| tree | 3486e26d5409708370e4e259d240fb77c6e1e439 /codegen/lib/extract.py | |
| parent | 41a9ae6aaff77646c08c64ac1334a8cc6081c24f (diff) | |
| download | azalea-drasl-eeaf1435e81d9cbd8daa0efa22029c1f259a64b5.tar.xz | |
26.1 (#316)
* start updating to 26.1
* start updating to 26.1-snapshot-6
* 26.1-snapshot-6
* 26.1-snapshot-10
* 26.1-rc-1
* fix tests
* 26.1-rc-2 and sort default components
* 26.1
* update changelog
Diffstat (limited to 'codegen/lib/extract.py')
| -rw-r--r-- | codegen/lib/extract.py | 83 |
1 files changed, 24 insertions, 59 deletions
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py index f2f7f4a2..9faa2e22 100644 --- a/codegen/lib/extract.py +++ b/codegen/lib/extract.py @@ -1,18 +1,16 @@ # Extracting data from the Minecraft jars import shutil -from lib.download import ( +from .download import ( get_fabric_api_version, get_latest_fabric_kotlin_version, - get_latest_fabric_loom_version, - get_mappings_for_version, get_pumpkin_extractor, get_server_jar, get_burger, get_client_jar, get_fabric_data, ) -from lib.utils import get_dir_location, to_camel_case, upper_first_letter +from .utils import get_dir_location from zipfile import ZipFile import subprocess import json @@ -43,7 +41,23 @@ def get_packets_report(version_id: str): def get_items_report(version_id: str): - return get_report(version_id, "items") + generate_data_from_server_jar(version_id) + items_dir = get_dir_location( + f"__cache__/generated-{version_id}/reports/minecraft/components/item" + ) + if not os.path.exists(items_dir): + return {} + items = {} + for root, dirs, files in os.walk(items_dir, topdown=False): + for name in files: + file = os.path.join(root, name) + relative_path = file.replace(items_dir, "")[1:] + if not file.endswith(".json"): + continue + with open(file, "r") as f: + items[relative_path[:-5]] = json.load(f) + + return items def get_report(version_id: str, name: str): @@ -143,14 +157,12 @@ def get_burger_data_for_version(version_id: str): if not os.path.exists(get_dir_location(f"__cache__/burger-{version_id}.json")): get_burger() get_client_jar(version_id) - get_mappings_for_version(version_id) - print("\033[92mRunning Burger...\033[m") + print("\033[92mRunning azalea-burger...\033[m") run_python_command_and_download_deps( - f"cd {get_dir_location('__cache__/Burger')} && " + f"cd {get_dir_location('__cache__/azalea-burger')} && " f"venv/bin/python munch.py {get_dir_location('__cache__')}/client-{version_id}.jar " f"--output {get_dir_location('__cache__')}/burger-{version_id}.json " - f"--mappings {get_dir_location('__cache__')}/mappings-{version_id}.txt" ) with open(get_dir_location(f"__cache__/burger-{version_id}.json"), "r") as f: return json.load(f) @@ -183,12 +195,11 @@ def get_pumpkin_data(version_id: str, category: str): fabric_kotlin_version = get_latest_fabric_kotlin_version() gradle_properties = f"""# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true # Fabric Properties -# check these on https://modmuss50.me/fabric.html +# check these on https://fabricmc.net/develop/ minecraft_version={version_id} -yarn_mappings={fabric_data["mappings"]["version"]} loader_version={fabric_data["loader"]["version"]} kotlin_loader_version={fabric_kotlin_version} # Mod Properties @@ -200,24 +211,9 @@ fabric_version={fabric_api_version} with open(f"{pumpkin_dir}/gradle.properties", "w") as f: f.write(gradle_properties) - # update the minecraft version dependency in src/main/resources/fabric.mod.json - fabric_mod_json_path = f"{pumpkin_dir}/src/main/resources/fabric.mod.json" - with open(fabric_mod_json_path, "r") as f: - fabric_mod_json = f.read() - with open(f"{pumpkin_dir}/build.gradle.kts", "r") as f: - build_gradle_kts = f.read() - with open(f"{pumpkin_dir}/build.gradle.kts", "w") as f: - # build_gradle_kts = re.sub( - # r'(id\("fabric-loom"\) version )"[^"]+"', - # rf'\1"{fabric_loom_version}"', - # build_gradle_kts, - # ) - f.write(build_gradle_kts) - # run ./gradlew runServer until it logs "(pumpkin_extractor) Done" p = subprocess.Popen( - # the gradle wrapper (./gradlew) is sometimes on the wrong version so just prefer the system's gradle installation - f"cd {pumpkin_dir} && gradle clean && gradle runServer", + f"cd {pumpkin_dir} && ./gradlew clean && ./gradlew runServer", stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, @@ -253,34 +249,3 @@ def get_file_from_jar(version_id: str, file_dir: str): def get_en_us_lang(version_id: str): return json.loads(get_file_from_jar(version_id, "assets/minecraft/lang/en_us.json")) - - -# burger packet id extraction is broken since 1.20.5 (always returns -1, so we have to determine packet id ourselves from the mappings). -# this is very much not ideal. - - -def get_packet_list(version_id: str): - if version_id != "1.21": - return [] - - generate_data_from_server_jar(version_id) - with open( - get_dir_location(f"__cache__/generated-{version_id}/reports/packets.json"), "r" - ) as f: - packets_report = json.load(f) - packet_list = [] - for state, state_value in packets_report.items(): - for direction, direction_value in state_value.items(): - for packet_identifier, packet_value in direction_value.items(): - assert packet_identifier.startswith("minecraft:") - packet_identifier = upper_first_letter( - to_camel_case(packet_identifier[len("minecraft:") :]) - ) - packet_list.append( - { - "state": state, - "direction": direction, - "name": packet_identifier, - "id": packet_value["protocol_id"], - } - ) |
