diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2024-04-23 10:34:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-23 10:34:50 -0500 |
| commit | 1d80f531b74bc3b31023753acb81b35efcdadd73 (patch) | |
| tree | 675635c7c41fbb456e3e0dd7b9f09c7211d356f0 /codegen/migrate.py | |
| parent | 0ddad8bd9c7c0e8846aec8bc90c95416418c9a63 (diff) | |
| download | azalea-drasl-1d80f531b74bc3b31023753acb81b35efcdadd73.tar.xz | |
1.20.5 (#127)
* 23w51b
* make recalculate_near_end_of_path public
so other plugins can do .after(recalculate_near_end_of_path)
* update to 24w03a i think
* start implementing 24w13a
* registries work (but a lot of packets are still broken)
* fix recipes and commands packets
* i love codecs :D i am not going insane :D mojang's java is very readable :D
* item components are "implemented" meowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeowmeow
* update to 1.20.5-pre3
* fix all the broken packets and clippy (mojang please don't do an update like this again or i will murder someone)
* 1.20.5-rc1
* fix failing tests
* 1.20.5
Diffstat (limited to 'codegen/migrate.py')
| -rwxr-xr-x | codegen/migrate.py | 152 |
1 files changed, 77 insertions, 75 deletions
diff --git a/codegen/migrate.py b/codegen/migrate.py index 860d860e..2be85643 100755 --- a/codegen/migrate.py +++ b/codegen/migrate.py @@ -26,88 +26,89 @@ if len(sys.argv) == 1: old_version_id = lib.code.version.get_version_id() old_mappings = lib.download.get_mappings_for_version(old_version_id) old_burger_data = lib.extract.get_burger_data_for_version(old_version_id) -old_packet_list = list(old_burger_data[0]['packets']['packet'].values()) 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) -new_packet_list = list(new_burger_data[0]['packets']['packet'].values()) - - -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) +old_packet_list = lib.extract.get_packet_list(old_burger_data, old_mappings) +new_packet_list = lib.extract.get_packet_list(new_burger_data, new_mappings) + + +# 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 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) +# # 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) lib.code.version.set_protocol_version( new_burger_data[0]['version']['protocol']) -print('Updated protocol!') +# print('Updated protocol!') old_ordered_blocks = lib.extract.get_ordered_blocks_burger(old_version_id) @@ -118,10 +119,11 @@ if old_ordered_blocks != new_ordered_blocks: 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( - new_version_id, 'shapes') + '1.20.3-pre4', 'shapes') pixlyzer_block_datas = lib.extract.get_pixlyzer_data( - new_version_id, 'blocks') + '1.20.3-pre4', 'blocks') lib.code.blocks.generate_blocks( block_states_burger, block_states_report, pixlyzer_block_datas, new_ordered_blocks, new_mappings) @@ -136,9 +138,9 @@ print('Generating registries...') 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) +# print('Generating entity metadata...') +# 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) |
