diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-03-16 13:41:17 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-16 13:41:17 -0500 |
| commit | b0bd992adcff71ee294dd05060e00e652f62a7b2 (patch) | |
| tree | 0a36d8b37befbc75c8c65cc2c8779c3df66bd87b /codegen | |
| parent | a95408cbcc05b5bd04a084b0a286b571069206f6 (diff) | |
| download | azalea-drasl-b0bd992adcff71ee294dd05060e00e652f62a7b2.tar.xz | |
Fluid physics fixes (#210)
* start fixing code related to fluid physics
* implement force_solid for blocks
* afk pool test
Diffstat (limited to 'codegen')
| -rwxr-xr-x | codegen/genblocks.py | 3 | ||||
| -rwxr-xr-x | codegen/lib/code/blocks.py | 13 | ||||
| -rwxr-xr-x | codegen/lib/extract.py | 23 | ||||
| -rwxr-xr-x | codegen/lib/mappings.py | 1 |
4 files changed, 22 insertions, 18 deletions
diff --git a/codegen/genblocks.py b/codegen/genblocks.py index 1024072a..d0bea909 100755 --- a/codegen/genblocks.py +++ b/codegen/genblocks.py @@ -13,13 +13,14 @@ def generate(version_id): '1.20.3-pre4', 'shapes') pixlyzer_block_datas = lib.extract.get_pixlyzer_data( '1.20.3-pre4', 'blocks') + burger_data = lib.extract.get_burger_data_for_version(version_id) block_states_report = lib.extract.get_block_states_report(version_id) registries = lib.extract.get_registries_report(version_id) ordered_blocks = lib.code.blocks.get_ordered_blocks(registries) lib.code.blocks.generate_blocks( - block_states_report, pixlyzer_block_datas, ordered_blocks) + block_states_report, pixlyzer_block_datas, ordered_blocks, burger_data) lib.code.shapes.generate_block_shapes( pixlyzer_block_datas, shape_datas['shapes'], shape_datas['aabbs'], block_states_report) diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py index 2733093b..181ce774 100755 --- a/codegen/lib/code/blocks.py +++ b/codegen/lib/code/blocks.py @@ -12,13 +12,15 @@ BLOCKS_RS_DIR = get_dir_location('../azalea-block/src/generated.rs') # - Block: Has properties and states. -def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blocks: list[str]): +def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blocks: list[str], burger_data: dict): with open(BLOCKS_RS_DIR, 'r') as f: existing_code = f.read().splitlines() new_make_block_states_macro_code = [] new_make_block_states_macro_code.append('make_block_states! {') + burger_block_datas = burger_data[0]['blocks']['block'] + # Find properties properties = {} @@ -77,6 +79,7 @@ def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blo for block_id in ordered_blocks: block_data_report = blocks_report['minecraft:' + block_id] block_data_pixlyzer = pixlyzer_block_datas.get(f'minecraft:{block_id}', {}) + block_data_burger = burger_block_datas.get(block_id, {}) default_property_variants: dict[str, str] = {} for state in block_data_report['states']: @@ -129,6 +132,14 @@ def generate_blocks(blocks_report: dict, pixlyzer_block_datas: dict, ordered_blo friction = block_data_pixlyzer.get('friction') if friction != None: behavior_constructor += f'.friction({friction})' + + force_solid = None + if block_data_burger.get('force_solid_on'): + force_solid = 'true' + elif block_data_burger.get('force_solid_off'): + force_solid = 'false' + if force_solid != None: + behavior_constructor += f'.force_solid({force_solid})' # TODO: use burger to generate the blockbehavior new_make_block_states_macro_code.append( diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py index 4119ad55..c62b2b99 100755 --- a/codegen/lib/extract.py +++ b/codegen/lib/extract.py @@ -1,7 +1,7 @@ # Extracting data from the Minecraft jars from typing import TYPE_CHECKING -from lib.download import get_server_jar, get_burger, get_client_jar, get_pixlyzer, get_yarn_data, get_fabric_api_versions, get_fabric_loader_versions +from lib.download import get_mappings_for_version, get_server_jar, get_burger, get_client_jar, get_pixlyzer, get_yarn_data, get_fabric_api_versions, get_fabric_loader_versions from lib.utils import get_dir_location, to_camel_case, upper_first_letter from zipfile import ZipFile import subprocess @@ -53,19 +53,8 @@ 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 (sys.executable, '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!') + return 'venv/bin/python' + def run_python_command_and_download_deps(command): @@ -105,10 +94,14 @@ 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') run_python_command_and_download_deps( - f'cd {get_dir_location("__cache__/Burger")} && {determine_python_command()} munch.py {get_dir_location("__cache__")}/client-{version_id}.jar --output {get_dir_location("__cache__")}/burger-{version_id}.json' + f'cd {get_dir_location("__cache__/Burger")} && '\ + f'{determine_python_command()} 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) diff --git a/codegen/lib/mappings.py b/codegen/lib/mappings.py index 22624fac..9c39fc2b 100755 --- a/codegen/lib/mappings.py +++ b/codegen/lib/mappings.py @@ -78,7 +78,6 @@ class Mappings: return self.classes[obfuscated_class_name] def get_method(self, obfuscated_class_name, obfuscated_method_name, obfuscated_signature): - # print(obfuscated_class_name, self.methods[obfuscated_class_name]) return self.methods[obfuscated_class_name][f'{obfuscated_method_name}({obfuscated_signature})'] def get_field_type(self, obfuscated_class_name, obfuscated_field_name) -> str: |
