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

fix repeated ids in game/mod.rs

This commit is contained in:
mat 2022-10-24 21:25:36 -05:00
parent f38d0660d1
commit 489cdb01aa
2 changed files with 5 additions and 2 deletions

View file

@ -290,14 +290,12 @@ declare_state_packets!(
0x49: clientbound_set_camera_packet::ClientboundSetCameraPacket, 0x49: clientbound_set_camera_packet::ClientboundSetCameraPacket,
0x4a: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket, 0x4a: clientbound_set_carried_item_packet::ClientboundSetCarriedItemPacket,
0x4b: clientbound_set_chunk_cache_center_packet::ClientboundSetChunkCacheCenterPacket, 0x4b: clientbound_set_chunk_cache_center_packet::ClientboundSetChunkCacheCenterPacket,
0x4c: clientbound_update_view_distance_packet::ClientboundUpdateViewDistancePacket,
0x4c: clientbound_set_chunk_cache_radius_packet::ClientboundSetChunkCacheRadiusPacket, 0x4c: clientbound_set_chunk_cache_radius_packet::ClientboundSetChunkCacheRadiusPacket,
0x4d: clientbound_set_default_spawn_position_packet::ClientboundSetDefaultSpawnPositionPacket, 0x4d: clientbound_set_default_spawn_position_packet::ClientboundSetDefaultSpawnPositionPacket,
0x4e: clientbound_set_display_chat_preview_packet::ClientboundSetDisplayChatPreviewPacket, 0x4e: clientbound_set_display_chat_preview_packet::ClientboundSetDisplayChatPreviewPacket,
0x4f: clientbound_set_display_objective_packet::ClientboundSetDisplayObjectivePacket, 0x4f: clientbound_set_display_objective_packet::ClientboundSetDisplayObjectivePacket,
0x50: clientbound_set_entity_data_packet::ClientboundSetEntityDataPacket, 0x50: clientbound_set_entity_data_packet::ClientboundSetEntityDataPacket,
0x51: clientbound_set_entity_link_packet::ClientboundSetEntityLinkPacket, 0x51: clientbound_set_entity_link_packet::ClientboundSetEntityLinkPacket,
0x52: clientbound_entity_velocity_packet::ClientboundEntityVelocityPacket,
0x52: clientbound_set_entity_motion_packet::ClientboundSetEntityMotionPacket, 0x52: clientbound_set_entity_motion_packet::ClientboundSetEntityMotionPacket,
0x53: clientbound_set_equipment_packet::ClientboundSetEquipmentPacket, 0x53: clientbound_set_equipment_packet::ClientboundSetEquipmentPacket,
0x54: clientbound_set_experience_packet::ClientboundSetExperiencePacket, 0x54: clientbound_set_experience_packet::ClientboundSetExperiencePacket,

View file

@ -121,6 +121,9 @@ def generate_packet(burger_packets, mappings: Mappings, target_packet_id, target
def set_packets(packet_ids: list[int], packet_class_names: list[str], direction: str, state: str): def set_packets(packet_ids: list[int], packet_class_names: list[str], direction: str, state: str):
assert len(packet_ids) == len(packet_class_names) assert len(packet_ids) == len(packet_class_names)
# ids are repeated
assert len(packet_ids) == len(set(packet_ids))
# sort the packets by id # sort the packets by id
packet_ids, packet_class_names = [list(x) for x in zip( packet_ids, packet_class_names = [list(x) for x in zip(
*sorted(zip(packet_ids, packet_class_names), key=lambda pair: pair[0]))] # type: ignore *sorted(zip(packet_ids, packet_class_names), key=lambda pair: pair[0]))] # type: ignore
@ -376,6 +379,8 @@ def change_packet_ids(id_map: dict[int, int], direction: str, state: str):
for packet_id in existing_packet_ids: for packet_id in existing_packet_ids:
new_packet_id = id_map.get(packet_id, packet_id) new_packet_id = id_map.get(packet_id, packet_id)
if new_packet_id in new_packet_ids:
raise Exception('Two packets have the same id')
new_packet_ids.append(new_packet_id) new_packet_ids.append(new_packet_id)
set_packets(new_packet_ids, existing_packet_class_names, direction, state) set_packets(new_packet_ids, existing_packet_class_names, direction, state)