1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

Fix detecting changed packet ids

This commit is contained in:
mat 2022-05-25 20:09:48 -05:00
parent d69f4445f3
commit c851204dd0
2 changed files with 14 additions and 10 deletions

View file

@ -41,8 +41,12 @@ def get_version_data(version_id: str):
print(
f'\033[92mGetting data for \033[1m{version_id}..\033[m')
package_url = next(
filter(lambda v: v['id'] == version_id, version_manifest_data['versions']))['url']
try:
package_url = next(
filter(lambda v: v['id'] == version_id, version_manifest_data['versions']))['url']
except StopIteration:
raise ValueError(
f'No version with id {version_id} found. Maybe delete downloads/version_manifest.json and try again?')
package_data = requests.get(package_url).json()
with open(f'downloads/{version_id}.json', 'w') as f:
json.dump(package_data, f)

View file

@ -38,8 +38,8 @@ for packet, packet_name in old_packets.items():
if packet_name not in old_packets.values():
removed_packets.append(packet)
print('Removed packet:', packet)
for (direction, state), packets in group_packets(removed_packets).items():
lib.code.packet.remove_packet_ids(packets, direction, state)
# for (direction, state), packets in group_packets(removed_packets).items():
# lib.code.packet.remove_packet_ids(packets, direction, state)
print()
@ -47,13 +47,13 @@ print()
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.direction == new_packet.direction and old_packet.state == new_packet.state and old_packet.packet_id != new_packet.packet_id:
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():
lib.code.packet.remove_packet_ids(packets, direction, state)
# for (direction, state), packets in group_packets(list(changed_packets.keys())).items():
# lib.code.packet.remove_packet_ids(packets, direction, state)
print()
@ -64,9 +64,9 @@ for packet, packet_name in new_packets.items():
if packet_name not in old_packets.values():
added_packets.append(packet)
print('Added packet:', packet)
for packet in added_packets:
lib.code.packet.generate_packet(
new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
# for packet in added_packets:
# lib.code.packet.generate_packet(
# new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)
lib.code.utils.fmt()
print('Done!')