diff options
Diffstat (limited to 'codegen/lib')
| -rwxr-xr-x | codegen/lib/code/blocks.py | 8 | ||||
| -rw-r--r-- | codegen/lib/code/entity.py | 28 | ||||
| -rwxr-xr-x | codegen/lib/download.py | 2 | ||||
| -rwxr-xr-x | codegen/lib/extract.py | 17 |
4 files changed, 40 insertions, 15 deletions
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py index f96b1116..64347849 100755 --- a/codegen/lib/code/blocks.py +++ b/codegen/lib/code/blocks.py @@ -41,7 +41,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, pixlyzer_block_dat if property_burger is None: print( - 'Warning: The reports have states for a block, but Burger doesn\'t!', block_data_burger) + f'Warning: The reports have states for a block, but Burger doesn\'t! (missing "{property_name}")', block_data_burger) property_struct_name = get_property_struct_name( property_burger, block_data_burger, property_variants, mappings) @@ -90,7 +90,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, pixlyzer_block_dat for block_id in ordered_blocks: block_data_burger = blocks_burger[block_id] block_data_report = blocks_report['minecraft:' + block_id] - block_data_pixlyzer = pixlyzer_block_datas[f'minecraft:{block_id}'] + block_data_pixlyzer = pixlyzer_block_datas.get(f'minecraft:{block_id}', {}) block_properties = block_data_burger.get('states', []) block_properties_burger = block_data_burger.get('states', []) @@ -202,6 +202,10 @@ def get_property_struct_name(property: Optional[dict], block_data_burger: dict, return 'ChestType' if property_variants == ['compare', 'subtract']: return 'ComparatorType' + if property_variants == ['inactive', 'waiting_for_players', 'active', 'waiting_for_reward_ejection', 'ejecting_reward', 'cooldown']: + return 'TrialSpawnerState' + if property_variants == ['inactive', 'active', 'unlocking', 'ejecting']: + return 'VaultState' if 'harp' in property_variants and 'didgeridoo' in property_variants: return 'Sound' diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py index 8fa11430..5f0bc3d9 100644 --- a/codegen/lib/code/entity.py +++ b/codegen/lib/code/entity.py @@ -89,7 +89,7 @@ def generate_entity_metadata(burger_entities_data: dict, mappings: Mappings): with open(DATA_RS_DIR, 'w') as f: f.write('\n'.join(lines)) print('Expected metadata types:\n' + '\n'.join(new_metadata_names)) - print('Updated metadata types in azalea-world/src/entity/data.rs, go make sure they\'re correct and then press enter') + print('Updated metadata types in azalea-entity/src/data.rs, go make sure they\'re correct (check EntityDataSerializers.java) and then press enter') input() metadata_types = parse_metadata_types_from_code() @@ -100,12 +100,17 @@ def generate_entity_metadata(burger_entities_data: dict, mappings: Mappings): // This file is generated from codegen/lib/code/entity.py. // Don't change it manually! +use crate::particle::Particle; + use super::{ - EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, Rotations, - SnifferState, VillagerData + ArmadilloStateKind, EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Quaternion, + Rotations, SnifferState, VillagerData, }; use azalea_chat::FormattedText; -use azalea_core::{particle::Particle, position::{BlockPos, Vec3}, direction::Direction}; +use azalea_core::{ + direction::Direction, + position::{BlockPos, Vec3}, +}; use azalea_inventory::ItemSlot; use bevy_ecs::{bundle::Bundle, component::Component}; use derive_more::{Deref, DerefMut}; @@ -218,8 +223,7 @@ impl From<EntityDataValue> for UpdateMetadataError { struct_name = upper_first_letter( to_camel_case(name_or_bitfield)) - type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))[ - 'type_id'] + type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))['type_id'] metadata_type_data = metadata_types[type_id] rust_type = metadata_type_data['type'] @@ -281,8 +285,7 @@ impl From<EntityDataValue> for UpdateMetadataError { if name_or_bitfield in single_use_imported_types: field_struct_name = '' - type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))[ - 'type_id'] + type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))['type_id'] metadata_type_data = metadata_types[type_id] rust_type = metadata_type_data['type'] type_name = metadata_type_data['name'] @@ -384,8 +387,7 @@ impl From<EntityDataValue> for UpdateMetadataError { ' },') for index, name_or_bitfield in get_entity_metadata_names(this_entity_id, burger_entity_metadata, mappings).items(): - default = next(filter(lambda i: i['index'] == index, entity_metadatas)).get( - 'default', 'Default::default()') + default = next(filter(lambda i: i['index'] == index, entity_metadatas)).get('default', 'Default::default()') if isinstance(name_or_bitfield, str): type_id = next(filter(lambda i: i['index'] == index, entity_metadatas))[ 'type_id'] @@ -454,8 +456,10 @@ impl From<EntityDataValue> for UpdateMetadataError { for mask, name in name_or_bitfield.items(): name = maybe_rename_field(name, index) mask = int(mask, 0) - bit_default = 'true' if ( - default & mask != 0) else 'false' + if default is None: + bit_default = 'false' + else: + bit_default = 'true' if (default & mask != 0) else 'false' code.append( f' {name}: {upper_first_letter(to_camel_case(name))}({bit_default}),') code.append(' Self {') diff --git a/codegen/lib/download.py b/codegen/lib/download.py index 319c6080..41576594 100755 --- a/codegen/lib/download.py +++ b/codegen/lib/download.py @@ -16,7 +16,7 @@ def get_burger(): if not os.path.exists(get_dir_location('__cache__/Burger')): print('\033[92mDownloading Burger...\033[m') os.system( - f'cd {get_dir_location("__cache__")} && git clone https://github.com/pokechu22/Burger && cd Burger && git pull') + f'cd {get_dir_location("__cache__")} && git clone https://github.com/mat-1/Burger && cd Burger && git pull') print('\033[92mInstalling dependencies...\033[m') os.system(f'cd {get_dir_location("__cache__")}/Burger && pip install six jawa') diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py index 608673fa..fa75c49e 100755 --- a/codegen/lib/extract.py +++ b/codegen/lib/extract.py @@ -1,5 +1,6 @@ # 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.utils import get_dir_location from zipfile import ZipFile @@ -275,3 +276,19 @@ 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. + +if TYPE_CHECKING: from codegen.lib.mappings import Mappings +def get_packet_list(burger_data, mappings: 'Mappings'): + packet_list = list(burger_data[0]['packets']['packet'].values()) + + current_packet_id = 0 + for packet in packet_list: + if packet['id'] == -1: + packet['id'] = current_packet_id + print(packet) + current_packet_id += 1 + + return packet_list |
