From ac31d1c83bc9b324e58aaef3328b1af572656229 Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Thu, 14 Nov 2024 18:52:47 +0100 Subject: [PATCH] Improve Packet Extractor Optimize packets.json - Reduce lines from 1394 -> 256 - Reduces File size 23KB-> 6.9KB --- assets/packets.json | 1648 +++-------------- .../de/snowii/extractor/extractors/Packets.kt | 101 +- pumpkin-macros/src/packet.rs | 38 +- .../src/client/config/c_add_resource_pack.rs | 2 +- .../src/client/config/c_config_disconnect.rs | 2 +- .../src/client/config/c_cookie_request.rs | 2 +- .../src/client/config/c_finish_config.rs | 2 +- .../src/client/config/c_known_packs.rs | 2 +- .../src/client/config/c_plugin_message.rs | 2 +- .../src/client/config/c_registry_data.rs | 2 +- .../config/s_acknowledge_finish_config.rs | 2 +- .../src/server/config/s_client_information.rs | 2 +- .../src/server/config/s_known_packs.rs | 2 +- .../src/server/config/s_plugin_message.rs | 2 +- 14 files changed, 365 insertions(+), 1444 deletions(-) diff --git a/assets/packets.json b/assets/packets.json index f7fc1944f..9cef653fa 100644 --- a/assets/packets.json +++ b/assets/packets.json @@ -1,1394 +1,256 @@ -[ - { - "name": "intention", - "phase": "handshake", - "side": "serverbound", - "id": 0 - }, - { - "name": "status_request", - "phase": "status", - "side": "serverbound", - "id": 0 - }, - { - "name": "ping_request", - "phase": "status", - "side": "serverbound", - "id": 1 - }, - { - "name": "status_response", - "phase": "status", - "side": "clientbound", - "id": 0 - }, - { - "name": "pong_response", - "phase": "status", - "side": "clientbound", - "id": 1 - }, - { - "name": "hello", - "phase": "login", - "side": "serverbound", - "id": 0 - }, - { - "name": "key", - "phase": "login", - "side": "serverbound", - "id": 1 - }, - { - "name": "custom_query_answer", - "phase": "login", - "side": "serverbound", - "id": 2 - }, - { - "name": "login_acknowledged", - "phase": "login", - "side": "serverbound", - "id": 3 - }, - { - "name": "cookie_response", - "phase": "login", - "side": "serverbound", - "id": 4 - }, - { - "name": "login_disconnect", - "phase": "login", - "side": "clientbound", - "id": 0 - }, - { - "name": "hello", - "phase": "login", - "side": "clientbound", - "id": 1 - }, - { - "name": "login_finished", - "phase": "login", - "side": "clientbound", - "id": 2 - }, - { - "name": "login_compression", - "phase": "login", - "side": "clientbound", - "id": 3 - }, - { - "name": "custom_query", - "phase": "login", - "side": "clientbound", - "id": 4 - }, - { - "name": "cookie_request", - "phase": "login", - "side": "clientbound", - "id": 5 - }, - { - "name": "client_information", - "phase": "configuration", - "side": "serverbound", - "id": 0 - }, - { - "name": "cookie_response", - "phase": "configuration", - "side": "serverbound", - "id": 1 - }, - { - "name": "custom_payload", - "phase": "configuration", - "side": "serverbound", - "id": 2 - }, - { - "name": "finish_configuration", - "phase": "configuration", - "side": "serverbound", - "id": 3 - }, - { - "name": "keep_alive", - "phase": "configuration", - "side": "serverbound", - "id": 4 - }, - { - "name": "pong", - "phase": "configuration", - "side": "serverbound", - "id": 5 - }, - { - "name": "resource_pack", - "phase": "configuration", - "side": "serverbound", - "id": 6 - }, - { - "name": "select_known_packs", - "phase": "configuration", - "side": "serverbound", - "id": 7 - }, - { - "name": "cookie_request", - "phase": "configuration", - "side": "clientbound", - "id": 0 - }, - { - "name": "custom_payload", - "phase": "configuration", - "side": "clientbound", - "id": 1 - }, - { - "name": "disconnect", - "phase": "configuration", - "side": "clientbound", - "id": 2 - }, - { - "name": "finish_configuration", - "phase": "configuration", - "side": "clientbound", - "id": 3 - }, - { - "name": "keep_alive", - "phase": "configuration", - "side": "clientbound", - "id": 4 - }, - { - "name": "ping", - "phase": "configuration", - "side": "clientbound", - "id": 5 - }, - { - "name": "reset_chat", - "phase": "configuration", - "side": "clientbound", - "id": 6 - }, - { - "name": "registry_data", - "phase": "configuration", - "side": "clientbound", - "id": 7 - }, - { - "name": "resource_pack_pop", - "phase": "configuration", - "side": "clientbound", - "id": 8 - }, - { - "name": "resource_pack_push", - "phase": "configuration", - "side": "clientbound", - "id": 9 - }, - { - "name": "store_cookie", - "phase": "configuration", - "side": "clientbound", - "id": 10 - }, - { - "name": "transfer", - "phase": "configuration", - "side": "clientbound", - "id": 11 - }, - { - "name": "update_enabled_features", - "phase": "configuration", - "side": "clientbound", - "id": 12 - }, - { - "name": "update_tags", - "phase": "configuration", - "side": "clientbound", - "id": 13 - }, - { - "name": "select_known_packs", - "phase": "configuration", - "side": "clientbound", - "id": 14 - }, - { - "name": "custom_report_details", - "phase": "configuration", - "side": "clientbound", - "id": 15 - }, - { - "name": "server_links", - "phase": "configuration", - "side": "clientbound", - "id": 16 - }, - { - "name": "accept_teleportation", - "phase": "play", - "side": "serverbound", - "id": 0 - }, - { - "name": "block_entity_tag_query", - "phase": "play", - "side": "serverbound", - "id": 1 - }, - { - "name": "bundle_item_selected", - "phase": "play", - "side": "serverbound", - "id": 2 - }, - { - "name": "change_difficulty", - "phase": "play", - "side": "serverbound", - "id": 3 - }, - { - "name": "chat_ack", - "phase": "play", - "side": "serverbound", - "id": 4 - }, - { - "name": "chat_command", - "phase": "play", - "side": "serverbound", - "id": 5 - }, - { - "name": "chat_command_signed", - "phase": "play", - "side": "serverbound", - "id": 6 - }, - { - "name": "chat", - "phase": "play", - "side": "serverbound", - "id": 7 - }, - { - "name": "chat_session_update", - "phase": "play", - "side": "serverbound", - "id": 8 - }, - { - "name": "chunk_batch_received", - "phase": "play", - "side": "serverbound", - "id": 9 - }, - { - "name": "client_command", - "phase": "play", - "side": "serverbound", - "id": 10 - }, - { - "name": "client_tick_end", - "phase": "play", - "side": "serverbound", - "id": 11 - }, - { - "name": "client_information", - "phase": "play", - "side": "serverbound", - "id": 12 - }, - { - "name": "command_suggestion", - "phase": "play", - "side": "serverbound", - "id": 13 - }, - { - "name": "configuration_acknowledged", - "phase": "play", - "side": "serverbound", - "id": 14 - }, - { - "name": "container_button_click", - "phase": "play", - "side": "serverbound", - "id": 15 - }, - { - "name": "container_click", - "phase": "play", - "side": "serverbound", - "id": 16 - }, - { - "name": "container_close", - "phase": "play", - "side": "serverbound", - "id": 17 - }, - { - "name": "container_slot_state_changed", - "phase": "play", - "side": "serverbound", - "id": 18 - }, - { - "name": "cookie_response", - "phase": "play", - "side": "serverbound", - "id": 19 - }, - { - "name": "custom_payload", - "phase": "play", - "side": "serverbound", - "id": 20 - }, - { - "name": "debug_sample_subscription", - "phase": "play", - "side": "serverbound", - "id": 21 - }, - { - "name": "edit_book", - "phase": "play", - "side": "serverbound", - "id": 22 - }, - { - "name": "entity_tag_query", - "phase": "play", - "side": "serverbound", - "id": 23 - }, - { - "name": "interact", - "phase": "play", - "side": "serverbound", - "id": 24 - }, - { - "name": "jigsaw_generate", - "phase": "play", - "side": "serverbound", - "id": 25 - }, - { - "name": "keep_alive", - "phase": "play", - "side": "serverbound", - "id": 26 - }, - { - "name": "lock_difficulty", - "phase": "play", - "side": "serverbound", - "id": 27 - }, - { - "name": "move_player_pos", - "phase": "play", - "side": "serverbound", - "id": 28 - }, - { - "name": "move_player_pos_rot", - "phase": "play", - "side": "serverbound", - "id": 29 - }, - { - "name": "move_player_rot", - "phase": "play", - "side": "serverbound", - "id": 30 - }, - { - "name": "move_player_status_only", - "phase": "play", - "side": "serverbound", - "id": 31 - }, - { - "name": "move_vehicle", - "phase": "play", - "side": "serverbound", - "id": 32 - }, - { - "name": "paddle_boat", - "phase": "play", - "side": "serverbound", - "id": 33 - }, - { - "name": "pick_item", - "phase": "play", - "side": "serverbound", - "id": 34 - }, - { - "name": "ping_request", - "phase": "play", - "side": "serverbound", - "id": 35 - }, - { - "name": "place_recipe", - "phase": "play", - "side": "serverbound", - "id": 36 - }, - { - "name": "player_abilities", - "phase": "play", - "side": "serverbound", - "id": 37 - }, - { - "name": "player_action", - "phase": "play", - "side": "serverbound", - "id": 38 - }, - { - "name": "player_command", - "phase": "play", - "side": "serverbound", - "id": 39 - }, - { - "name": "player_input", - "phase": "play", - "side": "serverbound", - "id": 40 - }, - { - "name": "pong", - "phase": "play", - "side": "serverbound", - "id": 41 - }, - { - "name": "recipe_book_change_settings", - "phase": "play", - "side": "serverbound", - "id": 42 - }, - { - "name": "recipe_book_seen_recipe", - "phase": "play", - "side": "serverbound", - "id": 43 - }, - { - "name": "rename_item", - "phase": "play", - "side": "serverbound", - "id": 44 - }, - { - "name": "resource_pack", - "phase": "play", - "side": "serverbound", - "id": 45 - }, - { - "name": "seen_advancements", - "phase": "play", - "side": "serverbound", - "id": 46 - }, - { - "name": "select_trade", - "phase": "play", - "side": "serverbound", - "id": 47 - }, - { - "name": "set_beacon", - "phase": "play", - "side": "serverbound", - "id": 48 - }, - { - "name": "set_carried_item", - "phase": "play", - "side": "serverbound", - "id": 49 - }, - { - "name": "set_command_block", - "phase": "play", - "side": "serverbound", - "id": 50 - }, - { - "name": "set_command_minecart", - "phase": "play", - "side": "serverbound", - "id": 51 - }, - { - "name": "set_creative_mode_slot", - "phase": "play", - "side": "serverbound", - "id": 52 - }, - { - "name": "set_jigsaw_block", - "phase": "play", - "side": "serverbound", - "id": 53 - }, - { - "name": "set_structure_block", - "phase": "play", - "side": "serverbound", - "id": 54 - }, - { - "name": "sign_update", - "phase": "play", - "side": "serverbound", - "id": 55 - }, - { - "name": "swing", - "phase": "play", - "side": "serverbound", - "id": 56 - }, - { - "name": "teleport_to_entity", - "phase": "play", - "side": "serverbound", - "id": 57 - }, - { - "name": "use_item_on", - "phase": "play", - "side": "serverbound", - "id": 58 - }, - { - "name": "use_item", - "phase": "play", - "side": "serverbound", - "id": 59 - }, - { - "name": "bundle_delimiter", - "phase": "play", - "side": "clientbound", - "id": 0 - }, - { - "name": "add_entity", - "phase": "play", - "side": "clientbound", - "id": 1 - }, - { - "name": "add_experience_orb", - "phase": "play", - "side": "clientbound", - "id": 2 - }, - { - "name": "animate", - "phase": "play", - "side": "clientbound", - "id": 3 - }, - { - "name": "award_stats", - "phase": "play", - "side": "clientbound", - "id": 4 - }, - { - "name": "block_changed_ack", - "phase": "play", - "side": "clientbound", - "id": 5 - }, - { - "name": "block_destruction", - "phase": "play", - "side": "clientbound", - "id": 6 - }, - { - "name": "block_entity_data", - "phase": "play", - "side": "clientbound", - "id": 7 - }, - { - "name": "block_event", - "phase": "play", - "side": "clientbound", - "id": 8 - }, - { - "name": "block_update", - "phase": "play", - "side": "clientbound", - "id": 9 - }, - { - "name": "boss_event", - "phase": "play", - "side": "clientbound", - "id": 10 - }, - { - "name": "change_difficulty", - "phase": "play", - "side": "clientbound", - "id": 11 - }, - { - "name": "chunk_batch_finished", - "phase": "play", - "side": "clientbound", - "id": 12 - }, - { - "name": "chunk_batch_start", - "phase": "play", - "side": "clientbound", - "id": 13 - }, - { - "name": "chunks_biomes", - "phase": "play", - "side": "clientbound", - "id": 14 - }, - { - "name": "clear_titles", - "phase": "play", - "side": "clientbound", - "id": 15 - }, - { - "name": "command_suggestions", - "phase": "play", - "side": "clientbound", - "id": 16 - }, - { - "name": "commands", - "phase": "play", - "side": "clientbound", - "id": 17 - }, - { - "name": "container_close", - "phase": "play", - "side": "clientbound", - "id": 18 - }, - { - "name": "container_set_content", - "phase": "play", - "side": "clientbound", - "id": 19 - }, - { - "name": "container_set_data", - "phase": "play", - "side": "clientbound", - "id": 20 - }, - { - "name": "container_set_slot", - "phase": "play", - "side": "clientbound", - "id": 21 - }, - { - "name": "cookie_request", - "phase": "play", - "side": "clientbound", - "id": 22 - }, - { - "name": "cooldown", - "phase": "play", - "side": "clientbound", - "id": 23 - }, - { - "name": "custom_chat_completions", - "phase": "play", - "side": "clientbound", - "id": 24 - }, - { - "name": "custom_payload", - "phase": "play", - "side": "clientbound", - "id": 25 - }, - { - "name": "damage_event", - "phase": "play", - "side": "clientbound", - "id": 26 - }, - { - "name": "debug_sample", - "phase": "play", - "side": "clientbound", - "id": 27 - }, - { - "name": "delete_chat", - "phase": "play", - "side": "clientbound", - "id": 28 - }, - { - "name": "disconnect", - "phase": "play", - "side": "clientbound", - "id": 29 - }, - { - "name": "disguised_chat", - "phase": "play", - "side": "clientbound", - "id": 30 - }, - { - "name": "entity_event", - "phase": "play", - "side": "clientbound", - "id": 31 - }, - { - "name": "entity_position_sync", - "phase": "play", - "side": "clientbound", - "id": 32 - }, - { - "name": "explode", - "phase": "play", - "side": "clientbound", - "id": 33 - }, - { - "name": "forget_level_chunk", - "phase": "play", - "side": "clientbound", - "id": 34 - }, - { - "name": "game_event", - "phase": "play", - "side": "clientbound", - "id": 35 - }, - { - "name": "horse_screen_open", - "phase": "play", - "side": "clientbound", - "id": 36 - }, - { - "name": "hurt_animation", - "phase": "play", - "side": "clientbound", - "id": 37 - }, - { - "name": "initialize_border", - "phase": "play", - "side": "clientbound", - "id": 38 - }, - { - "name": "keep_alive", - "phase": "play", - "side": "clientbound", - "id": 39 - }, - { - "name": "level_chunk_with_light", - "phase": "play", - "side": "clientbound", - "id": 40 - }, - { - "name": "level_event", - "phase": "play", - "side": "clientbound", - "id": 41 - }, - { - "name": "level_particles", - "phase": "play", - "side": "clientbound", - "id": 42 - }, - { - "name": "light_update", - "phase": "play", - "side": "clientbound", - "id": 43 - }, - { - "name": "login", - "phase": "play", - "side": "clientbound", - "id": 44 - }, - { - "name": "map_item_data", - "phase": "play", - "side": "clientbound", - "id": 45 - }, - { - "name": "merchant_offers", - "phase": "play", - "side": "clientbound", - "id": 46 - }, - { - "name": "move_entity_pos", - "phase": "play", - "side": "clientbound", - "id": 47 - }, - { - "name": "move_entity_pos_rot", - "phase": "play", - "side": "clientbound", - "id": 48 - }, - { - "name": "move_minecart_along_track", - "phase": "play", - "side": "clientbound", - "id": 49 - }, - { - "name": "move_entity_rot", - "phase": "play", - "side": "clientbound", - "id": 50 - }, - { - "name": "move_vehicle", - "phase": "play", - "side": "clientbound", - "id": 51 - }, - { - "name": "open_book", - "phase": "play", - "side": "clientbound", - "id": 52 - }, - { - "name": "open_screen", - "phase": "play", - "side": "clientbound", - "id": 53 - }, - { - "name": "open_sign_editor", - "phase": "play", - "side": "clientbound", - "id": 54 - }, - { - "name": "ping", - "phase": "play", - "side": "clientbound", - "id": 55 - }, - { - "name": "pong_response", - "phase": "play", - "side": "clientbound", - "id": 56 - }, - { - "name": "place_ghost_recipe", - "phase": "play", - "side": "clientbound", - "id": 57 - }, - { - "name": "player_abilities", - "phase": "play", - "side": "clientbound", - "id": 58 - }, - { - "name": "player_chat", - "phase": "play", - "side": "clientbound", - "id": 59 - }, - { - "name": "player_combat_end", - "phase": "play", - "side": "clientbound", - "id": 60 - }, - { - "name": "player_combat_enter", - "phase": "play", - "side": "clientbound", - "id": 61 - }, - { - "name": "player_combat_kill", - "phase": "play", - "side": "clientbound", - "id": 62 - }, - { - "name": "player_info_remove", - "phase": "play", - "side": "clientbound", - "id": 63 - }, - { - "name": "player_info_update", - "phase": "play", - "side": "clientbound", - "id": 64 - }, - { - "name": "player_look_at", - "phase": "play", - "side": "clientbound", - "id": 65 - }, - { - "name": "player_position", - "phase": "play", - "side": "clientbound", - "id": 66 - }, - { - "name": "player_rotation", - "phase": "play", - "side": "clientbound", - "id": 67 - }, - { - "name": "recipe_book_add", - "phase": "play", - "side": "clientbound", - "id": 68 - }, - { - "name": "recipe_book_remove", - "phase": "play", - "side": "clientbound", - "id": 69 - }, - { - "name": "recipe_book_settings", - "phase": "play", - "side": "clientbound", - "id": 70 - }, - { - "name": "remove_entities", - "phase": "play", - "side": "clientbound", - "id": 71 - }, - { - "name": "remove_mob_effect", - "phase": "play", - "side": "clientbound", - "id": 72 - }, - { - "name": "reset_score", - "phase": "play", - "side": "clientbound", - "id": 73 - }, - { - "name": "resource_pack_pop", - "phase": "play", - "side": "clientbound", - "id": 74 - }, - { - "name": "resource_pack_push", - "phase": "play", - "side": "clientbound", - "id": 75 - }, - { - "name": "respawn", - "phase": "play", - "side": "clientbound", - "id": 76 - }, - { - "name": "rotate_head", - "phase": "play", - "side": "clientbound", - "id": 77 - }, - { - "name": "section_blocks_update", - "phase": "play", - "side": "clientbound", - "id": 78 - }, - { - "name": "select_advancements_tab", - "phase": "play", - "side": "clientbound", - "id": 79 - }, - { - "name": "server_data", - "phase": "play", - "side": "clientbound", - "id": 80 - }, - { - "name": "set_action_bar_text", - "phase": "play", - "side": "clientbound", - "id": 81 - }, - { - "name": "set_border_center", - "phase": "play", - "side": "clientbound", - "id": 82 - }, - { - "name": "set_border_lerp_size", - "phase": "play", - "side": "clientbound", - "id": 83 - }, - { - "name": "set_border_size", - "phase": "play", - "side": "clientbound", - "id": 84 - }, - { - "name": "set_border_warning_delay", - "phase": "play", - "side": "clientbound", - "id": 85 - }, - { - "name": "set_border_warning_distance", - "phase": "play", - "side": "clientbound", - "id": 86 - }, - { - "name": "set_camera", - "phase": "play", - "side": "clientbound", - "id": 87 - }, - { - "name": "set_chunk_cache_center", - "phase": "play", - "side": "clientbound", - "id": 88 - }, - { - "name": "set_chunk_cache_radius", - "phase": "play", - "side": "clientbound", - "id": 89 - }, - { - "name": "set_cursor_item", - "phase": "play", - "side": "clientbound", - "id": 90 - }, - { - "name": "set_default_spawn_position", - "phase": "play", - "side": "clientbound", - "id": 91 - }, - { - "name": "set_display_objective", - "phase": "play", - "side": "clientbound", - "id": 92 - }, - { - "name": "set_entity_data", - "phase": "play", - "side": "clientbound", - "id": 93 - }, - { - "name": "set_entity_link", - "phase": "play", - "side": "clientbound", - "id": 94 - }, - { - "name": "set_entity_motion", - "phase": "play", - "side": "clientbound", - "id": 95 - }, - { - "name": "set_equipment", - "phase": "play", - "side": "clientbound", - "id": 96 - }, - { - "name": "set_experience", - "phase": "play", - "side": "clientbound", - "id": 97 - }, - { - "name": "set_health", - "phase": "play", - "side": "clientbound", - "id": 98 - }, - { - "name": "set_held_slot", - "phase": "play", - "side": "clientbound", - "id": 99 - }, - { - "name": "set_objective", - "phase": "play", - "side": "clientbound", - "id": 100 - }, - { - "name": "set_passengers", - "phase": "play", - "side": "clientbound", - "id": 101 - }, - { - "name": "set_player_inventory", - "phase": "play", - "side": "clientbound", - "id": 102 - }, - { - "name": "set_player_team", - "phase": "play", - "side": "clientbound", - "id": 103 - }, - { - "name": "set_score", - "phase": "play", - "side": "clientbound", - "id": 104 - }, - { - "name": "set_simulation_distance", - "phase": "play", - "side": "clientbound", - "id": 105 - }, - { - "name": "set_subtitle_text", - "phase": "play", - "side": "clientbound", - "id": 106 - }, - { - "name": "set_time", - "phase": "play", - "side": "clientbound", - "id": 107 - }, - { - "name": "set_title_text", - "phase": "play", - "side": "clientbound", - "id": 108 - }, - { - "name": "set_titles_animation", - "phase": "play", - "side": "clientbound", - "id": 109 - }, - { - "name": "sound_entity", - "phase": "play", - "side": "clientbound", - "id": 110 - }, - { - "name": "sound", - "phase": "play", - "side": "clientbound", - "id": 111 - }, - { - "name": "start_configuration", - "phase": "play", - "side": "clientbound", - "id": 112 - }, - { - "name": "stop_sound", - "phase": "play", - "side": "clientbound", - "id": 113 - }, - { - "name": "store_cookie", - "phase": "play", - "side": "clientbound", - "id": 114 - }, - { - "name": "system_chat", - "phase": "play", - "side": "clientbound", - "id": 115 - }, - { - "name": "tab_list", - "phase": "play", - "side": "clientbound", - "id": 116 - }, - { - "name": "tag_query", - "phase": "play", - "side": "clientbound", - "id": 117 - }, - { - "name": "take_item_entity", - "phase": "play", - "side": "clientbound", - "id": 118 - }, - { - "name": "teleport_entity", - "phase": "play", - "side": "clientbound", - "id": 119 - }, - { - "name": "ticking_state", - "phase": "play", - "side": "clientbound", - "id": 120 - }, - { - "name": "ticking_step", - "phase": "play", - "side": "clientbound", - "id": 121 - }, - { - "name": "transfer", - "phase": "play", - "side": "clientbound", - "id": 122 - }, - { - "name": "update_advancements", - "phase": "play", - "side": "clientbound", - "id": 123 - }, - { - "name": "update_attributes", - "phase": "play", - "side": "clientbound", - "id": 124 - }, - { - "name": "update_mob_effect", - "phase": "play", - "side": "clientbound", - "id": 125 - }, - { - "name": "update_recipes", - "phase": "play", - "side": "clientbound", - "id": 126 - }, - { - "name": "update_tags", - "phase": "play", - "side": "clientbound", - "id": 127 - }, - { - "name": "projectile_power", - "phase": "play", - "side": "clientbound", - "id": 128 - }, - { - "name": "custom_report_details", - "phase": "play", - "side": "clientbound", - "id": 129 - }, - { - "name": "server_links", - "phase": "play", - "side": "clientbound", - "id": 130 +{ + "serverbound": { + "status": { + "status_response": 0, + "pong_response": 1 + }, + "login": { + "login_disconnect": 0, + "hello": 1, + "login_finished": 2, + "login_compression": 3, + "custom_query": 4, + "cookie_request": 5 + }, + "config": { + "cookie_request": 0, + "custom_payload": 1, + "disconnect": 2, + "finish_configuration": 3, + "keep_alive": 4, + "ping": 5, + "reset_chat": 6, + "registry_data": 7, + "resource_pack_pop": 8, + "resource_pack_push": 9, + "store_cookie": 10, + "transfer": 11, + "update_enabled_features": 12, + "update_tags": 13, + "select_known_packs": 14, + "custom_report_details": 15, + "server_links": 16 + }, + "play": { + "bundle_delimiter": 0, + "add_entity": 1, + "add_experience_orb": 2, + "animate": 3, + "award_stats": 4, + "block_changed_ack": 5, + "block_destruction": 6, + "block_entity_data": 7, + "block_event": 8, + "block_update": 9, + "boss_event": 10, + "change_difficulty": 11, + "chunk_batch_finished": 12, + "chunk_batch_start": 13, + "chunks_biomes": 14, + "clear_titles": 15, + "command_suggestions": 16, + "commands": 17, + "container_close": 18, + "container_set_content": 19, + "container_set_data": 20, + "container_set_slot": 21, + "cookie_request": 22, + "cooldown": 23, + "custom_chat_completions": 24, + "custom_payload": 25, + "damage_event": 26, + "debug_sample": 27, + "delete_chat": 28, + "disconnect": 29, + "disguised_chat": 30, + "entity_event": 31, + "entity_position_sync": 32, + "explode": 33, + "forget_level_chunk": 34, + "game_event": 35, + "horse_screen_open": 36, + "hurt_animation": 37, + "initialize_border": 38, + "keep_alive": 39, + "level_chunk_with_light": 40, + "level_event": 41, + "level_particles": 42, + "light_update": 43, + "login": 44, + "map_item_data": 45, + "merchant_offers": 46, + "move_entity_pos": 47, + "move_entity_pos_rot": 48, + "move_minecart_along_track": 49, + "move_entity_rot": 50, + "move_vehicle": 51, + "open_book": 52, + "open_screen": 53, + "open_sign_editor": 54, + "ping": 55, + "pong_response": 56, + "place_ghost_recipe": 57, + "player_abilities": 58, + "player_chat": 59, + "player_combat_end": 60, + "player_combat_enter": 61, + "player_combat_kill": 62, + "player_info_remove": 63, + "player_info_update": 64, + "player_look_at": 65, + "player_position": 66, + "player_rotation": 67, + "recipe_book_add": 68, + "recipe_book_remove": 69, + "recipe_book_settings": 70, + "remove_entities": 71, + "remove_mob_effect": 72, + "reset_score": 73, + "resource_pack_pop": 74, + "resource_pack_push": 75, + "respawn": 76, + "rotate_head": 77, + "section_blocks_update": 78, + "select_advancements_tab": 79, + "server_data": 80, + "set_action_bar_text": 81, + "set_border_center": 82, + "set_border_lerp_size": 83, + "set_border_size": 84, + "set_border_warning_delay": 85, + "set_border_warning_distance": 86, + "set_camera": 87, + "set_chunk_cache_center": 88, + "set_chunk_cache_radius": 89, + "set_cursor_item": 90, + "set_default_spawn_position": 91, + "set_display_objective": 92, + "set_entity_data": 93, + "set_entity_link": 94, + "set_entity_motion": 95, + "set_equipment": 96, + "set_experience": 97, + "set_health": 98, + "set_held_slot": 99, + "set_objective": 100, + "set_passengers": 101, + "set_player_inventory": 102, + "set_player_team": 103, + "set_score": 104, + "set_simulation_distance": 105, + "set_subtitle_text": 106, + "set_time": 107, + "set_title_text": 108, + "set_titles_animation": 109, + "sound_entity": 110, + "sound": 111, + "start_configuration": 112, + "stop_sound": 113, + "store_cookie": 114, + "system_chat": 115, + "tab_list": 116, + "tag_query": 117, + "take_item_entity": 118, + "teleport_entity": 119, + "ticking_state": 120, + "ticking_step": 121, + "transfer": 122, + "update_advancements": 123, + "update_attributes": 124, + "update_mob_effect": 125, + "update_recipes": 126, + "update_tags": 127, + "projectile_power": 128, + "custom_report_details": 129, + "server_links": 130 + } + }, + "clientbound": { + "handshake": { + "intention": 0 + }, + "status": { + "status_request": 0, + "ping_request": 1 + }, + "login": { + "hello": 0, + "key": 1, + "custom_query_answer": 2, + "login_acknowledged": 3, + "cookie_response": 4 + }, + "config": { + "client_information": 0, + "cookie_response": 1, + "custom_payload": 2, + "finish_configuration": 3, + "keep_alive": 4, + "pong": 5, + "resource_pack": 6, + "select_known_packs": 7 + }, + "play": { + "accept_teleportation": 0, + "block_entity_tag_query": 1, + "bundle_item_selected": 2, + "change_difficulty": 3, + "chat_ack": 4, + "chat_command": 5, + "chat_command_signed": 6, + "chat": 7, + "chat_session_update": 8, + "chunk_batch_received": 9, + "client_command": 10, + "client_tick_end": 11, + "client_information": 12, + "command_suggestion": 13, + "configuration_acknowledged": 14, + "container_button_click": 15, + "container_click": 16, + "container_close": 17, + "container_slot_state_changed": 18, + "cookie_response": 19, + "custom_payload": 20, + "debug_sample_subscription": 21, + "edit_book": 22, + "entity_tag_query": 23, + "interact": 24, + "jigsaw_generate": 25, + "keep_alive": 26, + "lock_difficulty": 27, + "move_player_pos": 28, + "move_player_pos_rot": 29, + "move_player_rot": 30, + "move_player_status_only": 31, + "move_vehicle": 32, + "paddle_boat": 33, + "pick_item": 34, + "ping_request": 35, + "place_recipe": 36, + "player_abilities": 37, + "player_action": 38, + "player_command": 39, + "player_input": 40, + "pong": 41, + "recipe_book_change_settings": 42, + "recipe_book_seen_recipe": 43, + "rename_item": 44, + "resource_pack": 45, + "seen_advancements": 46, + "select_trade": 47, + "set_beacon": 48, + "set_carried_item": 49, + "set_command_block": 50, + "set_command_minecart": 51, + "set_creative_mode_slot": 52, + "set_jigsaw_block": 53, + "set_structure_block": 54, + "sign_update": 55, + "swing": 56, + "teleport_to_entity": 57, + "use_item_on": 58, + "use_item": 59 + } } -] \ No newline at end of file +} \ No newline at end of file diff --git a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt index de666ff31..c32a7a4d6 100644 --- a/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt +++ b/extractor/src/main/kotlin/de/snowii/extractor/extractors/Packets.kt @@ -1,12 +1,14 @@ package de.snowii.extractor.extractors -import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonObject import de.snowii.extractor.Extractor import io.netty.buffer.ByteBuf +import net.minecraft.network.NetworkPhase import net.minecraft.network.NetworkState -import net.minecraft.network.listener.PacketListener +import net.minecraft.network.PacketByteBuf +import net.minecraft.network.listener.ClientPacketListener +import net.minecraft.network.listener.ServerCrashSafePacketListener import net.minecraft.network.packet.PacketType import net.minecraft.network.state.* import net.minecraft.server.MinecraftServer @@ -18,32 +20,85 @@ class Packets : Extractor.Extractor { } override fun extract(server: MinecraftServer): JsonElement { - val packetsJson = JsonArray() + val packetsJson = JsonObject() - serializeFactory(HandshakeStates.C2S_FACTORY, packetsJson) - serializeFactory(QueryStates.C2S_FACTORY, packetsJson) - serializeFactory(QueryStates.S2C_FACTORY, packetsJson) - serializeFactory(LoginStates.C2S_FACTORY, packetsJson) - serializeFactory(LoginStates.S2C_FACTORY, packetsJson) - serializeFactory(ConfigurationStates.C2S_FACTORY, packetsJson) - serializeFactory(ConfigurationStates.S2C_FACTORY, packetsJson) - serializeFactory(PlayStateFactories.C2S, packetsJson) - serializeFactory(PlayStateFactories.S2C, packetsJson) + val serverBound = arrayOf( + QueryStates.S2C_FACTORY, + LoginStates.S2C_FACTORY, + ConfigurationStates.S2C_FACTORY, + PlayStateFactories.S2C + ) + + val clientBound = arrayOf( + HandshakeStates.C2S_FACTORY, + QueryStates.C2S_FACTORY, + LoginStates.C2S_FACTORY, + ConfigurationStates.C2S_FACTORY, + PlayStateFactories.C2S + ) + val serverBoundJson = serializeServerBound(serverBound) + val clientBoundJson = serializeClientBound(clientBound) + + packetsJson.add("serverbound", serverBoundJson) + packetsJson.add("clientbound", clientBoundJson) return packetsJson } - private fun serializeFactory( - factory: NetworkState.Factory, - json: JsonArray - ) { - factory.forEachPacketType { type: PacketType<*>, i: Int -> - val packetJson = JsonObject() - packetJson.addProperty("name", type.id().path) - packetJson.addProperty("phase", factory.phase().id) - packetJson.addProperty("side", factory.side().getName()) - packetJson.addProperty("id", i) - json.add(packetJson) + + private fun serializeServerBound( + packets: Array> + ): JsonObject { + val statusArray = JsonObject() + val loginArray = JsonObject() + val configArray = JsonObject() + val playArray = JsonObject() + + for (factory in packets) { + factory.forEachPacketType { type: PacketType<*>, i: Int -> + when (factory.phase()!!) { + NetworkPhase.HANDSHAKING -> error("Server bound Packet should have no handshake") + NetworkPhase.PLAY -> playArray.addProperty(type.id().path, i) + NetworkPhase.STATUS -> statusArray.addProperty(type.id().path, i) + NetworkPhase.LOGIN -> loginArray.addProperty(type.id().path, i) + NetworkPhase.CONFIGURATION -> configArray.addProperty(type.id().path, i) + } + } } + val finalJson = JsonObject() + finalJson.add("status", statusArray) + finalJson.add("login", loginArray) + finalJson.add("config", configArray) + finalJson.add("play", playArray) + return finalJson + } + + private fun serializeClientBound( + packets: Array> + ): JsonObject { + val handshakeArray = JsonObject() + val statusArray = JsonObject() + val loginArray = JsonObject() + val configArray = JsonObject() + val playArray = JsonObject() + + for (factory in packets) { + factory.forEachPacketType { type: PacketType<*>, i: Int -> + when (factory.phase()!!) { + NetworkPhase.HANDSHAKING -> handshakeArray.addProperty(type.id().path, i) + NetworkPhase.PLAY -> playArray.addProperty(type.id().path, i) + NetworkPhase.STATUS -> statusArray.addProperty(type.id().path, i) + NetworkPhase.LOGIN -> loginArray.addProperty(type.id().path, i) + NetworkPhase.CONFIGURATION -> configArray.addProperty(type.id().path, i) + } + } + } + val finalJson = JsonObject() + finalJson.add("handshake", handshakeArray) + finalJson.add("status", statusArray) + finalJson.add("login", loginArray) + finalJson.add("config", configArray) + finalJson.add("play", playArray) + return finalJson } } diff --git a/pumpkin-macros/src/packet.rs b/pumpkin-macros/src/packet.rs index 0d0a7c1a7..1c2c6ea37 100644 --- a/pumpkin-macros/src/packet.rs +++ b/pumpkin-macros/src/packet.rs @@ -5,37 +5,41 @@ use quote::quote; use serde::Deserialize; #[derive(Deserialize)] -pub struct Packet { - name: String, - phase: String, - side: String, - id: u16, +pub struct Packets { + serverbound: HashMap>, + clientbound: HashMap>, } -static PACKETS: LazyLock> = LazyLock::new(|| { - serde_json::from_str::>(include_str!("../../assets/packets.json")) +static PACKETS: LazyLock = LazyLock::new(|| { + serde_json::from_str(include_str!("../../assets/packets.json")) .expect("Could not parse packets.json registry.") - .into_iter() - .map(|val| (format!("{}:{}:{}", val.side, val.phase, val.name), val.id)) - .collect() }); pub(crate) fn packet_clientbound(item: TokenStream) -> proc_macro2::TokenStream { let input_string = item.to_string(); let packet_name = input_string.trim_matches('"'); - - let id = PACKETS - .get(&format!("clientbound:{}", packet_name)) - .expect("Invalid Packet"); + let packet_name_split: Vec<&str> = packet_name.split(":").collect(); + let phase = PACKETS + .serverbound + .get(packet_name_split[0]) + .expect("Invalid Phase"); + let id = phase + .get(packet_name_split[1]) + .expect("Invalid Packet name"); quote! { #id } } pub(crate) fn packet_serverbound(item: TokenStream) -> proc_macro2::TokenStream { let input_string = item.to_string(); let packet_name = input_string.trim_matches('"'); + let packet_name_split: Vec<&str> = packet_name.split(":").collect(); - let id = PACKETS - .get(&format!("serverbound:{}", packet_name)) - .expect("Invalid Packet"); + let phase = PACKETS + .clientbound + .get(packet_name_split[0]) + .expect("Invalid Phase"); + let id = phase + .get(packet_name_split[1]) + .expect("Invalid Packet name"); quote! { #id } } diff --git a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs index 8718ffbe8..e73946835 100644 --- a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs +++ b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs @@ -4,7 +4,7 @@ use pumpkin_macros::client_packet; use serde::Serialize; #[derive(Serialize)] -#[client_packet("configuration:resource_pack_push")] +#[client_packet("config:resource_pack_push")] pub struct CConfigAddResourcePack<'a> { uuid: uuid::Uuid, url: &'a str, diff --git a/pumpkin-protocol/src/client/config/c_config_disconnect.rs b/pumpkin-protocol/src/client/config/c_config_disconnect.rs index 8b21b6ff3..cf0fc4def 100644 --- a/pumpkin-protocol/src/client/config/c_config_disconnect.rs +++ b/pumpkin-protocol/src/client/config/c_config_disconnect.rs @@ -1,7 +1,7 @@ use pumpkin_macros::client_packet; #[derive(serde::Serialize)] -#[client_packet("configuration:disconnect")] +#[client_packet("config:disconnect")] pub struct CConfigDisconnect<'a> { reason: &'a str, } diff --git a/pumpkin-protocol/src/client/config/c_cookie_request.rs b/pumpkin-protocol/src/client/config/c_cookie_request.rs index 66a76c6a3..402bab802 100644 --- a/pumpkin-protocol/src/client/config/c_cookie_request.rs +++ b/pumpkin-protocol/src/client/config/c_cookie_request.rs @@ -3,7 +3,7 @@ use pumpkin_macros::client_packet; use crate::Identifier; #[derive(serde::Serialize)] -#[client_packet("configuration:cookie_request")] +#[client_packet("config:cookie_request")] pub struct CCookieRequest { key: Identifier, } diff --git a/pumpkin-protocol/src/client/config/c_finish_config.rs b/pumpkin-protocol/src/client/config/c_finish_config.rs index 18e6d1b3d..acb301b99 100644 --- a/pumpkin-protocol/src/client/config/c_finish_config.rs +++ b/pumpkin-protocol/src/client/config/c_finish_config.rs @@ -1,7 +1,7 @@ use pumpkin_macros::client_packet; #[derive(serde::Serialize)] -#[client_packet("configuration:finish_configuration")] +#[client_packet("config:finish_configuration")] pub struct CFinishConfig {} impl Default for CFinishConfig { diff --git a/pumpkin-protocol/src/client/config/c_known_packs.rs b/pumpkin-protocol/src/client/config/c_known_packs.rs index 0ee3c317c..89f7d7e6a 100644 --- a/pumpkin-protocol/src/client/config/c_known_packs.rs +++ b/pumpkin-protocol/src/client/config/c_known_packs.rs @@ -2,7 +2,7 @@ use pumpkin_macros::client_packet; use crate::{bytebuf::ByteBuffer, ClientPacket, KnownPack}; -#[client_packet("configuration:select_known_packs")] +#[client_packet("config:select_known_packs")] pub struct CKnownPacks<'a> { known_packs: &'a [KnownPack<'a>], } diff --git a/pumpkin-protocol/src/client/config/c_plugin_message.rs b/pumpkin-protocol/src/client/config/c_plugin_message.rs index 92286fd4e..ba519e91e 100644 --- a/pumpkin-protocol/src/client/config/c_plugin_message.rs +++ b/pumpkin-protocol/src/client/config/c_plugin_message.rs @@ -2,7 +2,7 @@ use pumpkin_macros::client_packet; use serde::Serialize; #[derive(Serialize)] -#[client_packet("configuration:custom_payload")] +#[client_packet("config:custom_payload")] pub struct CPluginMessage<'a> { channel: &'a str, data: &'a [u8], diff --git a/pumpkin-protocol/src/client/config/c_registry_data.rs b/pumpkin-protocol/src/client/config/c_registry_data.rs index 7cb81455e..38a3deecb 100644 --- a/pumpkin-protocol/src/client/config/c_registry_data.rs +++ b/pumpkin-protocol/src/client/config/c_registry_data.rs @@ -2,7 +2,7 @@ use pumpkin_macros::client_packet; use crate::{bytebuf::ByteBuffer, ClientPacket}; -#[client_packet("configuration:registry_data")] +#[client_packet("config:registry_data")] pub struct CRegistryData<'a> { registry_id: &'a str, entries: &'a [RegistryEntry<'a>], diff --git a/pumpkin-protocol/src/server/config/s_acknowledge_finish_config.rs b/pumpkin-protocol/src/server/config/s_acknowledge_finish_config.rs index 7796b8510..da08345cd 100644 --- a/pumpkin-protocol/src/server/config/s_acknowledge_finish_config.rs +++ b/pumpkin-protocol/src/server/config/s_acknowledge_finish_config.rs @@ -1,5 +1,5 @@ use pumpkin_macros::server_packet; #[derive(serde::Deserialize)] -#[server_packet("configuration:finish_configuration")] +#[server_packet("config:finish_configuration")] pub struct SAcknowledgeFinishConfig {} diff --git a/pumpkin-protocol/src/server/config/s_client_information.rs b/pumpkin-protocol/src/server/config/s_client_information.rs index ba6823f7e..ecb6fe1cf 100644 --- a/pumpkin-protocol/src/server/config/s_client_information.rs +++ b/pumpkin-protocol/src/server/config/s_client_information.rs @@ -3,7 +3,7 @@ use pumpkin_macros::server_packet; use crate::VarInt; #[derive(serde::Deserialize)] -#[server_packet("configuration:client_information")] +#[server_packet("config:client_information")] pub struct SClientInformationConfig { pub locale: String, // 16 pub view_distance: i8, diff --git a/pumpkin-protocol/src/server/config/s_known_packs.rs b/pumpkin-protocol/src/server/config/s_known_packs.rs index 138cf2ae2..e935ff9ba 100644 --- a/pumpkin-protocol/src/server/config/s_known_packs.rs +++ b/pumpkin-protocol/src/server/config/s_known_packs.rs @@ -3,7 +3,7 @@ use pumpkin_macros::server_packet; use crate::VarInt; #[derive(serde::Deserialize)] -#[server_packet("configuration:select_known_packs")] +#[server_packet("config:select_known_packs")] pub struct SKnownPacks { pub known_pack_count: VarInt, // known_packs: &'a [KnownPack] diff --git a/pumpkin-protocol/src/server/config/s_plugin_message.rs b/pumpkin-protocol/src/server/config/s_plugin_message.rs index 7007f35d8..ea20a35c0 100644 --- a/pumpkin-protocol/src/server/config/s_plugin_message.rs +++ b/pumpkin-protocol/src/server/config/s_plugin_message.rs @@ -5,7 +5,7 @@ use crate::{ Identifier, ServerPacket, }; -#[server_packet("configuration:custom_payload")] +#[server_packet("config:custom_payload")] pub struct SPluginMessage { pub channel: Identifier, pub data: Vec,