diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-08-20 15:17:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-20 15:17:07 -0500 |
| commit | dbb2092ac002790c07ad21cf7d12aabb477a2e74 (patch) | |
| tree | 5d5bb1e6dbca8250292a9e0b1edc7325699bbbaf /codegen/lib/extract.py | |
| parent | ac4d675d44a93a6625f508263c650206a7ff1f98 (diff) | |
| download | azalea-drasl-dbb2092ac002790c07ad21cf7d12aabb477a2e74.tar.xz | |
Implement ALL packets (#16)
* add a couple more packets and improve codegen
* enums in packet codegen
* fix enums and MORE PACKETS
* make unsigned numbers the default
* codegen can make hashmaps
* UnsizedByteArray in codegen
* Vec and Option
* enum codgen works in more situations
* ServerboundInteractPacket
* Fix error with new error system
* More packets
* more packets
* more packets
* guess what was added
* yeah it's more packets
* add more packets
* packets
* start adding ClientboundBossEventPacket
* finish boss event packet
* improve codegen for linux
* start on command suggestions packet
* rename declare_commands to commands
* más paquetes
* fix generating custom payload packet
* more packets
* mehr Pakete
* improve codegen for movement packets
* rename move packets to have "packet" at the end
* fix some unused variable warns
* addere plus facis
* pli da pakoj
* plus de paquets
* più pacchetti
* make ChatFormatting a macro in azalea-chat
* change a match to matches! macro
* update SetPlayerTeam to use ChatFormatting
* ClientboundSetScorePacket & fix clippy warnings
* finish game state :tada:
* add remaining packets for other states
* fix error in ping.rs
Diffstat (limited to 'codegen/lib/extract.py')
| -rw-r--r-- | codegen/lib/extract.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py index 4c2d2399..7c27d1ae 100644 --- a/codegen/lib/extract.py +++ b/codegen/lib/extract.py @@ -2,7 +2,9 @@ from lib.download import get_server_jar, get_burger, get_client_jar, get_generator_mod, get_yarn_data, get_fabric_api_versions from lib.utils import get_dir_location +import subprocess import json +import re import os @@ -31,15 +33,38 @@ def get_ordered_blocks_burger(version_id: str): burger_data = get_burger_data_for_version(version_id) return burger_data[0]['blocks']['ordered_blocks'] +python_command = None +def determine_python_command(): + global python_command + if python_command: + return python_command + + def try_python_command(version): + return os.system(f'{version} --version') == 0 + + for version in ('python3.9', 'python3.8', 'python3', 'python'): + if try_python_command(version): + python_command = version + return version + raise Exception('Couldn\'t determine python command to use to run burger with!') 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' - ) + for _ in range(10): + r = subprocess.run( + f'cd {get_dir_location("downloads/Burger")} && {determine_python_command()} munch.py ../client-{version_id}.jar --output ../burger-{version_id}.json', + capture_output=True, + shell=True + ) + regex_match = re.search(r'ModuleNotFoundError: No module named \'(\w+?)\'', r.stderr.decode()) + if not regex_match: + break + missing_lib = regex_match.group(1) + print('Missing required lib for Burger:', missing_lib) + os.system(f'{determine_python_command()} -m pip install {missing_lib}') with open(get_dir_location(f'downloads/burger-{version_id}.json'), 'r') as f: return json.load(f) |
