diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2024-11-27 19:31:40 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-27 19:31:40 -0600 |
| commit | 08958c2278b15ebeac8a964f392ebb792e479b61 (patch) | |
| tree | 4ae3664cea38d7fd1a8f1e95ed06fac04ffe519e /codegen/migrate.py | |
| parent | 139d77d3c2b0922fba5e9d4fa2bd9819d78bd773 (diff) | |
| download | azalea-drasl-08958c2278b15ebeac8a964f392ebb792e479b61.tar.xz | |
Refactor azalea-protocol (#190)
* start updating to 1.21.4
* fix block codegen and stop using block data from burger
* rename packet related modules and structs to be simpler
* ItemSlot -> ItemStack for more consistency with mojmap
* .get() -> .into_packet()
* simplify declare_state_packets by removing packet ids
* rename read_from and write_into to azalea_read and azalea_write
* rename McBufReadable and McBufWritable to AzaleaRead and AzaleaWrite
* McBuf -> AzBuf
* remove most uses of into_variant
* update codegen and use resourcelocation names for packets
* implement #[limit(i)] attribute for AzBuf derive macro
* fixes for 1.21.4
* fix examples
* update some physics code and fix ChatType
* remove unused imports in codegen
* re-add some things to migrate.py and update +mc version numbers automatically
* downgrade to 1.21.3 lol
Diffstat (limited to 'codegen/migrate.py')
| -rwxr-xr-x | codegen/migrate.py | 121 |
1 files changed, 21 insertions, 100 deletions
diff --git a/codegen/migrate.py b/codegen/migrate.py index 3dcb854a..53d5b588 100755 --- a/codegen/migrate.py +++ b/codegen/migrate.py @@ -1,5 +1,3 @@ -from lib.code.packet import fix_state -from lib.utils import PacketIdentifier, group_packets import lib.code.inventory import lib.code.language import lib.code.registry @@ -31,104 +29,28 @@ new_version_id = sys.argv[1] new_mappings = lib.download.get_mappings_for_version(new_version_id) new_burger_data = lib.extract.get_burger_data_for_version(new_version_id) -old_packet_list = lib.extract.get_packet_list(old_version_id) -new_packet_list = lib.extract.get_packet_list(new_version_id) - - -# old_packets: dict[PacketIdentifier, str] = {} -# old_packets_data: dict[PacketIdentifier, dict] = {} -# new_packets: dict[PacketIdentifier, str] = {} -# new_packets_data: dict[PacketIdentifier, dict] = {} - -# for packet in old_packet_list: -# assert packet['class'].endswith('.class') -# packet_name = old_mappings.get_class(packet['class'][:-6]) -# packet_ident = PacketIdentifier( -# packet['id'], packet['direction'].lower(), fix_state(packet['state'])) -# old_packets[packet_ident] = packet_name -# old_packets_data[packet_ident] = packet -# for packet in new_packet_list: -# assert packet['class'].endswith('.class') -# packet_name = new_mappings.get_class(packet['class'][:-6]) -# packet_ident = PacketIdentifier( -# packet['id'], packet['direction'].lower(), fix_state(packet['state'])) -# new_packets[packet_ident] = packet_name -# new_packets_data[packet_ident] = packet - -# # find removed packets -# removed_packets: list[PacketIdentifier] = [] -# for packet, packet_name in old_packets.items(): -# if packet_name not in new_packets.values(): -# removed_packets.append(packet) -# print('Removed packet:', packet, packet_name) -# for (direction, state), packets in group_packets(removed_packets).items(): -# lib.code.packet.remove_packet_ids(packets, direction, state) - -print() - -# # find packets that changed ids -# changed_packets: dict[PacketIdentifier, int] = {} -# for old_packet, old_packet_name in old_packets.items(): -# for new_packet, new_packet_name in new_packets.items(): -# if old_packet_name == new_packet_name and old_packet.direction == new_packet.direction and old_packet.state == new_packet.state and old_packet.packet_id != new_packet.packet_id: -# changed_packets[old_packet] = new_packet.packet_id -# print('Changed packet id:', old_packet, '->', -# new_packet, f'({new_packet_name})') -# break -# for (direction, state), packets in group_packets(list(changed_packets.keys())).items(): -# id_map: dict[int, int] = {} -# for old_packet_id in packets: -# new_packet_id = changed_packets[PacketIdentifier( -# old_packet_id, direction, state)] -# id_map[old_packet_id] = new_packet_id -# lib.code.packet.change_packet_ids(id_map, direction, state) - - -# print() - -# # find added/changed packets -# added_or_changed_packets: list[PacketIdentifier] = [] -# for new_packet, packet_name in new_packets.items(): -# old_packet = None -# for old_packet_tmp, old_packet_name in old_packets.items(): -# if old_packet_name == packet_name: -# old_packet = old_packet_tmp -# break - -# if packet_name not in old_packets.values(): -# added_or_changed_packets.append(new_packet) -# print('Added packet:', new_packet, packet_name) -# elif old_packet and not lib.code.packet.are_packet_instructions_identical(new_packets_data[new_packet].get('instructions'), old_packets_data[old_packet].get('instructions')): -# added_or_changed_packets.append(new_packet) -# print('Changed packet:', new_packet, packet_name) -# for packet in added_or_changed_packets: -# lib.code.packet.generate_packet( -# new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state) +new_packets_report = lib.extract.get_packets_report(new_version_id) +lib.code.packet.set_packets(new_packets_report) lib.code.version.set_protocol_version( new_burger_data[0]['version']['protocol']) - -# print('Updated protocol!') - - -# old_ordered_blocks = lib.extract.get_ordered_blocks_burger(old_version_id) -# new_ordered_blocks = lib.extract.get_ordered_blocks_burger(new_version_id) -# if old_ordered_blocks != new_ordered_blocks: -# print('Blocks changed, updating...') - -# block_states_burger = lib.extract.get_block_states_burger(new_version_id) -# block_states_report = lib.extract.get_block_states_report(new_version_id) - -# # TODO: pixlyzer is currently broken so uhhhh -# shape_datas = lib.extract.get_pixlyzer_data( -# '1.20.3-pre4', 'shapes') -# pixlyzer_block_datas = lib.extract.get_pixlyzer_data( -# '1.20.3-pre4', 'blocks') - -# lib.code.blocks.generate_blocks( -# block_states_burger, block_states_report, pixlyzer_block_datas, new_ordered_blocks, new_mappings) -# lib.code.shapes.generate_block_shapes( -# pixlyzer_block_datas, shape_datas['shapes'], shape_datas['aabbs'], block_states_report, block_states_burger, new_mappings) +lib.code.version.set_version_name(new_version_id) + +print('Updated protocol!') + +print('Generating blocks and shapes...') +# TODO: pixlyzer is broken so we use old data +new_shape_datas = lib.extract.get_pixlyzer_data( + '1.20.3-pre4', 'shapes') +new_pixlyzer_block_datas = lib.extract.get_pixlyzer_data( + '1.20.3-pre4', 'blocks') +new_block_states_report = lib.extract.get_block_states_report(new_version_id) +new_registries = lib.extract.get_registries_report(new_version_id) +new_ordered_blocks = lib.code.blocks.get_ordered_blocks(new_registries) +lib.code.blocks.generate_blocks( + new_block_states_report, new_pixlyzer_block_datas, new_ordered_blocks) +lib.code.shapes.generate_block_shapes( + new_pixlyzer_block_datas, new_shape_datas['shapes'], new_shape_datas['aabbs'], new_block_states_report) print('Getting en_us.json...') language = lib.extract.get_en_us_lang(new_version_id) @@ -139,13 +61,12 @@ import genregistries genregistries.generate(new_version_id) # print('Generating entity metadata...') -# burger_entities_data = new_burger_data[0]['entities'] -# lib.code.entity.generate_entity_metadata(burger_entities_data, new_mappings) +burger_entities_data = new_burger_data[0]['entities'] +lib.code.entity.generate_entity_metadata(burger_entities_data, new_mappings) print('Finishing touches, setting version in README and formatting code...') lib.code.version.set_version_id(new_version_id) - lib.code.utils.fmt() print('Done!') |
