From 39bf3d6aba245a75a87a1ea6d40e43b997859ca3 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 07:51:41 -0400 Subject: [PATCH 001/106] update protocol to 0.15 and start jwt decryption --- README.md | 2 +- data/protocol.json | 216 +++++++++++++++++++++++++++------------------ jwt.js | 25 ++++++ package.json | 1 + 4 files changed, 156 insertions(+), 88 deletions(-) create mode 100644 jwt.js diff --git a/README.md b/README.md index ed407ea..813b64b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Parse and serialize Minecraft PE packets. ## Features - * Supports Minecraft PE `0.14.3` + * Supports Minecraft PE `0.14.3` and `0.15.0` * Pure JavaScript * Easily send and listen for any packet * RakNet support through [node-raknet](https://github.com/mhsjlw/node-raknet) diff --git a/data/protocol.json b/data/protocol.json index 8964c20..9d4a087 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -310,7 +310,7 @@ [ { "name": "slot", - "type": "slot" + "type": "itemstacks" } ] ] @@ -567,60 +567,63 @@ "0x14": "id_no_free_incoming_connections", "0x17": "id_connection_banned", "0x1A": "id_ip_recently_connected", - "0x8f": "game_login", - "0x90": "player_status", - "0x91": "disconnect", - "0x92": "batch", - "0x93": "text", - "0x94": "set_time", - "0x95": "start_game", - "0x96": "add_player", - "0x97": "remove_player", - "0x98": "add_entity", - "0x99": "remove_entity", - "0x9a": "add_item_entity", - "0x9b": "take_item_entity", - "0x9c": "move_entity", - "0x9d": "move_player", - "0x9e": "remove_block", - "0x9f": "update_block", - "0xa0": "add_painting", - "0xa1": "explode", - "0xa2": "level_event", - "0xa3": "tile_event", - "0xa4": "entity_event", - "0xa5": "mob_effect", - "0xa6": "update_attributes", - "0xa7": "player_equipment", - "0xa8": "player_armor_equipment", - "0xa9": "interact", - "0xaa": "use_item", - "0xab": "player_action", - "0xac": "hurt_armor", - "0xad": "set_entity_data", - "0xae": "set_entity_motion", - "0xaf": "set_entity_link", - "0xb0": "set_health", - "0xb1": "set_spawn_position", - "0xb2": "animate", - "0xb3": "respawn", - "0xb4": "drop_item", - "0xb5": "container_open", - "0xb6": "container_close", - "0xb7": "container_set_slot", - "0xb8": "container_set_data", - "0xb9": "container_set_content", - "0xba": "crafting_data", - "0xbb": "crafting_event", - "0xbc": "adventure_settings", - "0xbd": "tile_entity_data", - "0xbf": "full_chunk_data", - "0xc0": "set_difficulty", - "0xc3": "player_list", - "0xc8": "request_chunk_radius", - "0xc9": "chunk_radius_update", - "0x1b": "transfer", - "0xc5": "spawn_experience_orb" + "0x03": "server_to_client_handshake", + "0x04": "client_to_server_handshake", + "0x01": "game_login", + "0x02": "player_status", + "0x05": "disconnect", + "0x06": "batch", + "0x07": "text", + "0x08": "set_time", + "0x09": "start_game", + "0x0a": "add_player", + "0x0b": "remove_player", + "0x0c": "add_entity", + "0x0d": "remove_entity", + "0x0e": "add_item_entity", + "0x0f": "take_item_entity", + "0x10": "move_entity", + "0x11": "move_player", + "0x12": "remove_block", + "0x13": "update_block", + "0x14": "add_painting", + "0x15": "explode", + "0x16": "level_event", + "0x17": "tile_event", + "0x18": "entity_event", + "0x19": "mob_effect", + "0x1a": "update_attributes", + "0x1b": "player_equipment", + "0x1c": "player_armor_equipment", + "0x1d": "interact", + "0x1e": "use_item", + "0x1f": "player_action", + "0x20": "hurt_armor", + "0x21": "set_entity_data", + "0x22": "set_entity_motion", + "0x23": "set_entity_link", + "0x24": "set_health", + "0x25": "set_spawn_position", + "0x26": "animate", + "0x27": "respawn", + "0x28": "drop_item", + "0x29": "container_open", + "0x2a": "container_close", + "0x2b": "container_set_slot", + "0x2c": "container_set_data", + "0x2d": "container_set_content", + "0x2e": "crafting_data", + "0x2f": "crafting_event", + "0x30": "adventure_settings", + "0x31": "tile_entity_data", + "0x32": "player_input", + "0x33": "full_chunk_data", + "0x34": "set_difficulty", + "0x37": "player_list", + "0x3c": "request_chunk_radius", + "0x3d": "chunk_radius_update", + "0x3a": "spawn_experience_orb", + "0x3f": "replace_selected_item" } } ] @@ -636,6 +639,8 @@ "id_no_free_incoming_connections": "packet_id_no_free_incoming_connections", "id_connection_banned": "packet_id_connection_banned", "id_ip_recently_connected": "packet_id_ip_recently_connected", + "server_to_client_handshake": "packet_server_to_client_handshake", + "client_to_server_handshake": "packet_client_to_server_handshake", "game_login": "packet_game_login", "player_status": "packet_player_status", "disconnect": "packet_disconnect", @@ -689,7 +694,8 @@ "request_chunk_radius": "packet_request_chunk_radius", "chunk_radius_update": "packet_chunk_radius_update", "transfer": "packet_transfer", - "spawn_experience_orb": "packet_spawn_experience_orb" + "spawn_experience_orb": "packet_spawn_experience_orb", + "replace_selected_item": "packet_replace_selected_item" } } ] @@ -712,40 +718,50 @@ "container", [] ], + "server_to_client_handshake": [ + "container", + [ + { + "name": "public_key", + "type": "string" + }, + { + "name": "server_token", + "type": "string" + } + ] + ], + "client_to_server_handshake": [ + "container", + [ + { + "name": "magic", + "type": "i64" + } + ] + ], "packet_game_login": [ "container", [ { - "name": "username", - "type": "string" + "name": "unknown", + "type": "short" }, { "name": "protocol", + "type": "long" + }, + { + "name": "body_length", "type": "i32" }, { - "name": "protocol2", - "type": "i32" + "name": "chain", + "type": ["pstring", {"countType": "li32"}] }, { - "name": "client_id", - "type": "i64" - }, - { - "name": "client_uuid", - "type": "uuid" - }, - { - "name": "server_address", - "type": "string" - }, - { - "name": "client_secret", - "type": ["buffer",{"countType":"i16"}] - }, - { - "name": "skin", - "type": "skin" + "name": "client_data", + "type": ["pstring", {"countType": "li32"}] } ] ], @@ -864,7 +880,7 @@ }, { "name": "gamemode", - "type": "i32" + "type": "i8" }, { "name": "entity_id", @@ -895,19 +911,19 @@ "type": "f32" }, { - "name": "unknown1", + "name": "is_loaded_in_creative", + "type": "bool" + }, + { + "name": "day_cycle_stop_time", "type": "i8" }, { - "name": "unknown2", - "type": "i8" + "name": "edu_mode", + "type": "bool" }, { - "name": "unknown3", - "type": "i8" - }, - { - "name": "unknown4", + "name": "unknown", "type": "string" } ] @@ -1794,6 +1810,23 @@ } ] ], + "packet_player_input": [ + "container", + [ + { + "name": "motion_x", + "type": "f32" + }, + { + "name": "motion_z", + "type": "f32" + }, + { + "name": "flags", + "type": "short" + } + ] + ], "packet_full_chunk_data": [ "container", [ @@ -1931,6 +1964,15 @@ "type": "i32" } ] + ], + "packet_replace_selected_item": [ + "container", + [ + { + "name": "slot", + "type": "slot" + } + ] ] } } diff --git a/jwt.js b/jwt.js new file mode 100644 index 0000000..7d14499 --- /dev/null +++ b/jwt.js @@ -0,0 +1,25 @@ +var jwt = require('jwt-simple'); +var example = { + "chain": { + "chain": [ + "eyJ4NXUiOiJNSFl3RUFZSEtvWkl6ajBDQVFZRks0RUVBQ0lEWWdBRThFTGtpeHlMY3dsWnJ5VVFjdTFUdlBPbUkyQjd2WDgzbmRuV1JVYVhtNzR3RmZhNWZcL2x3UU5UZnJMVkhhMlBtZW5wR0k2SmhJTVVKYVdacmptTWo5ME5vS05GU05CdUtkbThyWWlYc2ZhejNLMzZ4XC8xVTI2SHBHMFp4S1wvVjFWIiwiYWxnIjoiRVMzODQifQ.eyJuYmYiOjE0NjA4OTYzMzcsInJhbmRvbU5vbmNlIjo3MzI2MDA4MDM2OTAzODU5NzM0LCJpc3MiOiJSZWFsbXNBdXRob3JpemF0aW9uIiwiZXhwIjoxNDYwOTgyNzk3LCJpYXQiOjE0NjA4OTYzOTcsImNlcnRpZmljYXRlQXV0aG9yaXR5Ijp0cnVlLCJpZGVudGl0eVB1YmxpY0tleSI6Ik1IWXdFQVlIS29aSXpqMENBUVlGSzRFRUFDSURZZ0FFQlJ1MEd5VUFkYkZjd1wvUU1vNmFBTGFaZHJTeVNkZFwva1F2OXFHOHlHSWxnc0orVStNMVVpZWtjaDFPc3NHdXlFZW1oSWR1OUZWYklJanRWKzY4bXVkc0orSE1MdGYrMDJTYVk0elBtXC9iR3RURkRIUDBRK2FoUmhvVWRiNVptaFwvIn0.J9vCSKZOH6ZuO_rMv3Tlo0Z7nAnXI44rdlL4FyXcWfdTHG3HlHywos0WLWnMnlxP_Ex2co2M21CSyIhIFM6EvugemsuEZIQpz3WTAmUlaEoaNT7dgGFbqGUn9tr6S1MD", + "eyJ4NXUiOiJNSFl3RUFZSEtvWkl6ajBDQVFZRks0RUVBQ0lEWWdBRUJSdTBHeVVBZGJGY3dcL1FNbzZhQUxhWmRyU3lTZGRcL2tRdjlxRzh5R0lsZ3NKK1UrTTFVaWVrY2gxT3NzR3V5RWVtaElkdTlGVmJJSWp0Vis2OG11ZHNKK0hNTHRmKzAyU2FZNHpQbVwvYkd0VEZESFAwUSthaFJob1VkYjVabWhcLyIsImFsZyI6IkVTMzg0In0.eyJuYmYiOjE0NjA4OTYzMzcsImV4dHJhRGF0YSI6eyJpZGVudGl0eSI6Ijk4YjBjYmNmLWU5MWUtMzAwNC05NjUyLWFlZDkyZjhlMjU2ZCIsImRpc3BsYXlOYW1lIjoieWF3a2F0IiwiWFVJRCI6IjI1MzU0Mzc2MTMzNTc1MzUifSwicmFuZG9tTm9uY2UiOi0zMzg4NzY3NzYzMDEyODY5NTg3LCJpc3MiOiJSZWFsbXNBdXRob3JpemF0aW9uIiwiZXhwIjoxNDYwOTgyNzk3LCJpYXQiOjE0NjA4OTYzOTcsImlkZW50aXR5UHVibGljS2V5IjoiTUhZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUNJRFlnQUVERUtuZXFFdmNxVXFxRk1NMUhNMUE0eldqSkMrSThZK2FLekc1ZGwrNndOT0hIUTRObUcyUEVYUkpZaHVqeW9kRkgrd08wZEVyNEdNMVdvYVdvZzh4c1lRNm1RSkFDMGVWcEJNOTZzcFVCMWVNTjU2K0J3bEo0SDNReDRUQXZBcyJ9.gmAdOsTXU68QIqWweaU9FBuSyhNHcGI2hslrP0AQtVqGHyfPIhm54aUesZSj9mLGIIJTx_I50wijDlsj_lFExb3W3UQV0BDWCsYNBoJ5Kb9AX5O11onqtGbNynCVufJB" + ] + }, + "clientData": "eyJhbGciOiJFUzM4NCIsIng1dSI6Ik1IWXdFQVlIS29aSXpqMENBUVlGSzRFRUFDSURZZ0FFREVLbmVxRXZjcVVxcUZNTTFITTFBNHpXakpDK0k4WSthS3pHNWRsKzZ3Tk9ISFE0Tm1HMlBFWFJKWWh1anlvZEZIK3dPMGRFcjRHTTFXb2FXb2c4eHNZUTZtUUpBQzBlVnBCTTk2c3BVQjFlTU41NitCd2xKNEgzUXg0VEF2QXMifQo,.eyJDbGllbnRSYW5kb21JZCI6MTM2NTg2NDYwOCwiU2VydmVyQWRkcmVzcyI6IjE5Mi4xNjguMS41NjoxOTEzMiIsIlNraW5EYXRhIjoiQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRGxtVWYvNVpsSC8rV05QLy9sbVVmLzVabEgvK1dOUC8vbG1VZi81WTAvLzlpQU12L1lnREwvMklBeS85aUFNdi9ZZ0RMLzJJQXkvOWlBTXYvWWdETC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBNVkwLy8rV1pSLy9salQvLzVabEgvK1daUi8vY2t6ei81WmxILytpZFRQL1lnREwvMklBeS82cUpYditxaVY3L3FvbGUvNnFKWHYvWWdETC8ySUF5L3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFPV1pSLy9ja3p6LzZKMU0vK1daUi8vbGpULy8zSk04LytXTlAvL2xtVWYvMklBeS82cUpYditjZTFEL25IdFEvNXg3VVArY2UxRC9xb2xlLzlpQU12OEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQURsalQvLzNKTTgvK2lkVFAvbG1VZi81WmxILytXWlIvL2xqVC8vM0pNOC85aUFNditxaVY3L25IdFEvNXg3VVArY2UxRC9uSHRRLzZxSlh2L1lnREwvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTVZMC8vK1dOUC8vb25Vei81WTAvLytXWlIvL2xqVC8vNkoxTS85eVRQUC9meHFQL3FvbGUvNXg3VVArY2UxRC9uSHRRLzV4N1VQK3FpVjcvMklBeS93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT1daUi8vbGpULy81WmxILytXTlAvL2NrenovNVpsSC8raWRUUC9vblV6LzM4YWovNnFKWHYrY2UxRC9uSHRRLzV4N1VQK2NlMUQvcW9sZS85aUFNdjhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEY2t6ei81WTAvLytXTlAvL2xtVWYvNVpsSC8rV1pSLy9salQvLzZKMU0vOS9Hby8rcWlWNy9xb2xlLzZxSlh2K3FpVjcvcW9sZS82cUpYdi9ZZ0RML0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE2SjFNLytXWlIvL2xqVC8vNkoxTS8raWRUUC9salQvLzZKMU0vOXlUUFAvZnhxUC8zOGFqLzkvR28vL2Z4cVAvMzhhai85L0dvLy9meHFQLzM4YWovd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRGxtVWYvNVkwLy8raWRUUC9sbVVmLzZKMU0vK2lkVFAvb25Vei81WTAvLytXWlIvL2xqVC8vNVpsSC8rV05QLy9salQvLzVabEgvK1dOUC8vbG1VZi81WmxILytXTlAvL2xtVWYvNVkwLy8rV1pSLy9salQvLzZKMU0vK1daUi8vbGpULy81WmxILytXTlAvL2xtVWYvNVkwLy8rV1pSLy9vblV6LzVZMC8vd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBNVkwLy8rV1pSLy9sbVVmLzVZMC8vK1daUi8vbGpULy81WTAvLytXWlIvL2xqVC8vNVpsSC8rV05QLy9sbVVmLzNKTTgvK1daUi8vbG1VZi81WTAvLytXWlIvL29uVXovNkoxTS8raWRUUC9salQvLzVabEgvK1dOUC8vbG1VZi82SjFNLytpZFRQL2xtVWYvNVkwLy8raWRUUC9vblV6LzVZMC8vK1daUi84QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFPaWRUUC9vblV6LzVZMC8vK1daUi8vbGpULy81WmxILytpZFRQL2xtVWYvNVpsSC8rV05QLy9sbVVmLzNKTTgvK3ZUcy8vcjA3UC81WmxILytXTlAvL29uVXovNVkwLy8rV05QLy9salQvLzZKMU0vK1daUi8vbGpULy82SjFNLytpZFRQL29uVXovNVkwLy8raWRUUC9sbVVmLzZKMU0vK1dOUC8vbG1VZi9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQURsbVVmLzNKTTgvK1daUi8vbG1VZi82SjFNLzl5VFBQL2NrenovNVpsSC85eVRQUC9ja3p6LzNKTTgvK3ZUcy8veTJyci81TXVwLytUTHFmL2xtVWYvNVpsSC8rV1pSLy9ja3p6LzVabEgvK1dOUC8vb25Vei82SjFNLytXWlIvL2xqVC8vNkoxTS8rV05QLy9vblV6LzVabEgvK1dOUC8vbG1VZi81WTAvL3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTNKTTgvK1daUi8vbG1VZi81WmxILzl5VFBQL3IwN1AvNjlPei85eVRQUC9reTZuLysvdjcveU5pSlAveTJyci84dDNDL3lOaUpQLzcrL3YvNU11cC85eVRQUC9salQvLzVabEgvK1daUi8vbG1VZi81WTAvLytXWlIvL2xqVC8vNVpsSC8rV05QLy9sbVVmLzVabEgvK2lkVFAvbG1VZi81WmxILytpZFRQOEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBTnlUUFAvbGpULy82SjFNLzl5VFBQL3IwN1AvOHQzQy8vTGF1di95MnJyLzd0YTIvKy9adS8veTJyci84dDNDLy9MYXV2L3kyNzMvN3RlNS8vTGF1di9yMDdQLzNKTTgvK1daUi8vbGpULy81WmxILytXWlIvL29uVXovNVkwLy8rV05QLy9vblV6LzVabEgvK1dOUC8vbGpULy82SjFNLytXWlIvL2xtVWYvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEbGpULy81WmxILytpZFRQL2xtVWYvNjlPei8vTGF1di95M2NMLzh0M0MvL0xhdXYveTNjTC84dHE2LysrN3NmL3Z1N0gvOHRxNi8vTGF1di9yMDdQLzh0M0MvK3ZUcy8vY2t6ei81WTAvLytXWlIvL2xqVC8vNVpsSC8raWRUUC9salQvLzVZMC8vK1dOUC8vbG1VZi82SjFNLytXWlIvL2xtVWYvNVkwLy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE1WmxILytXTlAvL2xtVWYvNjlPei8rdlRzLy95M2NMLzh0cTYvL0xhdXYveTJyci84dHE2Ly9MZHd2L3kycnIvOHRxNi8vTGR3di95M2NMLzh0cTYvK3ZUcy8vY2t6ei81WTAvLytXWlIvL2xtVWYvNVkwLy8rV1pSLy9salQvLzVabEgvK1dOUC8vb25Vei81WmxILytXWlIvL2NrenovNVkwLy8raWRUUDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUJrUVN6L1pFRXMvMlJCTFA5a1FTei9LQ2dvL3lnb0tQOG9LQ2ovS0Nnby93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBZXJWMy80YUhZZi9ZZ0RMLzJJQXkvOWlBTXYvWWdETC82SjFNLytXWlIvOW9SVEQvYUVVdy8yaEZNUDlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3L3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFlcTkzLzNxdmQvOTZyM2YvMkxxVS8rdlRzLy9ZdXBUL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVpFRXMvMlJCTFA5a1FTei9aRUVzL3lnb0tQOG9LQ2ovS0Nnby95Z29LUDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFIcTFkLytHaDJIL2hvZGgvNGFIWWYrR2gySC8ySUF5LytXWlIvL29uVXovYUVVdy8yaEZNUDlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3LzJoRk1QOEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUhxdmQvOTZ0WGYvZXE5My85aTZsUC9yMDdQLzJMcVUvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBR1JCTFA5a1FTei9aRUVzLzJSQkxQOG9LQ2ovS0Nnby95Z29LUDhvS0NqL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUI2dFhmL2hvZGgvNGFIWWYvZnhxUC8zOGFqLzRhSFlmL2xtVWYvNkoxTS8yaEZNUDlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3LzJoRk1QOW9SVEQvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQjZyM2YvZXJWMy8zcXZkLy9yMDdQLzJMcVUvK3ZUcy84QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCa1FTei9aRUVzLzJSQkxQOWtRU3ovS0Nnby95Z29LUDhvS0NqL0tDZ28vd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQWVyVjMvNGFIWWYvcjA3UC84dHE2Ly9MYXV2L2xtVWYvNVpsSC8rV05QLzlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3LzJoRk1QOW9SVEQvYUVVdy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBZXE5My8zcXZkLzk2cjNmLzY5T3ovOWk2bFAvcjA3UC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUI2cjNmL2VyVjMvM3ExZC85NnIzZi9hRVV3LzNsVlBmK0FXa0QvYlVvei8yaEZNUDlrUVN6L2FFVXcvMlJCTFArTXZvci9qTDZLLzMyeWV2OTlzbnIvZXJWMy8zcTFkLzk2dFhmL2VxOTMvNHkraXYrR2gySC82OU96Ly9MYXV2L3kycnIvNkoxTS8raWRUUC9salQvLzZKMU0vK2lkVFAvbG1VZi82SjFNLytpZFRQL29uVXovNVpsSC8rV05QLy9sbVVmLzVabEgvNEcxZi8rTHVvai9lcTkzLzNxMWQvOTZyM2YvZXE5My80eStpditMdW9qL2ZiSjYvM3F2ZC85NnRYZi9lclYzLzNxdmQvK0x1b2ovakw2Sy80dTZpUDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVpFRXMvM3F2ZC85NnIzZi9hRVV3LzNKT052OTVWVDMvZVZVOS8yaEZNUDlrUVN6L2FFVXcvMmhGTVA5a1FTei9iMHcxLzRCYVFQK0FXa0QvY2s0Mi8zcTFkLzk2dFhmL2VxOTMvM3F2ZC8rTXZvci9pb3RtLyt2VHMvL3kycnIvOHRxNi8vTGF1di9sbVVmLzZKMU0vK1daUi8vbG1VZi9lcTkzLzNxdmQvL2xtVWYvNVkwLy8rV05QLy9sbVVmL2diVi8vNEcxZi8rTHVvai9pN3FJLzNxdmQvOTZyM2YvZXE5My8zcTFkLytMdW9qL2ZiSjYvNHkraXY5NnRYZi9lclYzLzNxdmQvOTZyM2YvaTdxSS80dTZpUCtNdm9yL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBR1JCTFA5b1JURC9aRUVzLzJoRk1QOXZURFgvZ0ZwQS8yaEZNUDl5VGpiL1pFRXMvMmhGTVA5a1FTei9hRVV3LzI5TU5mK0FXa0QvZVZVOS8zSk9Odjk2cjNmL2VyVjMvM3F2ZC85NnIzZi9qTDZLLzMyeWV2K01qV2ovNjlPei8rdlRzLy9salQvLzVabEgvK2lkVFA5NnIzZi9lcTkzLzNxdmQvOTZ0WGYvZ2JWLy80RzFmLytCdFgvL2diVi8vNHkraXYrTHVvai9pN3FJLzR1NmlQOTZyM2YvZXJWMy8zcTFkLzk2dFhmL2k3cUkvNHkraXYrTHVvai9lcTkzLzNxMWQvOTZ0WGYvZXE5My80eStpditMdW9qL2pMNksvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCa1FTei9aRUVzLzJSQkxQOW9SVEQvYUVVdy8yaEZNUDk1VlQzL2NrNDIvMlJCTFA5b1JURC9aRUVzLzJoRk1QOXZURFgvZ0ZwQS8zbFZQZjl5VGpiL2VxOTMvM3ExZC85NnIzZi9lcTkzLzNldmRmK012b3Ivakw2Sy80eU5hUCtNaldqLzVabEgvK2lkVFA5OXNuci9lclYzLzNxMWQvOTZyM2YvZXJWMy80eStpditMdW9qL2pMNksvNHU2aVArTHVvai9pN3FJLzMyeWV2K0x1b2ovZ0lKYS80ZUpZditIaVdML2dJSmEvNGFIWWYrUGtHdi9ob2RoLzRDQ1d2K0hpV0wvaDRsaS80Q0NXditHaDJIL2o1QnIvNGFIWWY4QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFaRUVzLzJSQkxQOWtRU3ovWkVFcy8yOU1OZitHWGtiL2hsNUcvMjlNTmY5a1FTei9aRUVzLzJSQkxQOWtRU3ovYUVVdy8yaEZNUDlvUlREL2FFVXcvM3F2ZC85NnRYZi9lclYzLzNxMWQvOTNyM1gvakw2Sy80eStpdjk5c25yL2pMNksvK2lkVFA5OXRIci9pN3FJLzNxdmQvOTZyM2YvZXE5My8zcTFkLytNdm9yL2k3cUkvNHkraXYrTHVvai9pN3FJLzR5K2l2K012b3Ivakw2Sy8rVEpxUC9reWFqLzVNbW8vK1RKcVAvcjA3UC82OU96Lyt2VHMvL2t5YWovNU1tby8rVEpxUC9reWFqLzY5T3ovK3ZUcy8vcjA3UC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQURzN08vODdPenYvT3pzNy8yUkJMUDlvUlREL2VGUTgvM2hVUFA5b1JURC9aRUVzL3pzN08vODdPenYvT3pzNy8wWkdSdjlHUmtiL1JrWkcvMFpHUnY5NnIzZi9lclYzLzNxdmQvOTZ0WGYvZmJKNi80eStpditMdW9qL2pMNksvNHU2aVArTXZvci9pN3FJLzR1NmlQOTZyM2YvZXE5My8zcXZkLzk2cjNmL2k3cUkvMzJ5ZXYrTXZvci9pN3FJLzR1NmlQK012b3IvaTdxSS80eStpdi9reWFqLzVNbW8vK3ZUcy8vcjA3UC84dHE2Ly9MYXV2L3IwN1AvNjlPei8rdlRzLy9reWFqLzY5T3ovL0xhdXYvcjA3UC84dHE2L3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQkpTVW4vU1VsSi8wbEpTZjg3T3p2L1dscGEvMTFkWGY5ZFhWMy9XbHBhL3pzN08vOUpTVW4vU1VsSi8wbEpTZjlOVFUzL1YxZFgvMWRYVi85TlRVMy9lcTkzLzNxMWQvOTZyM2YvZXJWMy80eStpditNdm9yL2ZiSjYvNHkraXYrTHVvai9qTDZLLzR1NmlQK012b3IvZXE5My8zcTFkLzk2cjNmL2VxOTMvNHU2aVArTXZvci9qTDZLLzR1NmlQK012b3IvZmJKNi80eStpditNdm9yLzVNbW8vK3ZUcy8vcjA3UC82OU96Ly9MYXV2L3kycnIvNmRDdi8rdlRzLy9zMUxqLzVNdXEvK3pVdVAveTJyci84dHE2Ly9MZHd2OEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBU1VsSi8wbEpTZjlKU1VuL1NVbEovMkZoWWY5cmEydi9hMnRyLzJGaFlmOUpTVW4vU1VsSi8wbEpTZjlKU1VuL1RVMU4vMWRYVi85WFYxZi9UVTFOLzNxMWQvOTZ0WGYvZXJWMy8zcTFkLytNdm9yL2pMNksvM2V2ZGYrTXZvci9mYko2LzR5K2l2K012b3Ivakw2Sy8zcXZkLzk2dFhmL2VyVjMvM3ExZC8rTXZvci9qTDZLLzR5K2l2OTlzbnIvakw2Sy8zMnllditNdm9yL2pMNksvK3pVdVAvcjA3UC83TlM0Lyt2VHMvL3AwYlAvOHRxNi8vTGF1di92MmIzLzdOUzQvK1hMcmYvdjJyLy84dHE2Ly9MYXV2L3AwYlAvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFFbEpTZjlKU1VuL096czcvMGxKU2Y5aFlXSC9hMnRyLzJ0cmEvOWhZV0gvU1VsSi96czdPLzlKU1VuL1NVbEovMDFOVGY5WFYxZi9WMWRYLzAxTlRmOFlPQmIvR2o4Wi94ZzRGdjhhUHhuL1Q0Qk0vNHkraXY5M3IzWC9qTDZLLzNldmRmK012b3Ivakw2Sy8wK0FUUDhhUHhuL0dqOFoveGc0RnY4YVB4bi9UNEJNLzR5K2l2K012b3IvZDdCMC80eStpdjkzcjNYL2pMNksvMCtBVFAvczFMai83TlM0Lyt6VXVQL3MxTGovNmRHei8vTGR3di95M2NMLzdOUzQvKy9hdi8vczFMai83TlM0Ly9MZHd2L3kzY0wvOHQzQy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUJOVFUzL1RVMU4vMUpTVXY4N096di9XbHBhLzJOalkvOWpZMlAvV2xwYS96czdPLzlTVWxML1RVMU4vMDFOVGY5S1Nrci9VRkJRLzFCUVVQOUtTa3IvZXJWMy8zcXZkLzk2dFhmL2VxOTMveGc0RnY4WU9CYi9HRGdXL3hvL0dmOGFQeG4vR0RnVy94ZzRGdjhhUHhuL2VxOTMvM3F2ZC85NnRYZi9lclYzL3hvL0dmOFlPQmIvR0RnVy94by9HZjhhUHhuL0dEZ1cveG8vR2Y4YVB4bi83TlM0Lyt6VXVQL3Yyci8vNzlxLy8vTGR3di95M2NMLzh0L0kvK3pVdVAvdjJyLy83TlM0Lyt6VXVQL3kzOGovOHQzQy8rclV1UDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVRVMU4vMDFOVGY5U1VsTC9YRnhjLzJGaFlmOXJhMnYvYTJ0ci8yRmhZZjljWEZ6L1VsSlMvMDFOVGY5TlRVMy9Ta3BLLzFCUVVQOVFVRkQvU2twSy8zcTFkLzk2cjNmL2VyVjMvM3F2ZC8rTHVvai9qTDZLLzR1NmlQK012b3IvZmJKNi80dTZpUCtMdW9qL2pMNksvM3F2ZC85NnIzZi9lclYzLzNxdmQvK0x1b2ovakw2Sy80eStpdjk5c25yL2pMNksvNHU2aVArTHVvai9qTDZLLysvYXYvL3Yyci8vN05TNC8rL2F2Ly95MzhqLzh0L0kvL0xkd3YvdjJyLy83OXEvLysvYXYvL3MxTGovOHQvSS8vTGR3di95M2NML0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRDgvUC84L1B6Ly9QejgvLzF4Y1hQOWpZMlAvY0hCdy8zQndjUDlqWTJQL1hGeGMvejgvUC84L1B6Ly9QejgvLzBoSVNQOU1URXovVEV4TS8waElTUDk2cjNmL2VyVjMvM3ExZC85NnIzZi9pN3FJLzJoRk1QOTFVRGovZFZBNC8zVlFPUDkxVURqL2FFVXcvNHU2aVA5NnRYZi9lcTkzLzNxMWQvOTZyM2YvaTdxSS80eStpditNdm9yL2pMNksvNHkraXYrTXZvci9qTDZLLzR1NmlQL3MxTGovNzltOS8relV1UC92MnIvLzh0L0kvL0xkd3YveTNjTC83TlM0Lyt6VXVQL3Yyci8vN05TNC8vTGZ5UC95M2NMLzh0M0Mvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCa1FTei9aRUVzLzJSQkxQOWtRU3ovS0Nnby95Z29LUDhvS0NqL0tDZ28vd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTZKMU0vM3ExZC85NnIzZi8yTHFVLyt2VHMvL1l1cFQvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFaRUVzLzJSQkxQOWtRU3ovWkVFcy95Z29LUDhvS0NqL0tDZ28veWdvS1A4QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT1daUi8vb25Vei9lcTkzLzlpNmxQL3IwN1AvMkxxVS93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUdSQkxQOWtRU3ovWkVFcy8yUkJMUDhvS0NqL0tDZ28veWdvS1A4b0tDai9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEbG1VZi81WTAvLzNxdmQvL3IwN1AvMkxxVS8rdlRzLzhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQmtRU3ovWkVFcy8yUkJMUDlrUVN6L0tDZ28veWdvS1A4b0tDai9LQ2dvL3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE1WTAvLzNxMWQvOTZyM2YvNjlPei85aTZsUC9yMDdQL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCb1JURC9aRUVzLzJoRk1QOWtRU3ovYlVvei80QmFRUDk1VlQzL2FFVXcvMmhGTVA5a1FTei9hRVV3LzJSQkxQOXZURFgvZmJKNi80eStpditNdm9yL2VxOTMvM3ExZC85NnIzZi81WmxILytXTlAvK0x1b2ovaTdxSS8zcXZkLzk2cjNmL2VxOTMvM3F2ZC8rTHVvai9qTDZLLytXTlAvOEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFaRUVzLzJoRk1QOWtRU3ovYUVVdy8yaEZNUDk1VlQzL2VWVTkvM0pPTnY5a1FTei9hRVV3LzJoRk1QOWtRU3ovYjB3MS80QmFRUCtBV2tEL2NrNDIvM3F2ZC85NnIzZi9lcTkzLytpZFRQL2xtVWYvaTdxSS80dTZpUDk2cjNmL2VyVjMvM3F2ZC85NnIzZi9pN3FJLzR1NmlQK012b3IvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUdSQkxQOW9SVEQvWkVFcy8yaEZNUDl5VGpiL2FFVXcvNEJhUVA5dlREWC9aRUVzLzJoRk1QOWtRU3ovYUVVdy8yOU1OZitBV2tEL2VWVTkvM0pPTnY5NnIzZi9lclYzLzNxMWQvOTZ0WGYvaTdxSS80eStpdjk5c25yL2VxOTMvM3ExZC85NnRYZi9lcTkzLzR5K2l2K0x1b2ovakw2Sy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQmtRU3ovWkVFcy8yUkJMUDlvUlREL2NrNDIvM2xWUGY5b1JURC9hRVV3LzJSQkxQOW9SVEQvWkVFcy8yaEZNUDl2VERYL2dGcEEvM2xWUGY5eVRqYi9nSUphLzRlSll2K0hpV0wvZ0lKYS80YUhZZitQa0d2L2hvZGgvNENDV3YrSGlXTC9oNGxpLzRDQ1d2K0doMkgvajVCci80YUhZZjhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBWkVFcy8yUkJMUDlrUVN6L1pFRXMvMjlNTmYrR1hrYi9obDVHLzI5TU5mOWtRU3ovWkVFcy8yUkJMUDlrUVN6L2FFVXcvMmhGTVA5b1JURC9hRVV3LytUSnFQL2t5YWovNU1tby8rVEpxUC9yMDdQLzY5T3ovK3ZUcy8va3lhai81TW1vLytUSnFQL2t5YWovNjlPei8rdlRzLy9yMDdQL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEczdPLzg3T3p2L096czcvMlJCTFA5b1JURC9lRlE4LzNoVVBQOW9SVEQvWkVFcy96czdPLzg3T3p2L096czcvMFpHUnY5R1JrYi9Sa1pHLzBaR1J2L2t5YWovNU1tby8rdlRzLy9yMDdQLzh0cTYvL0xhdXYvcjA3UC82OU96Lyt2VHMvL2t5YWovNjlPei8vTGF1di9yMDdQLzh0cTYvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUJKU1VuL1NVbEovMGxKU2Y4N096di9XbHBhLzExZFhmOWRYVjMvV2xwYS96czdPLzlKU1VuL1NVbEovMGxKU2Y5TlRVMy9WMWRYLzFkWFYvOU5UVTMvNU1tby8rdlRzLy9yMDdQLzY5T3ovL0xhdXYveTJyci84dHE2Lyt2VHMvL3MxTGovNjlPei8relV1UC95MnJyLzh0cTYvL0xkd3Y4QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVNVbEovMGxKU2Y5SlNVbi9TVWxKLzJGaFlmOXJhMnYvYTJ0ci8yRmhZZjlKU1VuL1NVbEovMGxKU2Y5SlNVbi9UVTFOLzFkWFYvOVhWMWYvVFUxTi8relV1UC9yMDdQLzdOUzQvKy9admYvcDBiUC84dHE2Ly9MYXV2L3IwN1AvN05TNC8rWExyZi9zMUxqLzh0cTYvL0xhdXYveTNjTC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRWxKU2Y5SlNVbi9PenM3LzBsSlNmOWhZV0gvYTJ0ci8ydHJhLzloWVdIL1NVbEovenM3Ty85SlNVbi9TVWxKLzAxTlRmOVhWMWYvVjFkWC8wMU5UZi9zMUxqLzdOUzQvK3pVdVAvczFMai82ZEd6Ly9MZHd2L3kzY0wvN05TNC8relV1UC9zMUxqLzdOUzQvK25Scy8veTNjTC84dDNDL3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCTlRVMy9UVTFOLzFKU1V2ODdPenYvV2xwYS8yTmpZLzlqWTJQL1dscGEvenM3Ty85U1VsTC9UVTFOLzAxTlRmOUtTa3IvVUZCUS8xQlFVUDlLU2tyLzdOUzQvK3pVdVAvdjJyLy83TlM0Ly9MZHd2L3kzY0wvNmRHei8relV1UC9zMUxqLzc5cS8vK3pVdVAveTNjTC84dDNDLy9MZHd2OEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFUVTFOLzAxTlRmOVNVbEwvWEZ4Yy8yRmhZZjlyYTJ2L2EydHIvMkZoWWY5Y1hGei9VbEpTLzAxTlRmOU5UVTMvU2twSy8xQlFVUDlRVUZEL1NrcEsvKy9hdi8vczFMai83OXEvLyt6VXVQL3kzY0wvOHQvSS8vTGR3di92MnIvLzdOUzQvK3pVdVAvdjJyLy84dDNDLy9MZnlQL3kzOGovQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUQ4L1AvOC9Qei8vUHo4Ly8xeGNYUDlqWTJQL2NIQncvM0J3Y1A5alkyUC9YRnhjL3o4L1AvOC9Qei8vUHo4Ly8waElTUDlNVEV6L1RFeE0vMGhJU1AvdjJyLy82OU96Lyt6VXVQL3MxTGovOHQvSS8vTGR3di95M2NMLzdOUzQvKy9hdi8vczFMai83TlM0Ly9MZHd2L3kzOGovOHQvSS93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBPT0iLCJTa2luSWQiOiJTdGFuZGFyZF9BbGV4In0K.gN2HJV9_WW1hvVj-gGKGJsCGEafIiGnTFgKRUKF2CqhiQk4dgB1dHFnZOglDN4VtW397jIPgs92ppMkyfZf8-09XQ87_o_eC1nvuscmBXt6Bn2UZQP_VYFqh_eCAXvCP" +} + + +var clientData = example.clientData; +var chain1 = example.chain.chain[0]; +var chain2 = example.chain.chain[1]; +var secret = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; + +var decode1 = jwt.decode(chain1, secret, 'ES384'); +var nextKey1 = decode1.identityPublicKey; + +var decode2 = jwt.decode(chain2, nextKey1, 'ES384'); +var nextKey2 = decode2.identityPublicKey; + +var clientDecode = jwt.decode(clientData, nextKey1, 'ES384'); +console.log(clientDecode); diff --git a/package.json b/package.json index 6847f96..1d4c196 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ ], "license": "MIT", "dependencies": { + "jwt-simple": "^0.5.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.0", "raknet": "^1.7.3", From 5b9ec7a1b6b3a4b0c4eb7d417689e5416f0fdf37 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 17:47:33 -0400 Subject: [PATCH 002/106] merge protocol with the mc-data to make fields in-sync --- data/protocol.json | 98 +++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 9d4a087..1454610 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -27,7 +27,7 @@ ] }, { - "name": "result_count", + "name": "resultCount", "type": "i32" }, { @@ -79,7 +79,7 @@ ] }, { - "name": "result_count", + "name": "resultCount", "type": "i32" }, { @@ -132,34 +132,38 @@ "countType": "i8", "type": [ "container", - { - "name": "cost", - "type": "i32" - }, - { - "name": "enchantments", - "type": [ - "array", - { - "countType": "i8", - "type": [ - "container", - { - "name": "id", - "type": "i32" - }, - { - "name": "level", - "id": "i32" - } - ] - } - ] - }, - { - "name": "name", - "type": "string" - } + [ + { + "name": "cost", + "type": "i32" + }, + { + "name": "enchantments", + "type": [ + "array", + { + "countType": "i8", + "type": [ + "container", + [ + { + "name": "id", + "type": "i32" + }, + { + "name": "level", + "type": "i32" + } + ] + ] + } + ] + }, + { + "name": "name", + "type": "string" + } + ] ] } ], @@ -175,15 +179,15 @@ "4": "lstring", "5": ["container",[ { - "name":"block_id", + "name":"blockId", "type":"li16" }, { - "name":"item_count", + "name":"itemCount", "type":"li8" }, { - "name":"item_damage", + "name":"itemDamage", "type":"li16" } ]], @@ -267,7 +271,7 @@ "container", [ { - "name": "block_id", + "name": "blockId", "type": "i16" }, { @@ -275,7 +279,7 @@ "type": [ "switch", { - "compareTo": "block_id", + "compareTo": "blockId", "fields": { "0": "void" }, @@ -283,15 +287,15 @@ "container", [ { - "name": "item_count", + "name": "itemCount", "type": "i8" }, { - "name": "item_damage", + "name": "itemDamage", "type": "i16" }, { - "name": "nbt_data", + "name": "nbtData", "type": ["buffer",{"countType":"li16"}] } ] @@ -332,7 +336,7 @@ "blockrecords": [ "array", { - "countType":"i32", + "countType":"i16", "type": [ "container", [ @@ -348,17 +352,13 @@ "name": "y", "type": "i8" }, - { - "name": "block_id", - "type": "i8" - }, { "anon": true, "type": [ "bitfield", [ { - "name": "block_data", + "name": "blockData", "size": 4, "signed": false }, @@ -405,11 +405,11 @@ "container", [ { - "name": "min_value", + "name": "minValue", "type": "f32" }, { - "name": "max_value", + "name": "maxValue", "type": "f32" }, { @@ -436,15 +436,15 @@ "type": "i64" }, { - "name": "mot_x", + "name": "motX", "type": "f32" }, { - "name": "mot_y", + "name": "motY", "type": "f32" }, { - "name": "mot_z", + "name": "motZ", "type": "f32" } ] From 712d44bcad3e3f9d4cd38a01f82e224102eb3c3c Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 17:51:49 -0400 Subject: [PATCH 003/106] oops, fix one protocol error --- data/protocol.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/protocol.json b/data/protocol.json index 1454610..a6fcdb4 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -336,7 +336,7 @@ "blockrecords": [ "array", { - "countType":"i16", + "countType":"i32", "type": [ "container", [ From f07c69176ebde73a6ba5b1750903f38ab8b2925e Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 18:00:29 -0400 Subject: [PATCH 004/106] remove a bunch of errors in the protocol and keep the standard --- data/protocol.json | 178 +++++++++++++++++++++++---------------------- 1 file changed, 91 insertions(+), 87 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index a6fcdb4..237d217 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -352,6 +352,10 @@ "name": "y", "type": "i8" }, + { + "name": "blockId", + "type": "i8" + }, { "anon": true, "type": [ @@ -513,7 +517,7 @@ "type": "f32" }, { - "name": "head_yaw", + "name": "headYaw", "type": "f32" }, { @@ -722,11 +726,11 @@ "container", [ { - "name": "public_key", + "name": "publicKey", "type": "string" }, { - "name": "server_token", + "name": "serverToken", "type": "string" } ] @@ -752,7 +756,7 @@ "type": "long" }, { - "name": "body_length", + "name": "bodyLength", "type": "i32" }, { @@ -760,7 +764,7 @@ "type": ["pstring", {"countType": "li32"}] }, { - "name": "client_data", + "name": "clientData", "type": ["pstring", {"countType": "li32"}] } ] @@ -883,19 +887,19 @@ "type": "i8" }, { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "spawn_x", + "name": "spawnX", "type": "i32" }, { - "name": "spawn_y", + "name": "spawnY", "type": "i32" }, { - "name": "spawn_z", + "name": "spawnZ", "type": "i32" }, { @@ -911,15 +915,15 @@ "type": "f32" }, { - "name": "is_loaded_in_creative", + "name": "isLoadedInCreative", "type": "bool" }, { - "name": "day_cycle_stop_time", + "name": "dayCycleStopTime", "type": "i8" }, { - "name": "edu_mode", + "name": "eduMode", "type": "bool" }, { @@ -940,7 +944,7 @@ "type": "string" }, { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -956,15 +960,15 @@ "type": "f32" }, { - "name": "speed_x", + "name": "speedX", "type": "f32" }, { - "name": "speed_y", + "name": "speedY", "type": "f32" }, { - "name": "speed_z", + "name": "speedZ", "type": "f32" }, { @@ -972,7 +976,7 @@ "type": "f32" }, { - "name": "head_yaw", + "name": "headYaw", "type": "f32" }, { @@ -993,11 +997,11 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "client_uuid", + "name": "clientUuid", "type": "uuid" } ] @@ -1006,11 +1010,11 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "entity_type", + "name": "entityType", "type": "i32" }, { @@ -1026,15 +1030,15 @@ "type": "f32" }, { - "name": "speed_x", + "name": "speedX", "type": "f32" }, { - "name": "speed_y", + "name": "speedY", "type": "f32" }, { - "name": "speed_z", + "name": "speedZ", "type": "f32" }, { @@ -1059,7 +1063,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" } ] @@ -1068,7 +1072,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1088,15 +1092,15 @@ "type": "f32" }, { - "name": "speed_x", + "name": "speedX", "type": "f32" }, { - "name": "speed_y", + "name": "speedY", "type": "f32" }, { - "name": "speed_z", + "name": "speedZ", "type": "f32" } ] @@ -1109,7 +1113,7 @@ "type": "i64" }, { - "name": "entity_id", + "name": "entityId", "type": "i64" } ] @@ -1127,7 +1131,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1147,7 +1151,7 @@ "type": "f32" }, { - "name": "head_yaw", + "name": "headYaw", "type": "f32" }, { @@ -1159,7 +1163,7 @@ "type": "i8" }, { - "name": "on_ground", + "name": "onGround", "type": "i8" } ] @@ -1168,7 +1172,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1198,7 +1202,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1252,7 +1256,7 @@ "container", [ { - "name": "event_id", + "name": "eventId", "type": "i16" }, { @@ -1289,11 +1293,11 @@ "type": "i32" }, { - "name": "case_1", + "name": "case1", "type": "i32" }, { - "name": "case_2", + "name": "case2", "type": "i32" } ] @@ -1302,11 +1306,11 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "event_id", + "name": "eventId", "type": "i8" } ] @@ -1315,15 +1319,15 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "event_id", + "name": "eventId", "type": "i8" }, { - "name": "effect_id", + "name": "effectId", "type": "i8" }, { @@ -1344,7 +1348,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1357,7 +1361,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1369,7 +1373,7 @@ "type": "i8" }, { - "name": "selected_slot", + "name": "selectedSlot", "type": "i8" } ] @@ -1378,7 +1382,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { @@ -1403,11 +1407,11 @@ "container", [ { - "name": "action_id", + "name": "actionId", "type": "i8" }, { - "name": "target_entity_id", + "name": "targetEntityId", "type": "i64" } ] @@ -1445,11 +1449,11 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "action_id", + "name": "actionId", "type": "i32" }, { @@ -1505,15 +1509,15 @@ "container", [ { - "name": "rider_id", + "name": "riderId", "type": "i64" }, { - "name": "ridden_id", + "name": "riddenId", "type": "i64" }, { - "name": "link_type", + "name": "linkType", "type": "i8" } ] @@ -1548,11 +1552,11 @@ "container", [ { - "name": "action_id", + "name": "actionId", "type": "i8" }, { - "name": "entity_id", + "name": "entityId", "type": "i64" } ] @@ -1591,7 +1595,7 @@ "container", [ { - "name": "window_id", + "name": "windowId", "type": "i8" }, { @@ -1599,7 +1603,7 @@ "type": "i8" }, { - "name": "slot_count", + "name": "slotCount", "type": "i16" }, { @@ -1620,7 +1624,7 @@ "container", [ { - "name": "window_id", + "name": "windowId", "type": "i8" } ] @@ -1629,7 +1633,7 @@ "container", [ { - "name": "window_id", + "name": "windowId", "type": "i8" }, { @@ -1650,7 +1654,7 @@ "container", [ { - "name": "window_id", + "name": "windowId", "type": "i8" }, { @@ -1667,19 +1671,19 @@ "container", [ { - "name": "window_id", + "name": "windowId", "type": "i8" }, { - "name": "slot_data", + "name": "slotData", "type": "itemstacks" }, { - "name": "hotbar_data", + "name": "hotbarData", "type": [ "switch", { - "compareTo": "window_id", + "compareTo": "windowId", "fields": { "0": [ "array", @@ -1726,11 +1730,11 @@ { "compareTo": "entryType", "fields": { - "0": "shapeless_recipe", - "1": "shaped_recipe", - "2": "furnace_recipe", - "3": "furnace_recipe_data", - "4": "enchant_list" + "0": "shapelessRecipe", + "1": "shapedRecipe", + "2": "furnaceRecipe", + "3": "furnaceRecipeData", + "4": "enchantList" }, "default":"void" } @@ -1751,15 +1755,15 @@ "container", [ { - "name": "window_id", + "name": "windowId", "type": "i8" }, { - "name": "recipe_type", + "name": "recipeType", "type": "i32" }, { - "name": "recipe_id", + "name": "recipeId", "type": "uuid" }, { @@ -1780,11 +1784,11 @@ "type": "i32" }, { - "name": "user_permission", + "name": "userPermission", "type": "i32" }, { - "name": "global_permission", + "name": "globalPermission", "type": "i32" } ] @@ -1814,11 +1818,11 @@ "container", [ { - "name": "motion_x", + "name": "motionX", "type": "f32" }, { - "name": "motion_z", + "name": "motionZ", "type": "f32" }, { @@ -1831,11 +1835,11 @@ "container", [ { - "name": "chunk_x", + "name": "chunkX", "type": "i32" }, { - "name": "chunk_z", + "name": "chunkZ", "type": "i32" }, { @@ -1843,7 +1847,7 @@ "type": "i8" }, { - "name": "chunk_data", + "name": "chunkData", "type":["buffer",{"countType":"i32"}] } ] @@ -1879,15 +1883,15 @@ "container", [ { - "name": "client_uuid", + "name": "clientUuid", "type": "uuid" }, { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { - "name": "display_name", + "name": "displayName", "type": "string" }, { @@ -1900,7 +1904,7 @@ "container", [ { - "name": "client_uuid", + "name": "clientUuid", "type": "uuid" } ] @@ -1917,7 +1921,7 @@ "container", [ { - "name": "chunk_radius", + "name": "chunkRadius", "type": "i32" } ] @@ -1926,7 +1930,7 @@ "container", [ { - "name": "chunk_radius", + "name": "chunkRadius", "type": "i32" } ] @@ -1944,7 +1948,7 @@ "container", [ { - "name": "entity_id", + "name": "entityId", "type": "i64" }, { From 8c30673c6c8d9f810e322b4849b50d780779a9bd Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 18:17:54 -0400 Subject: [PATCH 005/106] update all examples --- examples/client.js | 2 +- examples/server.js | 28 ++++++++++++++-------------- src/createClient.js | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/client.js b/examples/client.js index c13d3f8..d7ac65f 100644 --- a/examples/client.js +++ b/examples/client.js @@ -15,7 +15,7 @@ client.on('mcpe', packet => console.log(packet)); client.on('set_spawn_position', () => { client.writeMCPE('request_chunk_radius', { - chunk_radius:8 + chunkRadius:8 }); }); diff --git a/examples/server.js b/examples/server.js index 963098d..2cd0ae6 100644 --- a/examples/server.js +++ b/examples/server.js @@ -24,15 +24,15 @@ server.on('connection', function(client) { status:0 }); client.writeMCPE('move_player', { - entity_id: [0,0], + entityId: [0,0], x: 1, y: 64 + 1.62, z: 1, yaw: 0, - head_yaw: 0, + headYaw: 0, pitch: 0, mode: 0, - on_ground: 1 + onGround: 1 }); client.writeMCPE("start_game",{ @@ -40,17 +40,17 @@ server.on('connection', function(client) { dimension:0, generator:1, gamemode:1, - entity_id:[0,0], - spawn_x:1, - spawn_y:1, - spawn_z:1, + entityId:[0,0], + spawnX:1, + spawnY:1, + spawnZ:1, x:0, y:1+1.62, z:0, - unknown1:0, - unknown2:0, - unknown3:0, - unknown4:"" + isLoadedInCreative:false, + dayCycleStopTime:0, + eduMode:false, + unknown:"" }); client.writeMCPE('set_spawn_position', { @@ -72,14 +72,14 @@ server.on('connection', function(client) { client.on("request_chunk_radius",() => { client.writeMCPE('chunk_radius_update',{ - chunk_radius:1 + chunkRadius:1 }); for (let x = -1; x <=1; x++) { for (let z = -1; z <=1; z++) { client.writeBatch([{"name":"mcpe","params":{name:"full_chunk_data",params:{ - chunk_x: x, - chunk_z: z, + chunkX: x, + chunkZ: z, order: 1, chunk_data:fs.readFileSync(__dirname+"/chunk") }}}]); diff --git a/src/createClient.js b/src/createClient.js index cace13d..9833f33 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -35,10 +35,10 @@ function createClient(options) { username: client.username, protocol: 70, protocol2: 70, - client_id: [ -1, -697896776 ], - client_uuid: '86372ed8-d055-b23a-9171-5e3ac594d766', - server_address: client.host+":"+client.port, - client_secret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g,''),'hex'), + clientId: [ -1, -697896776 ], + clientUuid: '86372ed8-d055-b23a-9171-5e3ac594d766', + serverAddress: client.host+":"+client.port, + clientSecret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g,''),'hex'), skin: { skinType: 'Standard_Steve', From 97c8b7d0aa65b6de384ebfd1c14ce9c3f230863c Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 18:40:20 -0400 Subject: [PATCH 006/106] change packet prefix, remove duplicate packets --- data/protocol.json | 10 +-- examples/server.js | 151 +++++++++++++++++++++++---------------------- 2 files changed, 77 insertions(+), 84 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 237d217..28140ad 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -538,7 +538,7 @@ { "type": "u8", "mappings": { - "0x8e": "mcpe" + "0xfe": "mcpe" } } ] @@ -567,10 +567,6 @@ { "type": "u8", "mappings": { - "0x04": "id_detect_lost_connections", - "0x14": "id_no_free_incoming_connections", - "0x17": "id_connection_banned", - "0x1A": "id_ip_recently_connected", "0x03": "server_to_client_handshake", "0x04": "client_to_server_handshake", "0x01": "game_login", @@ -639,10 +635,6 @@ { "compareTo": "name", "fields": { - "id_detect_lost_connections": "packet_id_detect_lost_connections", - "id_no_free_incoming_connections": "packet_id_no_free_incoming_connections", - "id_connection_banned": "packet_id_connection_banned", - "id_ip_recently_connected": "packet_id_ip_recently_connected", "server_to_client_handshake": "packet_server_to_client_handshake", "client_to_server_handshake": "packet_client_to_server_handshake", "game_login": "packet_game_login", diff --git a/examples/server.js b/examples/server.js index 2cd0ae6..0190462 100644 --- a/examples/server.js +++ b/examples/server.js @@ -17,83 +17,84 @@ var server = pmp.createServer({ server.on('connection', function(client) { - client.on("mcpe",packet => console.log(packet)); + client.on("mcpe",packet => console.log(JSON.stringify(packet))); client.on("game_login",packet => { - client.writeMCPE("player_status",{ - status:0 - }); - client.writeMCPE('move_player', { - entityId: [0,0], - x: 1, - y: 64 + 1.62, - z: 1, - yaw: 0, - headYaw: 0, - pitch: 0, - mode: 0, - onGround: 1 - }); - - client.writeMCPE("start_game",{ - seed:-1, - dimension:0, - generator:1, - gamemode:1, - entityId:[0,0], - spawnX:1, - spawnY:1, - spawnZ:1, - x:0, - y:1+1.62, - z:0, - isLoadedInCreative:false, - dayCycleStopTime:0, - eduMode:false, - unknown:"" - }); - - client.writeMCPE('set_spawn_position', { - x: 1, - y: 64, - z: 1 - }); - client.writeMCPE("set_time",{ - time:0, - started:1 - }); - - client.writeMCPE('respawn', { - x: 1, - y: 64, - z: 1 - }); - }); - - client.on("request_chunk_radius",() => { - client.writeMCPE('chunk_radius_update',{ - chunkRadius:1 - }); - - for (let x = -1; x <=1; x++) { - for (let z = -1; z <=1; z++) { - client.writeBatch([{"name":"mcpe","params":{name:"full_chunk_data",params:{ - chunkX: x, - chunkZ: z, - order: 1, - chunk_data:fs.readFileSync(__dirname+"/chunk") - }}}]); - } - } - - client.writeMCPE('player_status', { - status: 3 - }); - - client.writeMCPE('set_time', { - time: 0, - started: 1 - }); + console.log(packet); + // client.writeMCPE("player_status",{ + // status:0 + // }); + // client.writeMCPE('move_player', { + // entityId: [0,0], + // x: 1, + // y: 64 + 1.62, + // z: 1, + // yaw: 0, + // headYaw: 0, + // pitch: 0, + // mode: 0, + // onGround: 1 + // }); + // + // client.writeMCPE("start_game",{ + // seed:-1, + // dimension:0, + // generator:1, + // gamemode:1, + // entityId:[0,0], + // spawnX:1, + // spawnY:1, + // spawnZ:1, + // x:0, + // y:1+1.62, + // z:0, + // isLoadedInCreative:false, + // dayCycleStopTime:0, + // eduMode:false, + // unknown:"" + // }); + // + // client.writeMCPE('set_spawn_position', { + // x: 1, + // y: 64, + // z: 1 + // }); + // client.writeMCPE("set_time",{ + // time:0, + // started:1 + // }); + // + // client.writeMCPE('respawn', { + // x: 1, + // y: 64, + // z: 1 + // }); + // }); + // + // client.on("request_chunk_radius",() => { + // client.writeMCPE('chunk_radius_update',{ + // chunkRadius:1 + // }); + // + // for (let x = -1; x <=1; x++) { + // for (let z = -1; z <=1; z++) { + // client.writeBatch([{"name":"mcpe","params":{name:"full_chunk_data",params:{ + // chunkX: x, + // chunkZ: z, + // order: 1, + // chunk_data:fs.readFileSync(__dirname+"/chunk") + // }}}]); + // } + // } + // + // client.writeMCPE('player_status', { + // status: 3 + // }); + // + // client.writeMCPE('set_time', { + // time: 0, + // started: 1 + // }); }); From 6783fa43cfcb806fb9d6b8bfadbfcdfcdb9129c3 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Tue, 14 Jun 2016 18:41:49 -0400 Subject: [PATCH 007/106] fix datatypes, we ain't got no short/long --- data/protocol.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 28140ad..fb5e2d3 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -741,11 +741,11 @@ [ { "name": "unknown", - "type": "short" + "type": "i16" }, { "name": "protocol", - "type": "long" + "type": "i64" }, { "name": "bodyLength", @@ -1819,7 +1819,7 @@ }, { "name": "flags", - "type": "short" + "type": "i16" } ] ], From 8c06ca5a38d1a55aba4881937b3342090ed9c01d Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Wed, 15 Jun 2016 00:44:38 +0200 Subject: [PATCH 008/106] parse server bound batches --- src/createClient.js | 2 +- src/createServer.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/createClient.js b/src/createClient.js index 9833f33..3cd58e1 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -52,7 +52,7 @@ function createClient(options) { client.on('batch', function(packet) { var buf = zlib.inflateSync(packet.payload); var packets=batchProto.parsePacketBuffer("insideBatch",buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0x8e]),packet]))); + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]),packet]))); }); return client; diff --git a/src/createServer.js b/src/createServer.js index 943f34f..557d088 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -39,7 +39,13 @@ function createServer(options) { client.writeMCPE("batch",{ payload:payload }); - } + }; + + client.on('batch', function(packet) { + var buf = zlib.inflateSync(packet.payload); + var packets=batchProto.parsePacketBuffer("insideBatch",buf).data; + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]),packet]))); + }); }); return server; } From 1dc00237fac986815a7aab810ab7e8b60cb09f73 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Wed, 15 Jun 2016 06:53:00 -0400 Subject: [PATCH 009/106] login event, jwt decoding --- data/protocol.json | 16 ++------- examples/server.js | 83 ++------------------------------------------- src/createServer.js | 36 ++++++++++++++++++-- 3 files changed, 39 insertions(+), 96 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index fb5e2d3..761511d 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -739,25 +739,13 @@ "packet_game_login": [ "container", [ - { - "name": "unknown", - "type": "i16" - }, { "name": "protocol", - "type": "i64" - }, - { - "name": "bodyLength", "type": "i32" }, { - "name": "chain", - "type": ["pstring", {"countType": "li32"}] - }, - { - "name": "clientData", - "type": ["pstring", {"countType": "li32"}] + "name": "body", + "type": ["buffer",{"countType":"i32"}] } ] ], diff --git a/examples/server.js b/examples/server.js index 0190462..c5172ad 100644 --- a/examples/server.js +++ b/examples/server.js @@ -15,87 +15,10 @@ var server = pmp.createServer({ }); server.on('connection', function(client) { + //client.on("mcpe", packet => console.log(packet)); - - client.on("mcpe",packet => console.log(JSON.stringify(packet))); - - client.on("game_login",packet => { - console.log(packet); - // client.writeMCPE("player_status",{ - // status:0 - // }); - // client.writeMCPE('move_player', { - // entityId: [0,0], - // x: 1, - // y: 64 + 1.62, - // z: 1, - // yaw: 0, - // headYaw: 0, - // pitch: 0, - // mode: 0, - // onGround: 1 - // }); - // - // client.writeMCPE("start_game",{ - // seed:-1, - // dimension:0, - // generator:1, - // gamemode:1, - // entityId:[0,0], - // spawnX:1, - // spawnY:1, - // spawnZ:1, - // x:0, - // y:1+1.62, - // z:0, - // isLoadedInCreative:false, - // dayCycleStopTime:0, - // eduMode:false, - // unknown:"" - // }); - // - // client.writeMCPE('set_spawn_position', { - // x: 1, - // y: 64, - // z: 1 - // }); - // client.writeMCPE("set_time",{ - // time:0, - // started:1 - // }); - // - // client.writeMCPE('respawn', { - // x: 1, - // y: 64, - // z: 1 - // }); - // }); - // - // client.on("request_chunk_radius",() => { - // client.writeMCPE('chunk_radius_update',{ - // chunkRadius:1 - // }); - // - // for (let x = -1; x <=1; x++) { - // for (let z = -1; z <=1; z++) { - // client.writeBatch([{"name":"mcpe","params":{name:"full_chunk_data",params:{ - // chunkX: x, - // chunkZ: z, - // order: 1, - // chunk_data:fs.readFileSync(__dirname+"/chunk") - // }}}]); - // } - // } - // - // client.writeMCPE('player_status', { - // status: 3 - // }); - // - // client.writeMCPE('set_time', { - // time: 0, - // started: 1 - // }); - + client.on("login", data => { + console.log(client.displayName + '(' + client.XUID + ') ' + ' joined the game'); }); client.on('error', function(err) { diff --git a/src/createServer.js b/src/createServer.js index 557d088..7fe92db 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,10 +1,16 @@ const raknet = require('raknet'); const zlib = require('zlib'); const ProtoDef = require('protodef').ProtoDef; -const batchProto=new ProtoDef(); +const jwt = require('jwt-simple'); +const batchProto = new ProtoDef(); batchProto.addTypes(require("./datatypes/minecraft")); batchProto.addType("insideBatch",["endOfArray",{"type":["buffer",{"countType":"i32"}]}]); +const dataProto = new ProtoDef(); +dataProto.addType("data_chain", [ "container", [ { "name":"chain", "type":[ "pstring", { "countType":"li32" } ] }, { "name":"clientData", "type":[ "pstring", { "countType":"li32" } ] } ] ]); + +const secret = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; + function createServer(options) { options = options || {}; var port = options.port != null ? @@ -26,7 +32,33 @@ function createServer(options) { server.on("connection", function (client) { client.on("mcpe",packet => client.emit(packet.name,packet.params)); - client.writeMCPE=(name,packet) => { + client.on("game_login", packet => { + var body = packet.body; + var body2 = zlib.inflateSync(body); + var parsed = dataProto.parsePacketBuffer("data_chain", body2); + parsed.data.chain = JSON.parse(parsed.data.chain); + + var clientData = parsed.data.clientData; + var chain1 = parsed.data.chain.chain[0]; + var chain2 = parsed.data.chain.chain[1].replace('\n', ''); + + var decode1 = jwt.decode(chain1, secret, 'ES384'); + var nextKey1 = decode1.identityPublicKey; + + var decode2 = jwt.decode(chain2, nextKey1, 'ES384'); + var nextKey2 = decode2.identityPublicKey; + + var clientDecode = jwt.decode(clientData, nextKey1, 'ES384'); + client.randomId = clientDecode.ClientRandomId; + client.skinData = clientDecode.SkinData; + client.skinId = clientDecode.SkinId + client.identity = decode2.extraData.identity; + client.displayName = decode2.extraData.displayName; + client.XUID = decode2.extraData.XUID; + client.emit('login', {displayName: client.displayName, randomId: client.randomId, skinData: client.skinData, skinId: client.skinId, identity: client.identity, XUID: client.XUID}) + }); + + client.writeMCPE = (name,packet) => { client.writeEncapsulated("mcpe",{ name:name, params:packet From 54c371dd62a36e28b2654baed895ab513d417ce7 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Wed, 15 Jun 2016 07:30:02 -0400 Subject: [PATCH 010/106] generating public keys --- data/protocol.json | 4 ++-- examples/client.js | 1 + examples/deserialize.js | 1 + examples/server.js | 6 +++--- src/createServer.js | 12 ++++++++++++ src/datatypes/minecraft.js | 1 - src/transforms/serializer.js | 1 + 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 761511d..41e454c 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -714,7 +714,7 @@ "container", [] ], - "server_to_client_handshake": [ + "packet_server_to_client_handshake": [ "container", [ { @@ -727,7 +727,7 @@ } ] ], - "client_to_server_handshake": [ + "packet_client_to_server_handshake": [ "container", [ { diff --git a/examples/client.js b/examples/client.js index d7ac65f..65b703f 100644 --- a/examples/client.js +++ b/examples/client.js @@ -1,3 +1,4 @@ +'use strict'; var pmp = require('../'); if(process.argv.length !=5) { diff --git a/examples/deserialize.js b/examples/deserialize.js index 97b4f96..bc9132f 100644 --- a/examples/deserialize.js +++ b/examples/deserialize.js @@ -1,3 +1,4 @@ +'use strict'; var mcpe = require('../'); var Parser = require('protodef').Parser; diff --git a/examples/server.js b/examples/server.js index c5172ad..35ed57c 100644 --- a/examples/server.js +++ b/examples/server.js @@ -15,17 +15,17 @@ var server = pmp.createServer({ }); server.on('connection', function(client) { - //client.on("mcpe", packet => console.log(packet)); + client.on("mcpe", packet => console.log(packet)); client.on("login", data => { console.log(client.displayName + '(' + client.XUID + ') ' + ' joined the game'); }); - client.on('error', function(err) { + client.on('error', err => { console.log(err.stack); }); - client.on('end',function() { + client.on('end', () => { console.log("client left"); }) }); diff --git a/src/createServer.js b/src/createServer.js index 7fe92db..6b8d5b8 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,7 +1,9 @@ +'use strict'; const raknet = require('raknet'); const zlib = require('zlib'); const ProtoDef = require('protodef').ProtoDef; const jwt = require('jwt-simple'); +const crypto = require('crypto'); const batchProto = new ProtoDef(); batchProto.addTypes(require("./datatypes/minecraft")); batchProto.addType("insideBatch",["endOfArray",{"type":["buffer",{"countType":"i32"}]}]); @@ -56,6 +58,16 @@ function createServer(options) { client.displayName = decode2.extraData.displayName; client.XUID = decode2.extraData.XUID; client.emit('login', {displayName: client.displayName, randomId: client.randomId, skinData: client.skinData, skinId: client.skinId, identity: client.identity, XUID: client.XUID}) + + client.ecdh = crypto.createECDH('secp192k1'); + // console.log(nextKey2); + // client.secret = client.ecdh.computeSecret(nextKey2, 'base64'); + // console.log(client.edch.getPublicKey('base64')); + + client.writeMCPE('server_to_client_handshake', { + publicKey: client.edch.getPublicKey('base64'), + serverToken: "SO SECRET VERY SECURE" + }); }); client.writeMCPE = (name,packet) => { diff --git a/src/datatypes/minecraft.js b/src/datatypes/minecraft.js index fb1bc48..ab9e940 100644 --- a/src/datatypes/minecraft.js +++ b/src/datatypes/minecraft.js @@ -1,5 +1,4 @@ 'use strict'; - var nbt = require('prismarine-nbt'); const UUID = require('uuid-1345'); diff --git a/src/transforms/serializer.js b/src/transforms/serializer.js index bda77e3..010e850 100644 --- a/src/transforms/serializer.js +++ b/src/transforms/serializer.js @@ -1,3 +1,4 @@ +'use strict'; var ProtoDef = require('protodef').ProtoDef; var Serializer = require('protodef').Serializer; var Parser = require('protodef').Parser; From 26dca46471caea7465dc4419b7728028982aac77 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Thu, 16 Jun 2016 07:11:22 -0400 Subject: [PATCH 011/106] more encryption stuff, lots of progress --- examples/server.js | 2 +- jwt.js | 25 -------- package.json | 4 +- src/createServer.js | 147 +++++++++++++++++++++++++++++++++++--------- 4 files changed, 122 insertions(+), 56 deletions(-) delete mode 100644 jwt.js diff --git a/examples/server.js b/examples/server.js index 35ed57c..9773f2c 100644 --- a/examples/server.js +++ b/examples/server.js @@ -11,7 +11,7 @@ if(process.argv.length !=4) { var server = pmp.createServer({ host: process.argv[2], port: parseInt(process.argv[3]), - name: 'MCPE;Minecraft: PE Server;70 70;0.14.3;0;20' + name: 'MCPE;Minecraft: PE Server;81 81;0.15.0;0;20' }); server.on('connection', function(client) { diff --git a/jwt.js b/jwt.js deleted file mode 100644 index 7d14499..0000000 --- a/jwt.js +++ /dev/null @@ -1,25 +0,0 @@ -var jwt = require('jwt-simple'); -var example = { - "chain": { - "chain": [ - "eyJ4NXUiOiJNSFl3RUFZSEtvWkl6ajBDQVFZRks0RUVBQ0lEWWdBRThFTGtpeHlMY3dsWnJ5VVFjdTFUdlBPbUkyQjd2WDgzbmRuV1JVYVhtNzR3RmZhNWZcL2x3UU5UZnJMVkhhMlBtZW5wR0k2SmhJTVVKYVdacmptTWo5ME5vS05GU05CdUtkbThyWWlYc2ZhejNLMzZ4XC8xVTI2SHBHMFp4S1wvVjFWIiwiYWxnIjoiRVMzODQifQ.eyJuYmYiOjE0NjA4OTYzMzcsInJhbmRvbU5vbmNlIjo3MzI2MDA4MDM2OTAzODU5NzM0LCJpc3MiOiJSZWFsbXNBdXRob3JpemF0aW9uIiwiZXhwIjoxNDYwOTgyNzk3LCJpYXQiOjE0NjA4OTYzOTcsImNlcnRpZmljYXRlQXV0aG9yaXR5Ijp0cnVlLCJpZGVudGl0eVB1YmxpY0tleSI6Ik1IWXdFQVlIS29aSXpqMENBUVlGSzRFRUFDSURZZ0FFQlJ1MEd5VUFkYkZjd1wvUU1vNmFBTGFaZHJTeVNkZFwva1F2OXFHOHlHSWxnc0orVStNMVVpZWtjaDFPc3NHdXlFZW1oSWR1OUZWYklJanRWKzY4bXVkc0orSE1MdGYrMDJTYVk0elBtXC9iR3RURkRIUDBRK2FoUmhvVWRiNVptaFwvIn0.J9vCSKZOH6ZuO_rMv3Tlo0Z7nAnXI44rdlL4FyXcWfdTHG3HlHywos0WLWnMnlxP_Ex2co2M21CSyIhIFM6EvugemsuEZIQpz3WTAmUlaEoaNT7dgGFbqGUn9tr6S1MD", - "eyJ4NXUiOiJNSFl3RUFZSEtvWkl6ajBDQVFZRks0RUVBQ0lEWWdBRUJSdTBHeVVBZGJGY3dcL1FNbzZhQUxhWmRyU3lTZGRcL2tRdjlxRzh5R0lsZ3NKK1UrTTFVaWVrY2gxT3NzR3V5RWVtaElkdTlGVmJJSWp0Vis2OG11ZHNKK0hNTHRmKzAyU2FZNHpQbVwvYkd0VEZESFAwUSthaFJob1VkYjVabWhcLyIsImFsZyI6IkVTMzg0In0.eyJuYmYiOjE0NjA4OTYzMzcsImV4dHJhRGF0YSI6eyJpZGVudGl0eSI6Ijk4YjBjYmNmLWU5MWUtMzAwNC05NjUyLWFlZDkyZjhlMjU2ZCIsImRpc3BsYXlOYW1lIjoieWF3a2F0IiwiWFVJRCI6IjI1MzU0Mzc2MTMzNTc1MzUifSwicmFuZG9tTm9uY2UiOi0zMzg4NzY3NzYzMDEyODY5NTg3LCJpc3MiOiJSZWFsbXNBdXRob3JpemF0aW9uIiwiZXhwIjoxNDYwOTgyNzk3LCJpYXQiOjE0NjA4OTYzOTcsImlkZW50aXR5UHVibGljS2V5IjoiTUhZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUNJRFlnQUVERUtuZXFFdmNxVXFxRk1NMUhNMUE0eldqSkMrSThZK2FLekc1ZGwrNndOT0hIUTRObUcyUEVYUkpZaHVqeW9kRkgrd08wZEVyNEdNMVdvYVdvZzh4c1lRNm1RSkFDMGVWcEJNOTZzcFVCMWVNTjU2K0J3bEo0SDNReDRUQXZBcyJ9.gmAdOsTXU68QIqWweaU9FBuSyhNHcGI2hslrP0AQtVqGHyfPIhm54aUesZSj9mLGIIJTx_I50wijDlsj_lFExb3W3UQV0BDWCsYNBoJ5Kb9AX5O11onqtGbNynCVufJB" - ] - }, - "clientData": "eyJhbGciOiJFUzM4NCIsIng1dSI6Ik1IWXdFQVlIS29aSXpqMENBUVlGSzRFRUFDSURZZ0FFREVLbmVxRXZjcVVxcUZNTTFITTFBNHpXakpDK0k4WSthS3pHNWRsKzZ3Tk9ISFE0Tm1HMlBFWFJKWWh1anlvZEZIK3dPMGRFcjRHTTFXb2FXb2c4eHNZUTZtUUpBQzBlVnBCTTk2c3BVQjFlTU41NitCd2xKNEgzUXg0VEF2QXMifQo,.eyJDbGllbnRSYW5kb21JZCI6MTM2NTg2NDYwOCwiU2VydmVyQWRkcmVzcyI6IjE5Mi4xNjguMS41NjoxOTEzMiIsIlNraW5EYXRhIjoiQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRGxtVWYvNVpsSC8rV05QLy9sbVVmLzVabEgvK1dOUC8vbG1VZi81WTAvLzlpQU12L1lnREwvMklBeS85aUFNdi9ZZ0RMLzJJQXkvOWlBTXYvWWdETC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBNVkwLy8rV1pSLy9salQvLzVabEgvK1daUi8vY2t6ei81WmxILytpZFRQL1lnREwvMklBeS82cUpYditxaVY3L3FvbGUvNnFKWHYvWWdETC8ySUF5L3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFPV1pSLy9ja3p6LzZKMU0vK1daUi8vbGpULy8zSk04LytXTlAvL2xtVWYvMklBeS82cUpYditjZTFEL25IdFEvNXg3VVArY2UxRC9xb2xlLzlpQU12OEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQURsalQvLzNKTTgvK2lkVFAvbG1VZi81WmxILytXWlIvL2xqVC8vM0pNOC85aUFNditxaVY3L25IdFEvNXg3VVArY2UxRC9uSHRRLzZxSlh2L1lnREwvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTVZMC8vK1dOUC8vb25Vei81WTAvLytXWlIvL2xqVC8vNkoxTS85eVRQUC9meHFQL3FvbGUvNXg3VVArY2UxRC9uSHRRLzV4N1VQK3FpVjcvMklBeS93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT1daUi8vbGpULy81WmxILytXTlAvL2NrenovNVpsSC8raWRUUC9vblV6LzM4YWovNnFKWHYrY2UxRC9uSHRRLzV4N1VQK2NlMUQvcW9sZS85aUFNdjhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEY2t6ei81WTAvLytXTlAvL2xtVWYvNVpsSC8rV1pSLy9salQvLzZKMU0vOS9Hby8rcWlWNy9xb2xlLzZxSlh2K3FpVjcvcW9sZS82cUpYdi9ZZ0RML0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE2SjFNLytXWlIvL2xqVC8vNkoxTS8raWRUUC9salQvLzZKMU0vOXlUUFAvZnhxUC8zOGFqLzkvR28vL2Z4cVAvMzhhai85L0dvLy9meHFQLzM4YWovd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRGxtVWYvNVkwLy8raWRUUC9sbVVmLzZKMU0vK2lkVFAvb25Vei81WTAvLytXWlIvL2xqVC8vNVpsSC8rV05QLy9salQvLzVabEgvK1dOUC8vbG1VZi81WmxILytXTlAvL2xtVWYvNVkwLy8rV1pSLy9salQvLzZKMU0vK1daUi8vbGpULy81WmxILytXTlAvL2xtVWYvNVkwLy8rV1pSLy9vblV6LzVZMC8vd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBNVkwLy8rV1pSLy9sbVVmLzVZMC8vK1daUi8vbGpULy81WTAvLytXWlIvL2xqVC8vNVpsSC8rV05QLy9sbVVmLzNKTTgvK1daUi8vbG1VZi81WTAvLytXWlIvL29uVXovNkoxTS8raWRUUC9salQvLzVabEgvK1dOUC8vbG1VZi82SjFNLytpZFRQL2xtVWYvNVkwLy8raWRUUC9vblV6LzVZMC8vK1daUi84QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFPaWRUUC9vblV6LzVZMC8vK1daUi8vbGpULy81WmxILytpZFRQL2xtVWYvNVpsSC8rV05QLy9sbVVmLzNKTTgvK3ZUcy8vcjA3UC81WmxILytXTlAvL29uVXovNVkwLy8rV05QLy9salQvLzZKMU0vK1daUi8vbGpULy82SjFNLytpZFRQL29uVXovNVkwLy8raWRUUC9sbVVmLzZKMU0vK1dOUC8vbG1VZi9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQURsbVVmLzNKTTgvK1daUi8vbG1VZi82SjFNLzl5VFBQL2NrenovNVpsSC85eVRQUC9ja3p6LzNKTTgvK3ZUcy8veTJyci81TXVwLytUTHFmL2xtVWYvNVpsSC8rV1pSLy9ja3p6LzVabEgvK1dOUC8vb25Vei82SjFNLytXWlIvL2xqVC8vNkoxTS8rV05QLy9vblV6LzVabEgvK1dOUC8vbG1VZi81WTAvL3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTNKTTgvK1daUi8vbG1VZi81WmxILzl5VFBQL3IwN1AvNjlPei85eVRQUC9reTZuLysvdjcveU5pSlAveTJyci84dDNDL3lOaUpQLzcrL3YvNU11cC85eVRQUC9salQvLzVabEgvK1daUi8vbG1VZi81WTAvLytXWlIvL2xqVC8vNVpsSC8rV05QLy9sbVVmLzVabEgvK2lkVFAvbG1VZi81WmxILytpZFRQOEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBTnlUUFAvbGpULy82SjFNLzl5VFBQL3IwN1AvOHQzQy8vTGF1di95MnJyLzd0YTIvKy9adS8veTJyci84dDNDLy9MYXV2L3kyNzMvN3RlNS8vTGF1di9yMDdQLzNKTTgvK1daUi8vbGpULy81WmxILytXWlIvL29uVXovNVkwLy8rV05QLy9vblV6LzVabEgvK1dOUC8vbGpULy82SjFNLytXWlIvL2xtVWYvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEbGpULy81WmxILytpZFRQL2xtVWYvNjlPei8vTGF1di95M2NMLzh0M0MvL0xhdXYveTNjTC84dHE2LysrN3NmL3Z1N0gvOHRxNi8vTGF1di9yMDdQLzh0M0MvK3ZUcy8vY2t6ei81WTAvLytXWlIvL2xqVC8vNVpsSC8raWRUUC9salQvLzVZMC8vK1dOUC8vbG1VZi82SjFNLytXWlIvL2xtVWYvNVkwLy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE1WmxILytXTlAvL2xtVWYvNjlPei8rdlRzLy95M2NMLzh0cTYvL0xhdXYveTJyci84dHE2Ly9MZHd2L3kycnIvOHRxNi8vTGR3di95M2NMLzh0cTYvK3ZUcy8vY2t6ei81WTAvLytXWlIvL2xtVWYvNVkwLy8rV1pSLy9salQvLzVabEgvK1dOUC8vb25Vei81WmxILytXWlIvL2NrenovNVkwLy8raWRUUDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUJrUVN6L1pFRXMvMlJCTFA5a1FTei9LQ2dvL3lnb0tQOG9LQ2ovS0Nnby93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBZXJWMy80YUhZZi9ZZ0RMLzJJQXkvOWlBTXYvWWdETC82SjFNLytXWlIvOW9SVEQvYUVVdy8yaEZNUDlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3L3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFlcTkzLzNxdmQvOTZyM2YvMkxxVS8rdlRzLy9ZdXBUL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVpFRXMvMlJCTFA5a1FTei9aRUVzL3lnb0tQOG9LQ2ovS0Nnby95Z29LUDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFIcTFkLytHaDJIL2hvZGgvNGFIWWYrR2gySC8ySUF5LytXWlIvL29uVXovYUVVdy8yaEZNUDlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3LzJoRk1QOEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUhxdmQvOTZ0WGYvZXE5My85aTZsUC9yMDdQLzJMcVUvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBR1JCTFA5a1FTei9aRUVzLzJSQkxQOG9LQ2ovS0Nnby95Z29LUDhvS0NqL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUI2dFhmL2hvZGgvNGFIWWYvZnhxUC8zOGFqLzRhSFlmL2xtVWYvNkoxTS8yaEZNUDlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3LzJoRk1QOW9SVEQvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQjZyM2YvZXJWMy8zcXZkLy9yMDdQLzJMcVUvK3ZUcy84QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCa1FTei9aRUVzLzJSQkxQOWtRU3ovS0Nnby95Z29LUDhvS0NqL0tDZ28vd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQWVyVjMvNGFIWWYvcjA3UC84dHE2Ly9MYXV2L2xtVWYvNVpsSC8rV05QLzlvUlREL2FFVXcvMmhGTVA5b1JURC9hRVV3LzJoRk1QOW9SVEQvYUVVdy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBZXE5My8zcXZkLzk2cjNmLzY5T3ovOWk2bFAvcjA3UC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUI2cjNmL2VyVjMvM3ExZC85NnIzZi9hRVV3LzNsVlBmK0FXa0QvYlVvei8yaEZNUDlrUVN6L2FFVXcvMlJCTFArTXZvci9qTDZLLzMyeWV2OTlzbnIvZXJWMy8zcTFkLzk2dFhmL2VxOTMvNHkraXYrR2gySC82OU96Ly9MYXV2L3kycnIvNkoxTS8raWRUUC9salQvLzZKMU0vK2lkVFAvbG1VZi82SjFNLytpZFRQL29uVXovNVpsSC8rV05QLy9sbVVmLzVabEgvNEcxZi8rTHVvai9lcTkzLzNxMWQvOTZyM2YvZXE5My80eStpditMdW9qL2ZiSjYvM3F2ZC85NnRYZi9lclYzLzNxdmQvK0x1b2ovakw2Sy80dTZpUDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVpFRXMvM3F2ZC85NnIzZi9hRVV3LzNKT052OTVWVDMvZVZVOS8yaEZNUDlrUVN6L2FFVXcvMmhGTVA5a1FTei9iMHcxLzRCYVFQK0FXa0QvY2s0Mi8zcTFkLzk2dFhmL2VxOTMvM3F2ZC8rTXZvci9pb3RtLyt2VHMvL3kycnIvOHRxNi8vTGF1di9sbVVmLzZKMU0vK1daUi8vbG1VZi9lcTkzLzNxdmQvL2xtVWYvNVkwLy8rV05QLy9sbVVmL2diVi8vNEcxZi8rTHVvai9pN3FJLzNxdmQvOTZyM2YvZXE5My8zcTFkLytMdW9qL2ZiSjYvNHkraXY5NnRYZi9lclYzLzNxdmQvOTZyM2YvaTdxSS80dTZpUCtNdm9yL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBR1JCTFA5b1JURC9aRUVzLzJoRk1QOXZURFgvZ0ZwQS8yaEZNUDl5VGpiL1pFRXMvMmhGTVA5a1FTei9hRVV3LzI5TU5mK0FXa0QvZVZVOS8zSk9Odjk2cjNmL2VyVjMvM3F2ZC85NnIzZi9qTDZLLzMyeWV2K01qV2ovNjlPei8rdlRzLy9salQvLzVabEgvK2lkVFA5NnIzZi9lcTkzLzNxdmQvOTZ0WGYvZ2JWLy80RzFmLytCdFgvL2diVi8vNHkraXYrTHVvai9pN3FJLzR1NmlQOTZyM2YvZXJWMy8zcTFkLzk2dFhmL2k3cUkvNHkraXYrTHVvai9lcTkzLzNxMWQvOTZ0WGYvZXE5My80eStpditMdW9qL2pMNksvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCa1FTei9aRUVzLzJSQkxQOW9SVEQvYUVVdy8yaEZNUDk1VlQzL2NrNDIvMlJCTFA5b1JURC9aRUVzLzJoRk1QOXZURFgvZ0ZwQS8zbFZQZjl5VGpiL2VxOTMvM3ExZC85NnIzZi9lcTkzLzNldmRmK012b3Ivakw2Sy80eU5hUCtNaldqLzVabEgvK2lkVFA5OXNuci9lclYzLzNxMWQvOTZyM2YvZXJWMy80eStpditMdW9qL2pMNksvNHU2aVArTHVvai9pN3FJLzMyeWV2K0x1b2ovZ0lKYS80ZUpZditIaVdML2dJSmEvNGFIWWYrUGtHdi9ob2RoLzRDQ1d2K0hpV0wvaDRsaS80Q0NXditHaDJIL2o1QnIvNGFIWWY4QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFaRUVzLzJSQkxQOWtRU3ovWkVFcy8yOU1OZitHWGtiL2hsNUcvMjlNTmY5a1FTei9aRUVzLzJSQkxQOWtRU3ovYUVVdy8yaEZNUDlvUlREL2FFVXcvM3F2ZC85NnRYZi9lclYzLzNxMWQvOTNyM1gvakw2Sy80eStpdjk5c25yL2pMNksvK2lkVFA5OXRIci9pN3FJLzNxdmQvOTZyM2YvZXE5My8zcTFkLytNdm9yL2k3cUkvNHkraXYrTHVvai9pN3FJLzR5K2l2K012b3Ivakw2Sy8rVEpxUC9reWFqLzVNbW8vK1RKcVAvcjA3UC82OU96Lyt2VHMvL2t5YWovNU1tby8rVEpxUC9reWFqLzY5T3ovK3ZUcy8vcjA3UC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQURzN08vODdPenYvT3pzNy8yUkJMUDlvUlREL2VGUTgvM2hVUFA5b1JURC9aRUVzL3pzN08vODdPenYvT3pzNy8wWkdSdjlHUmtiL1JrWkcvMFpHUnY5NnIzZi9lclYzLzNxdmQvOTZ0WGYvZmJKNi80eStpditMdW9qL2pMNksvNHU2aVArTXZvci9pN3FJLzR1NmlQOTZyM2YvZXE5My8zcXZkLzk2cjNmL2k3cUkvMzJ5ZXYrTXZvci9pN3FJLzR1NmlQK012b3IvaTdxSS80eStpdi9reWFqLzVNbW8vK3ZUcy8vcjA3UC84dHE2Ly9MYXV2L3IwN1AvNjlPei8rdlRzLy9reWFqLzY5T3ovL0xhdXYvcjA3UC84dHE2L3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQkpTVW4vU1VsSi8wbEpTZjg3T3p2L1dscGEvMTFkWGY5ZFhWMy9XbHBhL3pzN08vOUpTVW4vU1VsSi8wbEpTZjlOVFUzL1YxZFgvMWRYVi85TlRVMy9lcTkzLzNxMWQvOTZyM2YvZXJWMy80eStpditNdm9yL2ZiSjYvNHkraXYrTHVvai9qTDZLLzR1NmlQK012b3IvZXE5My8zcTFkLzk2cjNmL2VxOTMvNHU2aVArTXZvci9qTDZLLzR1NmlQK012b3IvZmJKNi80eStpditNdm9yLzVNbW8vK3ZUcy8vcjA3UC82OU96Ly9MYXV2L3kycnIvNmRDdi8rdlRzLy9zMUxqLzVNdXEvK3pVdVAveTJyci84dHE2Ly9MZHd2OEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBU1VsSi8wbEpTZjlKU1VuL1NVbEovMkZoWWY5cmEydi9hMnRyLzJGaFlmOUpTVW4vU1VsSi8wbEpTZjlKU1VuL1RVMU4vMWRYVi85WFYxZi9UVTFOLzNxMWQvOTZ0WGYvZXJWMy8zcTFkLytNdm9yL2pMNksvM2V2ZGYrTXZvci9mYko2LzR5K2l2K012b3Ivakw2Sy8zcXZkLzk2dFhmL2VyVjMvM3ExZC8rTXZvci9qTDZLLzR5K2l2OTlzbnIvakw2Sy8zMnllditNdm9yL2pMNksvK3pVdVAvcjA3UC83TlM0Lyt2VHMvL3AwYlAvOHRxNi8vTGF1di92MmIzLzdOUzQvK1hMcmYvdjJyLy84dHE2Ly9MYXV2L3AwYlAvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFFbEpTZjlKU1VuL096czcvMGxKU2Y5aFlXSC9hMnRyLzJ0cmEvOWhZV0gvU1VsSi96czdPLzlKU1VuL1NVbEovMDFOVGY5WFYxZi9WMWRYLzAxTlRmOFlPQmIvR2o4Wi94ZzRGdjhhUHhuL1Q0Qk0vNHkraXY5M3IzWC9qTDZLLzNldmRmK012b3Ivakw2Sy8wK0FUUDhhUHhuL0dqOFoveGc0RnY4YVB4bi9UNEJNLzR5K2l2K012b3IvZDdCMC80eStpdjkzcjNYL2pMNksvMCtBVFAvczFMai83TlM0Lyt6VXVQL3MxTGovNmRHei8vTGR3di95M2NMLzdOUzQvKy9hdi8vczFMai83TlM0Ly9MZHd2L3kzY0wvOHQzQy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUJOVFUzL1RVMU4vMUpTVXY4N096di9XbHBhLzJOalkvOWpZMlAvV2xwYS96czdPLzlTVWxML1RVMU4vMDFOVGY5S1Nrci9VRkJRLzFCUVVQOUtTa3IvZXJWMy8zcXZkLzk2dFhmL2VxOTMveGc0RnY4WU9CYi9HRGdXL3hvL0dmOGFQeG4vR0RnVy94ZzRGdjhhUHhuL2VxOTMvM3F2ZC85NnRYZi9lclYzL3hvL0dmOFlPQmIvR0RnVy94by9HZjhhUHhuL0dEZ1cveG8vR2Y4YVB4bi83TlM0Lyt6VXVQL3Yyci8vNzlxLy8vTGR3di95M2NMLzh0L0kvK3pVdVAvdjJyLy83TlM0Lyt6VXVQL3kzOGovOHQzQy8rclV1UDhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVRVMU4vMDFOVGY5U1VsTC9YRnhjLzJGaFlmOXJhMnYvYTJ0ci8yRmhZZjljWEZ6L1VsSlMvMDFOVGY5TlRVMy9Ta3BLLzFCUVVQOVFVRkQvU2twSy8zcTFkLzk2cjNmL2VyVjMvM3F2ZC8rTHVvai9qTDZLLzR1NmlQK012b3IvZmJKNi80dTZpUCtMdW9qL2pMNksvM3F2ZC85NnIzZi9lclYzLzNxdmQvK0x1b2ovakw2Sy80eStpdjk5c25yL2pMNksvNHU2aVArTHVvai9qTDZLLysvYXYvL3Yyci8vN05TNC8rL2F2Ly95MzhqLzh0L0kvL0xkd3YvdjJyLy83OXEvLysvYXYvL3MxTGovOHQvSS8vTGR3di95M2NML0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRDgvUC84L1B6Ly9QejgvLzF4Y1hQOWpZMlAvY0hCdy8zQndjUDlqWTJQL1hGeGMvejgvUC84L1B6Ly9QejgvLzBoSVNQOU1URXovVEV4TS8waElTUDk2cjNmL2VyVjMvM3ExZC85NnIzZi9pN3FJLzJoRk1QOTFVRGovZFZBNC8zVlFPUDkxVURqL2FFVXcvNHU2aVA5NnRYZi9lcTkzLzNxMWQvOTZyM2YvaTdxSS80eStpditNdm9yL2pMNksvNHkraXYrTXZvci9qTDZLLzR1NmlQL3MxTGovNzltOS8relV1UC92MnIvLzh0L0kvL0xkd3YveTNjTC83TlM0Lyt6VXVQL3Yyci8vN05TNC8vTGZ5UC95M2NMLzh0M0Mvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCa1FTei9aRUVzLzJSQkxQOWtRU3ovS0Nnby95Z29LUDhvS0NqL0tDZ28vd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQTZKMU0vM3ExZC85NnIzZi8yTHFVLyt2VHMvL1l1cFQvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFaRUVzLzJSQkxQOWtRU3ovWkVFcy95Z29LUDhvS0NqL0tDZ28veWdvS1A4QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT1daUi8vb25Vei9lcTkzLzlpNmxQL3IwN1AvMkxxVS93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUdSQkxQOWtRU3ovWkVFcy8yUkJMUDhvS0NqL0tDZ28veWdvS1A4b0tDai9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEbG1VZi81WTAvLzNxdmQvL3IwN1AvMkxxVS8rdlRzLzhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQmtRU3ovWkVFcy8yUkJMUDlrUVN6L0tDZ28veWdvS1A4b0tDai9LQ2dvL3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE1WTAvLzNxMWQvOTZyM2YvNjlPei85aTZsUC9yMDdQL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCb1JURC9aRUVzLzJoRk1QOWtRU3ovYlVvei80QmFRUDk1VlQzL2FFVXcvMmhGTVA5a1FTei9hRVV3LzJSQkxQOXZURFgvZmJKNi80eStpditNdm9yL2VxOTMvM3ExZC85NnIzZi81WmxILytXTlAvK0x1b2ovaTdxSS8zcXZkLzk2cjNmL2VxOTMvM3F2ZC8rTHVvai9qTDZLLytXTlAvOEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFaRUVzLzJoRk1QOWtRU3ovYUVVdy8yaEZNUDk1VlQzL2VWVTkvM0pPTnY5a1FTei9hRVV3LzJoRk1QOWtRU3ovYjB3MS80QmFRUCtBV2tEL2NrNDIvM3F2ZC85NnIzZi9lcTkzLytpZFRQL2xtVWYvaTdxSS80dTZpUDk2cjNmL2VyVjMvM3F2ZC85NnIzZi9pN3FJLzR1NmlQK012b3IvQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUdSQkxQOW9SVEQvWkVFcy8yaEZNUDl5VGpiL2FFVXcvNEJhUVA5dlREWC9aRUVzLzJoRk1QOWtRU3ovYUVVdy8yOU1OZitBV2tEL2VWVTkvM0pPTnY5NnIzZi9lclYzLzNxMWQvOTZ0WGYvaTdxSS80eStpdjk5c25yL2VxOTMvM3ExZC85NnRYZi9lcTkzLzR5K2l2K0x1b2ovakw2Sy93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQmtRU3ovWkVFcy8yUkJMUDlvUlREL2NrNDIvM2xWUGY5b1JURC9hRVV3LzJSQkxQOW9SVEQvWkVFcy8yaEZNUDl2VERYL2dGcEEvM2xWUGY5eVRqYi9nSUphLzRlSll2K0hpV0wvZ0lKYS80YUhZZitQa0d2L2hvZGgvNENDV3YrSGlXTC9oNGxpLzRDQ1d2K0doMkgvajVCci80YUhZZjhBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBWkVFcy8yUkJMUDlrUVN6L1pFRXMvMjlNTmYrR1hrYi9obDVHLzI5TU5mOWtRU3ovWkVFcy8yUkJMUDlrUVN6L2FFVXcvMmhGTVA5b1JURC9hRVV3LytUSnFQL2t5YWovNU1tby8rVEpxUC9yMDdQLzY5T3ovK3ZUcy8va3lhai81TW1vLytUSnFQL2t5YWovNjlPei8rdlRzLy9yMDdQL0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFEczdPLzg3T3p2L096czcvMlJCTFA5b1JURC9lRlE4LzNoVVBQOW9SVEQvWkVFcy96czdPLzg3T3p2L096czcvMFpHUnY5R1JrYi9Sa1pHLzBaR1J2L2t5YWovNU1tby8rdlRzLy9yMDdQLzh0cTYvL0xhdXYvcjA3UC82OU96Lyt2VHMvL2t5YWovNjlPei8vTGF1di9yMDdQLzh0cTYvd0FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUJKU1VuL1NVbEovMGxKU2Y4N096di9XbHBhLzExZFhmOWRYVjMvV2xwYS96czdPLzlKU1VuL1NVbEovMGxKU2Y5TlRVMy9WMWRYLzFkWFYvOU5UVTMvNU1tby8rdlRzLy9yMDdQLzY5T3ovL0xhdXYveTJyci84dHE2Lyt2VHMvL3MxTGovNjlPei8relV1UC95MnJyLzh0cTYvL0xkd3Y4QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQVNVbEovMGxKU2Y5SlNVbi9TVWxKLzJGaFlmOXJhMnYvYTJ0ci8yRmhZZjlKU1VuL1NVbEovMGxKU2Y5SlNVbi9UVTFOLzFkWFYvOVhWMWYvVFUxTi8relV1UC9yMDdQLzdOUzQvKy9admYvcDBiUC84dHE2Ly9MYXV2L3IwN1AvN05TNC8rWExyZi9zMUxqLzh0cTYvL0xhdXYveTNjTC9BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBRWxKU2Y5SlNVbi9PenM3LzBsSlNmOWhZV0gvYTJ0ci8ydHJhLzloWVdIL1NVbEovenM3Ty85SlNVbi9TVWxKLzAxTlRmOVhWMWYvVjFkWC8wMU5UZi9zMUxqLzdOUzQvK3pVdVAvczFMai82ZEd6Ly9MZHd2L3kzY0wvN05TNC8relV1UC9zMUxqLzdOUzQvK25Scy8veTNjTC84dDNDL3dBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFCTlRVMy9UVTFOLzFKU1V2ODdPenYvV2xwYS8yTmpZLzlqWTJQL1dscGEvenM3Ty85U1VsTC9UVTFOLzAxTlRmOUtTa3IvVUZCUS8xQlFVUDlLU2tyLzdOUzQvK3pVdVAvdjJyLy83TlM0Ly9MZHd2L3kzY0wvNmRHei8relV1UC9zMUxqLzc5cS8vK3pVdVAveTNjTC84dDNDLy9MZHd2OEFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFUVTFOLzAxTlRmOVNVbEwvWEZ4Yy8yRmhZZjlyYTJ2L2EydHIvMkZoWWY5Y1hGei9VbEpTLzAxTlRmOU5UVTMvU2twSy8xQlFVUDlRVUZEL1NrcEsvKy9hdi8vczFMai83OXEvLyt6VXVQL3kzY0wvOHQvSS8vTGR3di92MnIvLzdOUzQvK3pVdVAvdjJyLy84dDNDLy9MZnlQL3kzOGovQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUQ4L1AvOC9Qei8vUHo4Ly8xeGNYUDlqWTJQL2NIQncvM0J3Y1A5alkyUC9YRnhjL3o4L1AvOC9Qei8vUHo4Ly8waElTUDlNVEV6L1RFeE0vMGhJU1AvdjJyLy82OU96Lyt6VXVQL3MxTGovOHQvSS8vTGR3di95M2NMLzdOUzQvKy9hdi8vczFMai83TlM0Ly9MZHd2L3kzOGovOHQvSS93QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBPT0iLCJTa2luSWQiOiJTdGFuZGFyZF9BbGV4In0K.gN2HJV9_WW1hvVj-gGKGJsCGEafIiGnTFgKRUKF2CqhiQk4dgB1dHFnZOglDN4VtW397jIPgs92ppMkyfZf8-09XQ87_o_eC1nvuscmBXt6Bn2UZQP_VYFqh_eCAXvCP" -} - - -var clientData = example.clientData; -var chain1 = example.chain.chain[0]; -var chain2 = example.chain.chain[1]; -var secret = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; - -var decode1 = jwt.decode(chain1, secret, 'ES384'); -var nextKey1 = decode1.identityPublicKey; - -var decode2 = jwt.decode(chain2, nextKey1, 'ES384'); -var nextKey2 = decode2.identityPublicKey; - -var clientDecode = jwt.decode(clientData, nextKey1, 'ES384'); -console.log(clientDecode); diff --git a/package.json b/package.json index 1d4c196..8835beb 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,12 @@ ], "license": "MIT", "dependencies": { + "asn1": "^0.2.3", + "bn.js": "^4.11.4", "jwt-simple": "^0.5.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.0", - "raknet": "^1.7.3", + "raknet": "^1.7.4", "uuid-1345": "^0.99.6" }, "devDependencies": {}, diff --git a/src/createServer.js b/src/createServer.js index 6b8d5b8..845da65 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -4,14 +4,33 @@ const zlib = require('zlib'); const ProtoDef = require('protodef').ProtoDef; const jwt = require('jwt-simple'); const crypto = require('crypto'); +const Ber = require('asn1').Ber; +// const BN = require('bn.js'); + const batchProto = new ProtoDef(); batchProto.addTypes(require("./datatypes/minecraft")); -batchProto.addType("insideBatch",["endOfArray",{"type":["buffer",{"countType":"i32"}]}]); +batchProto.addType("insideBatch", ["endOfArray", { + "type": ["buffer", { + "countType": "i32" + }] +}]); const dataProto = new ProtoDef(); -dataProto.addType("data_chain", [ "container", [ { "name":"chain", "type":[ "pstring", { "countType":"li32" } ] }, { "name":"clientData", "type":[ "pstring", { "countType":"li32" } ] } ] ]); +dataProto.addType("data_chain", ["container", [{ + "name": "chain", + "type": ["pstring", { + "countType": "li32" + }] +}, { + "name": "clientData", + "type": ["pstring", { + "countType": "li32" + }] +}]]); -const secret = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; +const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; +var encryptionEnabled = false; +var sendCounter = 0; function createServer(options) { options = options || {}; @@ -22,8 +41,8 @@ function createServer(options) { 19132; var host = options.host || '0.0.0.0'; - options.customPackets=require("../data/protocol"); - options.customTypes=require("./datatypes/minecraft"); + options.customPackets = require("../data/protocol"); + options.customTypes = require("./datatypes/minecraft"); var server = raknet.createServer(options); server.name = options.name || "Minecraft Server"; @@ -31,8 +50,8 @@ function createServer(options) { server.maxPlayers = options['max-players'] || 20; server.playerCount = 0; - server.on("connection", function (client) { - client.on("mcpe",packet => client.emit(packet.name,packet.params)); + server.on("connection", function(client) { + client.on("mcpe", packet => client.emit(packet.name, packet.params)); client.on("game_login", packet => { var body = packet.body; @@ -44,7 +63,7 @@ function createServer(options) { var chain1 = parsed.data.chain.chain[0]; var chain2 = parsed.data.chain.chain[1].replace('\n', ''); - var decode1 = jwt.decode(chain1, secret, 'ES384'); + var decode1 = jwt.decode(chain1, PUBLIC_KEY, 'ES384'); var nextKey1 = decode1.identityPublicKey; var decode2 = jwt.decode(chain2, nextKey1, 'ES384'); @@ -57,41 +76,111 @@ function createServer(options) { client.identity = decode2.extraData.identity; client.displayName = decode2.extraData.displayName; client.XUID = decode2.extraData.XUID; - client.emit('login', {displayName: client.displayName, randomId: client.randomId, skinData: client.skinData, skinId: client.skinId, identity: client.identity, XUID: client.XUID}) - client.ecdh = crypto.createECDH('secp192k1'); - // console.log(nextKey2); - // client.secret = client.ecdh.computeSecret(nextKey2, 'base64'); - // console.log(client.edch.getPublicKey('base64')); + var reader = new Ber.Reader(new Buffer(nextKey2, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); + reader.readOID(); + var pubKey = new Buffer(reader.readString(Ber.BitString, true)).slice(1); + var ec = crypto.createECDH('secp384r1'); + ec.generateKeys(); + client.sharedSecret = ec.computeSecret(pubKey); + + client.secretKeyBytes = crypto.createHash('sha256').update(client.sharedSecret + "SO SECRET VERY SECURE").digest('binary'); + // console.log(client.secretKeyBytes.length); => 32 client.writeMCPE('server_to_client_handshake', { - publicKey: client.edch.getPublicKey('base64'), - serverToken: "SO SECRET VERY SECURE" + publicKey: ec.getPublicKey('base64'), + serverToken: "SO SECRET VERY SECURE" // obviously, this is super secure (it's not, change it) + }); + + encryptionEnabled = true; + customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe']='restBuffer'; client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol,customPackets).types); + + client.emit('login', { + displayName: client.displayName, + randomId: client.randomId, + skinData: client.skinData, + skinId: client.skinId, + identity: client.identity, + XUID: client.XUID }); }); - client.writeMCPE = (name,packet) => { - client.writeEncapsulated("mcpe",{ - name:name, - params:packet - }); + client.writeMCPE = (name, packet) => { + if (!encryptionEnabled) { + client.writeEncapsulated("mcpe", { + name: name, + params: packet + }); + } else { + sendCounter += 1; + // sendCounter.add(1); + // client.writeEncapsulated("mcpe", { + // name: name, + // params: packet + // }); + } }; - client.writeBatch=function(packets) { - const payload=zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", - packets.map(packet => - client.encapsulatedPacketSerializer.createPacketBuffer(packet).slice(1)))); - client.writeMCPE("batch",{ - payload:payload - }); + + client.writeBatch = function(packets) { + if (!encryptionEnabled) { + const payload = zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", + packets.map(packet => + client.encapsulatedPacketSerializer.createPacketBuffer(packet).slice(1)))); + + client.writeMCPE("batch", { + payload: payload + }); + } else { + sendCounter += 1; + // sendCounter.add(1); + // const payload = zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", + // packets.map(packet => + // client.encapsulatedPacketSerializer.createPacketBuffer(packet).slice(1)))); + // + // client.writeMCPE("batch", { + // payload: payload + // }); + } }; client.on('batch', function(packet) { var buf = zlib.inflateSync(packet.payload); - var packets=batchProto.parsePacketBuffer("insideBatch",buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]),packet]))); + var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; + if (!encryptionEnabled) { + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); + } else { + sendCounter += 1; + // sendCounter.add(1); + // packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]),packet]))); + } }); }); return server; } module.exports = createServer; + +// http://stackoverflow.com/questions/19236327/nodejs-sha256-password-encryption +var AES = {}; + +AES.decrypt = function(cryptkey, iv, encryptdata) { + encryptdata = new Buffer(encryptdata, 'base64').toString('binary'); + + var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv), + decoded = decipher.update(encryptdata, 'binary', 'utf8'); + + decoded += decipher.final('utf8'); + return decoded; +} + +AES.encrypt = function(cryptkey, iv, cleardata) { + var encipher = crypto.createCipheriv('aes-256-cbc', cryptkey, iv), + encryptdata = encipher.update(cleardata, 'utf8', 'binary'); + + encryptdata += encipher.final('binary'); + encode_encryptdata = new Buffer(encryptdata, 'binary').toString('base64'); + return encode_encryptdata; +} From 709a456ecd6201c3f74f76acf9d332ff6b503a2f Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Thu, 16 Jun 2016 08:14:33 -0400 Subject: [PATCH 012/106] decrypt our first packet --- package.json | 1 + src/createServer.js | 95 +++++++++++++++++---------------------------- 2 files changed, 37 insertions(+), 59 deletions(-) diff --git a/package.json b/package.json index 8835beb..1c2cd02 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "asn1": "^0.2.3", "bn.js": "^4.11.4", "jwt-simple": "^0.5.0", + "lodash.merge": "^4.4.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.0", "raknet": "^1.7.4", diff --git a/src/createServer.js b/src/createServer.js index 845da65..71520c1 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -5,6 +5,7 @@ const ProtoDef = require('protodef').ProtoDef; const jwt = require('jwt-simple'); const crypto = require('crypto'); const Ber = require('asn1').Ber; +const merge=require("lodash.merge"); // const BN = require('bn.js'); const batchProto = new ProtoDef(); @@ -51,7 +52,17 @@ function createServer(options) { server.playerCount = 0; server.on("connection", function(client) { - client.on("mcpe", packet => client.emit(packet.name, packet.params)); + + + //if(encryptionEnabled) { + // client.on('mcpe', packet => { decipher.write(packet); }) + //} else { + client.on("mcpe", packet => { + client.emit(packet.name, packet.params) + }); + //} + + // decipher.on('data', data => console.log(data)) client.on("game_login", packet => { var body = packet.body; @@ -87,16 +98,31 @@ function createServer(options) { ec.generateKeys(); client.sharedSecret = ec.computeSecret(pubKey); - client.secretKeyBytes = crypto.createHash('sha256').update(client.sharedSecret + "SO SECRET VERY SECURE").digest('binary'); - // console.log(client.secretKeyBytes.length); => 32 + client.secretKeyBytes = crypto.createHash('sha256'); + client.secretKeyBytes.update("SO SECRET VERY SECURE"); + client.secretKeyBytes.update(client.sharedSecret) + client.secretKeyBytes = new Buffer(client.secretKeyBytes.digest()) client.writeMCPE('server_to_client_handshake', { publicKey: ec.getPublicKey('base64'), serverToken: "SO SECRET VERY SECURE" // obviously, this is super secure (it's not, change it) }); - + //console.log('secret', new Buffer(client.secretKeyBytes)); + var decipher = crypto.createDecipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); + let customPackets=require("../data/protocol"); + customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe'] = 'restBuffer'; + client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol, customPackets).types); encryptionEnabled = true; - customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe']='restBuffer'; client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol,customPackets).types); + + client.on("mcpe", packet => { + //console.log('THE CONSOLELOG') + //console.log(packet); + //console.log('---------------') + decipher.write(packet); + }); + decipher.on('data', data => console.log('decrypt', data)) + + //client.on('mcpe', packet => { decipher.write(packet); }) client.emit('login', { displayName: client.displayName, @@ -109,23 +135,13 @@ function createServer(options) { }); client.writeMCPE = (name, packet) => { - if (!encryptionEnabled) { - client.writeEncapsulated("mcpe", { - name: name, - params: packet - }); - } else { - sendCounter += 1; - // sendCounter.add(1); - // client.writeEncapsulated("mcpe", { - // name: name, - // params: packet - // }); - } + client.writeEncapsulated("mcpe", { + name: name, + params: packet + }); }; client.writeBatch = function(packets) { - if (!encryptionEnabled) { const payload = zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", packets.map(packet => client.encapsulatedPacketSerializer.createPacketBuffer(packet).slice(1)))); @@ -133,54 +149,15 @@ function createServer(options) { client.writeMCPE("batch", { payload: payload }); - } else { - sendCounter += 1; - // sendCounter.add(1); - // const payload = zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", - // packets.map(packet => - // client.encapsulatedPacketSerializer.createPacketBuffer(packet).slice(1)))); - // - // client.writeMCPE("batch", { - // payload: payload - // }); - } }; client.on('batch', function(packet) { var buf = zlib.inflateSync(packet.payload); var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; - if (!encryptionEnabled) { - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); - } else { - sendCounter += 1; - // sendCounter.add(1); - // packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]),packet]))); - } + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); }); return server; } module.exports = createServer; - -// http://stackoverflow.com/questions/19236327/nodejs-sha256-password-encryption -var AES = {}; - -AES.decrypt = function(cryptkey, iv, encryptdata) { - encryptdata = new Buffer(encryptdata, 'base64').toString('binary'); - - var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv), - decoded = decipher.update(encryptdata, 'binary', 'utf8'); - - decoded += decipher.final('utf8'); - return decoded; -} - -AES.encrypt = function(cryptkey, iv, cleardata) { - var encipher = crypto.createCipheriv('aes-256-cbc', cryptkey, iv), - encryptdata = encipher.update(cleardata, 'utf8', 'binary'); - - encryptdata += encipher.final('binary'); - encode_encryptdata = new Buffer(encryptdata, 'binary').toString('base64'); - return encode_encryptdata; -} From d22a813a2333186a97ea5edc52324d670ec82cc4 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 17 Jun 2016 14:33:55 +0200 Subject: [PATCH 013/106] add decryption test --- package.json | 5 ++++- test/decryption.js | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 test/decryption.js diff --git a/package.json b/package.json index 1c2cd02..bb4aa44 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,10 @@ "raknet": "^1.7.4", "uuid-1345": "^0.99.6" }, - "devDependencies": {}, + "devDependencies": { + "buffer-equal": "^1.0.0", + "mocha": "^2.5.3" + }, "repository": { "type": "git", "url": "git+https://github.com/mhsjlw/pocket-minecraft-protocol.git" diff --git a/test/decryption.js b/test/decryption.js new file mode 100644 index 0000000..af898ee --- /dev/null +++ b/test/decryption.js @@ -0,0 +1,41 @@ +const crypto=require("crypto"); +const assert=require("assert"); +const bufferEqual=require("buffer-equal"); + +// based on https://s.yawk.at/8W5U and https://confluence.yawk.at/display/PEPROTOCOL/Encryption +describe("decryption",() => { + let decipher; + before(() => { + + let secretKeyBytes = new Buffer("ZOBpyzki/M8UZv5tiBih048eYOBVPkQE3r5Fl0gmUP4=","base64"); + + ///// + + let iv = secretKeyBytes.slice(0,16); + + assert(bufferEqual(iv, new Buffer("ZOBpyzki/M8UZv5tiBih0w==","base64"))); + + + decipher = crypto.createDecipheriv('aes-256-cfb8', secretKeyBytes, iv); + }); + + + it("decrypt 1",cb => { + let packet1Encrypted = new Buffer("4B4FCA0C2A4114155D67F8092154AAA5EF","hex"); + decipher.once('data', packet1Decrypted => { + assert(bufferEqual(packet1Decrypted, new Buffer("0400000000499602D2FC2FCB233F34D5DD", "hex"))); + cb(); + }); + decipher.write(packet1Encrypted); + }); + + + it("decrypt 2",cb => { + let packet2Encrypted = new Buffer("DF53B9764DB48252FA1AE3AEE4","hex"); + decipher.once('data', packet2Decrypted => { + assert(bufferEqual(packet2Decrypted,new Buffer("3C000000085A446D11C0C7AA5A","hex"))); + cb(); + }); + decipher.write(packet2Encrypted); + }) +}); \ No newline at end of file From 7cf474a49fd473ce3c5aff06048045643cda0a4a Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 17 Jun 2016 14:55:15 +0200 Subject: [PATCH 014/106] add test for ecdh : values might not be correct --- test/ecdh_key_exchange.js | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/ecdh_key_exchange.js diff --git a/test/ecdh_key_exchange.js b/test/ecdh_key_exchange.js new file mode 100644 index 0000000..db3e88d --- /dev/null +++ b/test/ecdh_key_exchange.js @@ -0,0 +1,42 @@ +const crypto=require("crypto"); +var Ber = require('asn1').Ber; +const assert=require("assert"); +const bufferEqual=require("buffer-equal"); + +// based on https://s.yawk.at/VZSf and https://confluence.yawk.at/display/PEPROTOCOL/Encryption +describe("ecdh key exchange",() => { + it("generate the secret",() => { + + const pubKeyStr = "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEDEKneqEvcqUqqFMM1HM1A4zWjJC+I8Y+aKzG5dl+6wNOHHQ4NmG2PEXRJYhujyodFH+wO0dEr4GM1WoaWog8xsYQ6mQJAC0eVpBM96spUB1eMN56+BwlJ4H3Qx4TAvAs"; + + var reader = new Ber.Reader(new Buffer(pubKeyStr, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); // Hey, I'm an elliptic curve + reader.readOID(); // This contains the curve type, could be useful + +// The first byte is unused, it contains the "number of unused bits in last octet" +// The pubKey should start at "04" which signifies it is an "uncompressed" public key. + var pubKey = new Buffer(reader.readString(Ber.BitString, true)).slice(1); + +// It'd be better to get this from the curve type OID + var server = crypto.createECDH('secp384r1'); +//server.generateKeys(); + server.setPrivateKey("oH53xXsdMRt6VbjlUUggn/QTcUQUqOHcvHl+U1jaGAUe8TP9H3XdKeoqSAKrKBGG", "base64"); + let secret = server.computeSecret(pubKey); + assert(bufferEqual(secret, new Buffer("sM5HvG6efG0RwRe7S+Er9ingxuVzC6HIXmQ1DITVkh4GmX7pboSzbLtaTTNKE8bJ", "base64"))); + + }); + + + it("create the secret key",() => { + let secret=new Buffer("sM5HvG6efG0RwRe7S+Er9ingxuVzC6HIXmQ1DITVkh4GmX7pboSzbLtaTTNKE8bJ", "base64"); + let hash = crypto.createHash('sha256'); + hash.update("SO SECRET VERY SECURE"); + hash.update(secret); + let secretKey = hash.digest(); + + let expected=new Buffer("PN/4NCtRswMTwfpOKRecbMncwxa91Fx4QSUlad46jrc","base64"); + assert(bufferEqual(secretKey,expected),secretKey.toString("base64")+"!="+expected.toString("base64")); + }) +}); \ No newline at end of file From 3dfc5134b6141d03b32cc0777eb84cc8b1fd08a6 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 17 Jun 2016 15:06:22 +0200 Subject: [PATCH 015/106] add checksum test --- test/checksum.js | 33 +++++++++++++++++++++++++++++++++ test/ecdh_key_exchange.js | 1 + 2 files changed, 34 insertions(+) create mode 100644 test/checksum.js diff --git a/test/checksum.js b/test/checksum.js new file mode 100644 index 0000000..3a15dd4 --- /dev/null +++ b/test/checksum.js @@ -0,0 +1,33 @@ +const crypto=require("crypto"); +const assert=require("assert"); +const bufferEqual=require("buffer-equal"); + +function writeLI64(value, buffer, offset) { + buffer.writeInt32LE(value[0], offset+4); + buffer.writeInt32LE(value[1], offset); + return offset + 8; +} + +// based on https://s.yawk.at/QADm and https://confluence.yawk.at/display/PEPROTOCOL/Encryption +describe("checksum",() => { + it("generate hash and checksum",() => { + let packetPlaintext = new Buffer("3C00000008","hex"); + let sendCounter = [0,1]; + let secretKeyBytes = new Buffer("ZOBpyzki/M8UZv5tiBih048eYOBVPkQE3r5Fl0gmUP4=","base64"); + + ///// + + let digest = crypto.createHash('sha256'); + // sendCounter to little-endian byte array + let counter=new Buffer(8); + writeLI64(sendCounter,counter,0); + digest.update(counter); + digest.update(packetPlaintext); + digest.update(secretKeyBytes); + let hash = digest.digest(); + assert(bufferEqual(hash, new Buffer("WkRtEcDHqlqesU6wdSnIz7cU3OCNKVMIsX3aXZMLRjQ=","base64")),hash.toString("base64")); + + let checksum = hash.slice(0,8); + assert(bufferEqual(checksum, new Buffer("5A446D11C0C7AA5A","hex"))); + }) +}); \ No newline at end of file diff --git a/test/ecdh_key_exchange.js b/test/ecdh_key_exchange.js index db3e88d..a0e95b7 100644 --- a/test/ecdh_key_exchange.js +++ b/test/ecdh_key_exchange.js @@ -4,6 +4,7 @@ const assert=require("assert"); const bufferEqual=require("buffer-equal"); // based on https://s.yawk.at/VZSf and https://confluence.yawk.at/display/PEPROTOCOL/Encryption +// and https://github.com/mhsjlw/pocket-minecraft-protocol/issues/15 describe("ecdh key exchange",() => { it("generate the secret",() => { From 549f8dc084c4a5b798cdfd0b1c1963db6a46db56 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 17 Jun 2016 15:07:45 +0200 Subject: [PATCH 016/106] fix secretKeyBytes a bit --- src/createServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/createServer.js b/src/createServer.js index 71520c1..9daafb5 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -101,7 +101,7 @@ function createServer(options) { client.secretKeyBytes = crypto.createHash('sha256'); client.secretKeyBytes.update("SO SECRET VERY SECURE"); client.secretKeyBytes.update(client.sharedSecret) - client.secretKeyBytes = new Buffer(client.secretKeyBytes.digest()) + client.secretKeyBytes = client.secretKeyBytes.digest(); client.writeMCPE('server_to_client_handshake', { publicKey: ec.getPublicKey('base64'), From 7bf93ae68b587052837b874ec08e9c0027c032a9 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 17 Jun 2016 15:19:29 +0200 Subject: [PATCH 017/106] formatting fixes --- src/createServer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 9daafb5..eefb3dd 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -83,7 +83,7 @@ function createServer(options) { var clientDecode = jwt.decode(clientData, nextKey1, 'ES384'); client.randomId = clientDecode.ClientRandomId; client.skinData = clientDecode.SkinData; - client.skinId = clientDecode.SkinId + client.skinId = clientDecode.SkinId; client.identity = decode2.extraData.identity; client.displayName = decode2.extraData.displayName; client.XUID = decode2.extraData.XUID; @@ -100,7 +100,7 @@ function createServer(options) { client.secretKeyBytes = crypto.createHash('sha256'); client.secretKeyBytes.update("SO SECRET VERY SECURE"); - client.secretKeyBytes.update(client.sharedSecret) + client.secretKeyBytes.update(client.sharedSecret); client.secretKeyBytes = client.secretKeyBytes.digest(); client.writeMCPE('server_to_client_handshake', { @@ -120,7 +120,7 @@ function createServer(options) { //console.log('---------------') decipher.write(packet); }); - decipher.on('data', data => console.log('decrypt', data)) + decipher.on('data', data => console.log('decrypt', data)); //client.on('mcpe', packet => { decipher.write(packet); }) From 6478e625ec01abac03e120bfafd7e95e0ebce4e0 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 17 Jun 2016 15:39:36 +0200 Subject: [PATCH 018/106] read/write X509 properly, fix decrypt --- src/createServer.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index eefb3dd..10fd24d 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -51,6 +51,27 @@ function createServer(options) { server.maxPlayers = options['max-players'] || 20; server.playerCount = 0; + function readX509PublicKey(key) { + var reader = new Ber.Reader(new Buffer(key, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); + reader.readOID(); + return new Buffer(reader.readString(Ber.BitString, true)).slice(1); + } + + function writeX509PublicKey(key) { + var writer = new Ber.Writer(); + writer.startSequence(); + writer.startSequence(); + writer.writeOID("1.2.840.10045.2.1"); + writer.writeOID("1.3.132.0.34"); + writer.endSequence(); + writer.writeBuffer(Buffer.concat([new Buffer([0x00]),key]),Ber.BitString); + writer.endSequence(); + return writer.buffer.toString("base64"); + } + server.on("connection", function(client) { @@ -88,23 +109,20 @@ function createServer(options) { client.displayName = decode2.extraData.displayName; client.XUID = decode2.extraData.XUID; - var reader = new Ber.Reader(new Buffer(nextKey2, "base64")); - reader.readSequence(); - reader.readSequence(); - reader.readOID(); - reader.readOID(); - var pubKey = new Buffer(reader.readString(Ber.BitString, true)).slice(1); + + var pubKeyClient = readX509PublicKey(nextKey2); var ec = crypto.createECDH('secp384r1'); ec.generateKeys(); - client.sharedSecret = ec.computeSecret(pubKey); + client.sharedSecret = ec.computeSecret(pubKeyClient); client.secretKeyBytes = crypto.createHash('sha256'); client.secretKeyBytes.update("SO SECRET VERY SECURE"); client.secretKeyBytes.update(client.sharedSecret); client.secretKeyBytes = client.secretKeyBytes.digest(); + let pubKeyServer=writeX509PublicKey(ec.getPublicKey()); client.writeMCPE('server_to_client_handshake', { - publicKey: ec.getPublicKey('base64'), + publicKey: pubKeyServer, serverToken: "SO SECRET VERY SECURE" // obviously, this is super secure (it's not, change it) }); //console.log('secret', new Buffer(client.secretKeyBytes)); From b86eb6a80f3266de769ad7fcec44ce3f1ecdd6c4 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 18 Jun 2016 13:07:13 +0200 Subject: [PATCH 019/106] add rest of the parsing pipeline. Works but the client is sending unparsable packet in a batch --- src/createServer.js | 58 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 10fd24d..38c9639 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -2,10 +2,12 @@ const raknet = require('raknet'); const zlib = require('zlib'); const ProtoDef = require('protodef').ProtoDef; +const Parser = require('protodef').Parser; const jwt = require('jwt-simple'); const crypto = require('crypto'); const Ber = require('asn1').Ber; const merge=require("lodash.merge"); +const assert=require("assert"); // const BN = require('bn.js'); const batchProto = new ProtoDef(); @@ -29,6 +31,10 @@ dataProto.addType("data_chain", ["container", [{ }] }]]); + +const Transform = require('stream').Transform; + + const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; var encryptionEnabled = false; var sendCounter = 0; @@ -74,11 +80,13 @@ function createServer(options) { server.on("connection", function(client) { + client.counter=0; //if(encryptionEnabled) { // client.on('mcpe', packet => { decipher.write(packet); }) //} else { client.on("mcpe", packet => { + console.log("actual mcpe",packet); client.emit(packet.name, packet.params) }); //} @@ -127,12 +135,13 @@ function createServer(options) { }); //console.log('secret', new Buffer(client.secretKeyBytes)); var decipher = crypto.createDecipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); - let customPackets=require("../data/protocol"); - customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe'] = 'restBuffer'; + let customPackets=JSON.parse(JSON.stringify(require("../data/protocol"))); + customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe_encrypted'] = 'restBuffer'; + customPackets['types']['encapsulated_packet'][1][0]['type'][1]['mappings']['0xfe'] = 'mcpe_encrypted'; client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol, customPackets).types); encryptionEnabled = true; - client.on("mcpe", packet => { + client.on("mcpe_encrypted", packet => { //console.log('THE CONSOLELOG') //console.log(packet); //console.log('---------------') @@ -140,6 +149,48 @@ function createServer(options) { }); decipher.on('data', data => console.log('decrypt', data)); + + function writeLI64(value, buffer, offset) { + buffer.writeInt32LE(value[0], offset+4); + buffer.writeInt32LE(value[1], offset); + return offset + 8; + } + + function computeCheckSum(packetPlaintext,sendCounter,secretKeyBytes) { + let digest = crypto.createHash('sha256'); + let counter=new Buffer(8); + writeLI64(sendCounter,counter,0); + digest.update(counter); + digest.update(packetPlaintext); + digest.update(secretKeyBytes); + let hash = digest.digest(); + + return hash.slice(0,8); + } + + + const checksumTransform = new Transform({ + transform(chunk,enc,cb) { + const packet=chunk.slice(0,chunk.length-8); + const checksum=chunk.slice(chunk.length-8); + const computedCheckSum=computeCheckSum(packet,[0,client.counter],client.secretKeyBytes); + const pass=checksum.toString("hex")==computedCheckSum.toString("hex"); + //assert.equal(checksum.toString("hex"),computedCheckSum.toString("hex")); + client.counter++; + if(pass) this.push(packet); + cb(); + } + }); + checksumTransform.on("data",data => console.log('sliced',data)); + decipher.pipe(checksumTransform); + const proto=new ProtoDef(); + proto.addTypes(require("./datatypes/minecraft")); + proto.addTypes(require("../data/protocol").types); + const mcpePacketParser=new Parser(proto,"mcpe_packet"); + checksumTransform.pipe(mcpePacketParser); + mcpePacketParser.on("data",parsed => console.log("parsed data",parsed)); + mcpePacketParser.on("data",parsed => client.emitPacket(parsed)); + //client.on('mcpe', packet => { decipher.write(packet); }) client.emit('login', { @@ -171,6 +222,7 @@ function createServer(options) { client.on('batch', function(packet) { var buf = zlib.inflateSync(packet.payload); + console.log("in batch",buf); var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); From 2c6ee7615263bf71eed3bdf2ef4c026ba65ae1a9 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 18 Jun 2016 14:37:23 +0200 Subject: [PATCH 020/106] client_to_server_handshake doesn't have the magic --- data/protocol.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 41e454c..2e0e36d 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -730,10 +730,6 @@ "packet_client_to_server_handshake": [ "container", [ - { - "name": "magic", - "type": "i64" - } ] ], "packet_game_login": [ From 2e1e3f8bb24b395c9170e314614baa0c05adf2ed Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 18 Jun 2016 14:37:37 +0200 Subject: [PATCH 021/106] update raknet --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb4aa44..e4d8237 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lodash.merge": "^4.4.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.0", - "raknet": "^1.7.4", + "raknet": "^1.8.0", "uuid-1345": "^0.99.6" }, "devDependencies": { From 66111dad542708bc029ee2f08ddbbe2abff08ef6 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 18 Jun 2016 14:58:17 +0200 Subject: [PATCH 022/106] encryption + complete example. The ideas are there, but it doesn't seems to be accepted by the client yet --- examples/server.js | 91 +++++++++++++++++-- examples/server_simple.js | 31 +++++++ src/createServer.js | 180 ++++++++++++++++++++++---------------- 3 files changed, 222 insertions(+), 80 deletions(-) create mode 100644 examples/server_simple.js diff --git a/examples/server.js b/examples/server.js index 9773f2c..42a3691 100644 --- a/examples/server.js +++ b/examples/server.js @@ -15,17 +15,96 @@ var server = pmp.createServer({ }); server.on('connection', function(client) { - client.on("mcpe", packet => console.log(packet)); - client.on("login", data => { - console.log(client.displayName + '(' + client.XUID + ') ' + ' joined the game'); + + client.on("mcpe",packet => console.log(packet)); + + client.on("login",packet => { + console.log("aaaaa"); + + client.writeMCPE("player_status",{ + status:0 + }); +/* + client.writeMCPE('move_player', { + entityId: [0,0], + x: 1, + y: 64 + 1.62, + z: 1, + yaw: 0, + headYaw: 0, + pitch: 0, + mode: 0, + onGround: 1 + }); + + client.writeMCPE("start_game",{ + seed:-1, + dimension:0, + generator:1, + gamemode:1, + entityId:[0,0], + spawnX:1, + spawnY:1, + spawnZ:1, + x:0, + y:1+1.62, + z:0, + isLoadedInCreative:0, + dayCycleStopTime:0, + eduMode:0, + unknown:"" + });*/ +/* + client.writeMCPE('set_spawn_position', { + x: 1, + y: 64, + z: 1 + }); + client.writeMCPE("set_time",{ + time:0, + started:1 + }); + + client.writeMCPE('respawn', { + x: 1, + y: 64, + z: 1 + });*/ }); - client.on('error', err => { + client.on("request_chunk_radius",() => { + client.writeMCPE('chunk_radius_update',{ + chunk_radius:1 + }); + + for (let x = -1; x <=1; x++) { + for (let z = -1; z <=1; z++) { + client.writeBatch([{"name":"mcpe","params":{name:"full_chunk_data",params:{ + chunkX: x, + chunkZ: z, + order: 1, + chunkData:fs.readFileSync(__dirname+"/chunk") + }}}]); + } + } + + client.writeMCPE('player_status', { + status: 3 + }); + + client.writeMCPE('set_time', { + time: 0, + started: 1 + }); + + }); + + client.on('error', function(err) { console.log(err.stack); }); - client.on('end', () => { + client.on('end',function() { console.log("client left"); }) -}); +}); \ No newline at end of file diff --git a/examples/server_simple.js b/examples/server_simple.js new file mode 100644 index 0000000..9773f2c --- /dev/null +++ b/examples/server_simple.js @@ -0,0 +1,31 @@ +'use strict'; + +var pmp = require('../'); +var fs = require("fs"); + +if(process.argv.length !=4) { + console.log("Usage: node server.js "); + process.exit(1); +} + +var server = pmp.createServer({ + host: process.argv[2], + port: parseInt(process.argv[3]), + name: 'MCPE;Minecraft: PE Server;81 81;0.15.0;0;20' +}); + +server.on('connection', function(client) { + client.on("mcpe", packet => console.log(packet)); + + client.on("login", data => { + console.log(client.displayName + '(' + client.XUID + ') ' + ' joined the game'); + }); + + client.on('error', err => { + console.log(err.stack); + }); + + client.on('end', () => { + console.log("client left"); + }) +}); diff --git a/src/createServer.js b/src/createServer.js index 38c9639..ade4d26 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -3,11 +3,13 @@ const raknet = require('raknet'); const zlib = require('zlib'); const ProtoDef = require('protodef').ProtoDef; const Parser = require('protodef').Parser; +const Serializer = require('protodef').Serializer; const jwt = require('jwt-simple'); const crypto = require('crypto'); const Ber = require('asn1').Ber; const merge=require("lodash.merge"); const assert=require("assert"); +var debug = require('debug')("raknet"); // const BN = require('bn.js'); const batchProto = new ProtoDef(); @@ -32,12 +34,50 @@ dataProto.addType("data_chain", ["container", [{ }]]); +function writeLI64(value, buffer, offset) { + buffer.writeInt32LE(value[0], offset+4); + buffer.writeInt32LE(value[1], offset); + return offset + 8; +} + +function computeCheckSum(packetPlaintext,sendCounter,secretKeyBytes) { + let digest = crypto.createHash('sha256'); + let counter=new Buffer(8); + writeLI64(sendCounter,counter,0); + digest.update(counter); + digest.update(packetPlaintext); + digest.update(secretKeyBytes); + let hash = digest.digest(); + + return hash.slice(0,8); +} + + +function readX509PublicKey(key) { + var reader = new Ber.Reader(new Buffer(key, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); + reader.readOID(); + return new Buffer(reader.readString(Ber.BitString, true)).slice(1); +} + +function writeX509PublicKey(key) { + var writer = new Ber.Writer(); + writer.startSequence(); + writer.startSequence(); + writer.writeOID("1.2.840.10045.2.1"); + writer.writeOID("1.3.132.0.34"); + writer.endSequence(); + writer.writeBuffer(Buffer.concat([new Buffer([0x00]),key]),Ber.BitString); + writer.endSequence(); + return writer.buffer.toString("base64"); +} + const Transform = require('stream').Transform; const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; -var encryptionEnabled = false; -var sendCounter = 0; function createServer(options) { options = options || {}; @@ -57,41 +97,19 @@ function createServer(options) { server.maxPlayers = options['max-players'] || 20; server.playerCount = 0; - function readX509PublicKey(key) { - var reader = new Ber.Reader(new Buffer(key, "base64")); - reader.readSequence(); - reader.readSequence(); - reader.readOID(); - reader.readOID(); - return new Buffer(reader.readString(Ber.BitString, true)).slice(1); - } - - function writeX509PublicKey(key) { - var writer = new Ber.Writer(); - writer.startSequence(); - writer.startSequence(); - writer.writeOID("1.2.840.10045.2.1"); - writer.writeOID("1.3.132.0.34"); - writer.endSequence(); - writer.writeBuffer(Buffer.concat([new Buffer([0x00]),key]),Ber.BitString); - writer.endSequence(); - return writer.buffer.toString("base64"); - } server.on("connection", function(client) { - client.counter=0; + client.receiveCounter=0; + client.sendCounter=0; + + client.encryptionEnabled = false; - //if(encryptionEnabled) { - // client.on('mcpe', packet => { decipher.write(packet); }) - //} else { client.on("mcpe", packet => { console.log("actual mcpe",packet); client.emit(packet.name, packet.params) }); - //} - // decipher.on('data', data => console.log(data)) client.on("game_login", packet => { var body = packet.body; @@ -133,81 +151,68 @@ function createServer(options) { publicKey: pubKeyServer, serverToken: "SO SECRET VERY SECURE" // obviously, this is super secure (it's not, change it) }); - //console.log('secret', new Buffer(client.secretKeyBytes)); var decipher = crypto.createDecipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); let customPackets=JSON.parse(JSON.stringify(require("../data/protocol"))); customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe_encrypted'] = 'restBuffer'; customPackets['types']['encapsulated_packet'][1][0]['type'][1]['mappings']['0xfe'] = 'mcpe_encrypted'; client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol, customPackets).types); - encryptionEnabled = true; + client.encryptionEnabled = true; client.on("mcpe_encrypted", packet => { - //console.log('THE CONSOLELOG') - //console.log(packet); - //console.log('---------------') + console.log("raw",packet); decipher.write(packet); }); decipher.on('data', data => console.log('decrypt', data)); - - function writeLI64(value, buffer, offset) { - buffer.writeInt32LE(value[0], offset+4); - buffer.writeInt32LE(value[1], offset); - return offset + 8; - } - - function computeCheckSum(packetPlaintext,sendCounter,secretKeyBytes) { - let digest = crypto.createHash('sha256'); - let counter=new Buffer(8); - writeLI64(sendCounter,counter,0); - digest.update(counter); - digest.update(packetPlaintext); - digest.update(secretKeyBytes); - let hash = digest.digest(); - - return hash.slice(0,8); - } + client.cipher=crypto.createCipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); const checksumTransform = new Transform({ transform(chunk,enc,cb) { const packet=chunk.slice(0,chunk.length-8); const checksum=chunk.slice(chunk.length-8); - const computedCheckSum=computeCheckSum(packet,[0,client.counter],client.secretKeyBytes); - const pass=checksum.toString("hex")==computedCheckSum.toString("hex"); + const computedCheckSum=computeCheckSum(packet,[0,client.receiveCounter],client.secretKeyBytes); //assert.equal(checksum.toString("hex"),computedCheckSum.toString("hex")); - client.counter++; - if(pass) this.push(packet); + client.receiveCounter++; + if(checksum.toString("hex")==computedCheckSum.toString("hex")) this.push(packet); cb(); } }); + client.addChecksumTransform = new Transform({ + transform(chunk,enc,cb) { + const packet=Buffer.concat([chunk,computeCheckSum(chunk,[0,client.sendCounter],client.secretKeyBytes)]); + client.sendCounter++; + this.push(packet); + cb(); + } + }); + + checksumTransform.on("data",data => console.log('sliced',data)); decipher.pipe(checksumTransform); const proto=new ProtoDef(); proto.addTypes(require("./datatypes/minecraft")); proto.addTypes(require("../data/protocol").types); - const mcpePacketParser=new Parser(proto,"mcpe_packet"); - checksumTransform.pipe(mcpePacketParser); - mcpePacketParser.on("data",parsed => console.log("parsed data",parsed)); - mcpePacketParser.on("data",parsed => client.emitPacket(parsed)); + client.mcpePacketParser=new Parser(proto,"mcpe_packet"); + client.mcpePacketSerializer=new Serializer(proto,"mcpe_packet"); + checksumTransform.pipe(client.mcpePacketParser); + client.mcpePacketParser.on("data",parsed => console.log("parsed data",parsed)); + client.mcpePacketParser.on("data",parsed => {if(parsed.data.name=="batch") parsed.data.name="batch_non_encrypted"; return client.emitPacket(parsed)}); - //client.on('mcpe', packet => { decipher.write(packet); }) - client.emit('login', { - displayName: client.displayName, - randomId: client.randomId, - skinData: client.skinData, - skinId: client.skinId, - identity: client.identity, - XUID: client.XUID - }); + client.mcpePacketSerializer.pipe(client.addChecksumTransform); + client.addChecksumTransform.pipe(client.cipher); }); - client.writeMCPE = (name, packet) => { - client.writeEncapsulated("mcpe", { - name: name, - params: packet - }); + client.writeMCPE = (name, params) => { + if(client.encryptionEnabled) { + client.mcpePacketSerializer.write({ name, params }); + client.cipher.on('data', data => console.log("crypted",data)); + client.cipher.on('data', data => client.writeEncapsulated("mcpe_encrypted", data)); + } + else { + client.writeEncapsulated("mcpe", { name, params }); + } }; client.writeBatch = function(packets) { @@ -222,10 +227,37 @@ function createServer(options) { client.on('batch', function(packet) { var buf = zlib.inflateSync(packet.payload); - console.log("in batch",buf); var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); + + client.on('client_to_server_handshake',() => { + console.log("plop"); + client.emit('login', { + displayName: client.displayName, + randomId: client.randomId, + skinData: client.skinData, + skinId: client.skinId, + identity: client.identity, + XUID: client.XUID + }); + }); + + + client.on('batch_non_encrypted', function(packet) { + var buf = zlib.inflateSync(packet.payload); + var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; + packets.forEach(packet => { + try { + debug("handle mcpe",packet); + var r = client.mcpePacketParser.parsePacketBuffer(packet); + client.emitPacket(r); + } + catch(err) { + client.emit("error",err); + } + }); + }); }); return server; } From d040667bc0dc97aec3214ef2b413be61756a4ad4 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 18 Jun 2016 15:51:41 +0200 Subject: [PATCH 023/106] spawns ! --- examples/server.js | 18 ++++++++---------- examples/server_simple.js | 2 +- src/createServer.js | 17 ++++++----------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/examples/server.js b/examples/server.js index 42a3691..50d4a8a 100644 --- a/examples/server.js +++ b/examples/server.js @@ -19,13 +19,11 @@ server.on('connection', function(client) { client.on("mcpe",packet => console.log(packet)); - client.on("login",packet => { - console.log("aaaaa"); - + client.on("login_mcpe",packet => { client.writeMCPE("player_status",{ status:0 }); -/* + client.writeMCPE('move_player', { entityId: [0,0], x: 1, @@ -54,8 +52,8 @@ server.on('connection', function(client) { dayCycleStopTime:0, eduMode:0, unknown:"" - });*/ -/* + }); + client.writeMCPE('set_spawn_position', { x: 1, y: 64, @@ -70,22 +68,22 @@ server.on('connection', function(client) { x: 1, y: 64, z: 1 - });*/ + }); }); - client.on("request_chunk_radius",() => { + client.on("chunk_radius_update",() => { client.writeMCPE('chunk_radius_update',{ chunk_radius:1 }); for (let x = -1; x <=1; x++) { for (let z = -1; z <=1; z++) { - client.writeBatch([{"name":"mcpe","params":{name:"full_chunk_data",params:{ + client.writeBatch([{name:"full_chunk_data",params:{ chunkX: x, chunkZ: z, order: 1, chunkData:fs.readFileSync(__dirname+"/chunk") - }}}]); + }}]); } } diff --git a/examples/server_simple.js b/examples/server_simple.js index 9773f2c..1cf2e15 100644 --- a/examples/server_simple.js +++ b/examples/server_simple.js @@ -17,7 +17,7 @@ var server = pmp.createServer({ server.on('connection', function(client) { client.on("mcpe", packet => console.log(packet)); - client.on("login", data => { + client.on("login_mcpe", data => { console.log(client.displayName + '(' + client.XUID + ') ' + ' joined the game'); }); diff --git a/src/createServer.js b/src/createServer.js index ade4d26..3a74b5c 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -106,7 +106,6 @@ function createServer(options) { client.encryptionEnabled = false; client.on("mcpe", packet => { - console.log("actual mcpe",packet); client.emit(packet.name, packet.params) }); @@ -159,10 +158,8 @@ function createServer(options) { client.encryptionEnabled = true; client.on("mcpe_encrypted", packet => { - console.log("raw",packet); decipher.write(packet); }); - decipher.on('data', data => console.log('decrypt', data)); client.cipher=crypto.createCipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); @@ -172,7 +169,7 @@ function createServer(options) { const packet=chunk.slice(0,chunk.length-8); const checksum=chunk.slice(chunk.length-8); const computedCheckSum=computeCheckSum(packet,[0,client.receiveCounter],client.secretKeyBytes); - //assert.equal(checksum.toString("hex"),computedCheckSum.toString("hex")); + assert.equal(checksum.toString("hex"),computedCheckSum.toString("hex")); client.receiveCounter++; if(checksum.toString("hex")==computedCheckSum.toString("hex")) this.push(packet); cb(); @@ -188,7 +185,6 @@ function createServer(options) { }); - checksumTransform.on("data",data => console.log('sliced',data)); decipher.pipe(checksumTransform); const proto=new ProtoDef(); proto.addTypes(require("./datatypes/minecraft")); @@ -196,19 +192,19 @@ function createServer(options) { client.mcpePacketParser=new Parser(proto,"mcpe_packet"); client.mcpePacketSerializer=new Serializer(proto,"mcpe_packet"); checksumTransform.pipe(client.mcpePacketParser); - client.mcpePacketParser.on("data",parsed => console.log("parsed data",parsed)); client.mcpePacketParser.on("data",parsed => {if(parsed.data.name=="batch") parsed.data.name="batch_non_encrypted"; return client.emitPacket(parsed)}); client.mcpePacketSerializer.pipe(client.addChecksumTransform); client.addChecksumTransform.pipe(client.cipher); + + client.cipher.on('data', data => client.writeEncapsulated("mcpe_encrypted", data)); }); client.writeMCPE = (name, params) => { if(client.encryptionEnabled) { + debug("write mcpe",name,params); client.mcpePacketSerializer.write({ name, params }); - client.cipher.on('data', data => console.log("crypted",data)); - client.cipher.on('data', data => client.writeEncapsulated("mcpe_encrypted", data)); } else { client.writeEncapsulated("mcpe", { name, params }); @@ -218,7 +214,7 @@ function createServer(options) { client.writeBatch = function(packets) { const payload = zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", packets.map(packet => - client.encapsulatedPacketSerializer.createPacketBuffer(packet).slice(1)))); + client.mcpePacketSerializer.createPacketBuffer(packet)))); client.writeMCPE("batch", { payload: payload @@ -232,8 +228,7 @@ function createServer(options) { }); client.on('client_to_server_handshake',() => { - console.log("plop"); - client.emit('login', { + client.emit('login_mcpe', { displayName: client.displayName, randomId: client.randomId, skinData: client.skinData, From 315e32d634debe54b74de6e5df5fdf10df843235 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Tue, 21 Jun 2016 03:02:44 +0200 Subject: [PATCH 024/106] string of start_game is worldName (according to Intyre) --- data/protocol.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/protocol.json b/data/protocol.json index 2e0e36d..92a416c 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -903,7 +903,7 @@ "type": "bool" }, { - "name": "unknown", + "name": "worldName", "type": "string" } ] From d8ee61b7db471574adcdc474a841627f95577225 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Tue, 21 Jun 2016 03:03:52 +0200 Subject: [PATCH 025/106] worldName in server.js --- examples/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server.js b/examples/server.js index 50d4a8a..7116391 100644 --- a/examples/server.js +++ b/examples/server.js @@ -51,7 +51,7 @@ server.on('connection', function(client) { isLoadedInCreative:0, dayCycleStopTime:0, eduMode:0, - unknown:"" + worldName:"" }); client.writeMCPE('set_spawn_position', { @@ -105,4 +105,4 @@ server.on('connection', function(client) { client.on('end',function() { console.log("client left"); }) -}); \ No newline at end of file +}); From 78cfd29aab4a31d6aa942aa0df2c98fda65c1b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 23 Jun 2016 04:12:09 +0200 Subject: [PATCH 026/106] Update protocol.json --- data/protocol.json | 99 ++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 92a416c..c262ca3 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -567,63 +567,68 @@ { "type": "u8", "mappings": { - "0x03": "server_to_client_handshake", - "0x04": "client_to_server_handshake", "0x01": "game_login", "0x02": "player_status", + "0x03": "server_to_client_handshake", + "0x04": "client_to_server_handshake", "0x05": "disconnect", "0x06": "batch", "0x07": "text", "0x08": "set_time", "0x09": "start_game", "0x0a": "add_player", - "0x0b": "remove_player", - "0x0c": "add_entity", - "0x0d": "remove_entity", - "0x0e": "add_item_entity", - "0x0f": "take_item_entity", - "0x10": "move_entity", - "0x11": "move_player", + "0x0b": "add_entity", + "0x0c": "remove_entity", + "0x0d": "add_item_entity", + "0x0e": "take_item_entity", + "0x0f": "move_entity", + "0x10": "move_player", + "0x11": "rider_jump", "0x12": "remove_block", "0x13": "update_block", "0x14": "add_painting", "0x15": "explode", "0x16": "level_event", - "0x17": "tile_event", + "0x17": "block_event", "0x18": "entity_event", "0x19": "mob_effect", "0x1a": "update_attributes", - "0x1b": "player_equipment", - "0x1c": "player_armor_equipment", + "0x1b": "mob_equipment", + "0x1c": "mob_armor_equipment", "0x1d": "interact", - "0x1e": "use_item", - "0x1f": "player_action", - "0x20": "hurt_armor", - "0x21": "set_entity_data", - "0x22": "set_entity_motion", - "0x23": "set_entity_link", - "0x24": "set_health", - "0x25": "set_spawn_position", - "0x26": "animate", - "0x27": "respawn", - "0x28": "drop_item", - "0x29": "container_open", - "0x2a": "container_close", - "0x2b": "container_set_slot", - "0x2c": "container_set_data", - "0x2d": "container_set_content", - "0x2e": "crafting_data", - "0x2f": "crafting_event", - "0x30": "adventure_settings", - "0x31": "tile_entity_data", - "0x32": "player_input", - "0x33": "full_chunk_data", - "0x34": "set_difficulty", - "0x37": "player_list", - "0x3c": "request_chunk_radius", - "0x3d": "chunk_radius_update", + "0x1f": "use_item", + "0x20": "player_action", + "0x21": "hurt_armor", + "0x22": "set_entity_data", + "0x23": "set_entity_motion", + "0x24": "set_entity_link", + "0x25": "set_health", + "0x26": "set_spawn_position", + "0x27": "animate", + "0x28": "respawn", + "0x29": "drop_item", + "0x2a": "container_open", + "0x2b": "container_close", + "0x2c": "container_set_slot", + "0x2d": "container_set_data", + "0x2e": "container_set_content", + "0x2f": "crafting_data", + "0x30": "crafting_event", + "0x31": "adventure_settings", + "0x32": "block_entity_data", + "0x33": "player_input", + "0x34": "full_chunk_data", + "0x35": "set_difficulty", + "0x36": "change_dimension", + "0x37": "set_player_gametype", + "0x38": "player_list", + "0x39": "telemetry_event", "0x3a": "spawn_experience_orb", - "0x3f": "replace_selected_item" + "0x3d": "request_chunk_radius", + "0x3e": "chunk_radius_update", + "0x3f": "item_frame_drop_item", + "0x40": "replace_selected_item", + "0x41": "add_item_item" } } ] @@ -657,12 +662,12 @@ "add_painting": "packet_add_painting", "explode": "packet_explode", "level_event": "packet_level_event", - "tile_event": "packet_tile_event", + "block_event": "packet_block_event", "entity_event": "packet_entity_event", "mob_effect": "packet_mob_effect", "update_attributes": "packet_update_attributes", - "player_equipment": "packet_player_equipment", - "player_armor_equipment": "packet_player_armor_equipment", + "mob_equipment": "packet_mob_equipment", + "mob_armor_equipment": "packet_mob_armor_equipment", "interact": "packet_interact", "use_item": "packet_use_item", "player_action": "packet_player_action", @@ -683,7 +688,7 @@ "crafting_data": "packet_crafting_data", "crafting_event": "packet_crafting_event", "adventure_settings": "packet_adventure_settings", - "tile_entity_data": "packet_tile_entity_data", + "block_entity_data": "packet_block_entity_data", "full_chunk_data": "packet_full_chunk_data", "set_difficulty": "packet_set_difficulty", "player_list": "packet_player_list", @@ -1253,7 +1258,7 @@ } ] ], - "packet_tile_event": [ + "packet_block_event": [ "container", [ { @@ -1333,7 +1338,7 @@ } ] ], - "packet_player_equipment": [ + "packet_mob_equipment": [ "container", [ { @@ -1354,7 +1359,7 @@ } ] ], - "packet_player_armor_equipment": [ + "packet_mob_armor_equipment": [ "container", [ { @@ -1769,7 +1774,7 @@ } ] ], - "packet_tile_entity_data": [ + "packet_block_entity_data": [ "container", [ { From 947a5e0872caabe861322df2d82d09013668b9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 23 Jun 2016 20:53:19 +0200 Subject: [PATCH 027/106] Update createServer.js --- src/createServer.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 3a74b5c..60904e3 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -118,31 +118,21 @@ function createServer(options) { var clientData = parsed.data.clientData; var chain1 = parsed.data.chain.chain[0]; - var chain2 = parsed.data.chain.chain[1].replace('\n', ''); + var chain2 = parsed.data.chain.chain[1]; var decode1 = jwt.decode(chain1, PUBLIC_KEY, 'ES384'); var nextKey1 = decode1.identityPublicKey; - var decode2 = jwt.decode(chain2, nextKey1, 'ES384'); - var nextKey2 = decode2.identityPublicKey; - var clientDecode = jwt.decode(clientData, nextKey1, 'ES384'); client.randomId = clientDecode.ClientRandomId; client.skinData = clientDecode.SkinData; client.skinId = clientDecode.SkinId; - client.identity = decode2.extraData.identity; - client.displayName = decode2.extraData.displayName; - client.XUID = decode2.extraData.XUID; - - var pubKeyClient = readX509PublicKey(nextKey2); var ec = crypto.createECDH('secp384r1'); ec.generateKeys(); - client.sharedSecret = ec.computeSecret(pubKeyClient); client.secretKeyBytes = crypto.createHash('sha256'); - client.secretKeyBytes.update("SO SECRET VERY SECURE"); - client.secretKeyBytes.update(client.sharedSecret); + client.secretKeyBytes.update("SO SECRET VERY SECURE");; client.secretKeyBytes = client.secretKeyBytes.digest(); let pubKeyServer=writeX509PublicKey(ec.getPublicKey()); From 82fba41ae15a4869a1e70a2d3225bc436e1e2189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 23 Jun 2016 22:03:37 +0200 Subject: [PATCH 028/106] Update createServer.js --- src/createServer.js | 91 ++++----------------------------------------- 1 file changed, 7 insertions(+), 84 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 60904e3..1dec6a0 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -105,95 +105,18 @@ function createServer(options) { client.encryptionEnabled = false; + let proto = new ProtoDef(); + proto.addTypes(require("./datatypes/minecraft")); + proto.addTypes(require("../data/protocol").types); + client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); + client.on("mcpe", packet => { client.emit(packet.name, packet.params) }); - - - client.on("game_login", packet => { - var body = packet.body; - var body2 = zlib.inflateSync(body); - var parsed = dataProto.parsePacketBuffer("data_chain", body2); - parsed.data.chain = JSON.parse(parsed.data.chain); - - var clientData = parsed.data.clientData; - var chain1 = parsed.data.chain.chain[0]; - var chain2 = parsed.data.chain.chain[1]; - - var decode1 = jwt.decode(chain1, PUBLIC_KEY, 'ES384'); - var nextKey1 = decode1.identityPublicKey; - - var clientDecode = jwt.decode(clientData, nextKey1, 'ES384'); - client.randomId = clientDecode.ClientRandomId; - client.skinData = clientDecode.SkinData; - client.skinId = clientDecode.SkinId; - - var ec = crypto.createECDH('secp384r1'); - ec.generateKeys(); - - client.secretKeyBytes = crypto.createHash('sha256'); - client.secretKeyBytes.update("SO SECRET VERY SECURE");; - client.secretKeyBytes = client.secretKeyBytes.digest(); - - let pubKeyServer=writeX509PublicKey(ec.getPublicKey()); - client.writeMCPE('server_to_client_handshake', { - publicKey: pubKeyServer, - serverToken: "SO SECRET VERY SECURE" // obviously, this is super secure (it's not, change it) - }); - var decipher = crypto.createDecipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); - let customPackets=JSON.parse(JSON.stringify(require("../data/protocol"))); - customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe_encrypted'] = 'restBuffer'; - customPackets['types']['encapsulated_packet'][1][0]['type'][1]['mappings']['0xfe'] = 'mcpe_encrypted'; - client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol, customPackets).types); - client.encryptionEnabled = true; - - client.on("mcpe_encrypted", packet => { - decipher.write(packet); - }); - - client.cipher=crypto.createCipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0,16)); - - - const checksumTransform = new Transform({ - transform(chunk,enc,cb) { - const packet=chunk.slice(0,chunk.length-8); - const checksum=chunk.slice(chunk.length-8); - const computedCheckSum=computeCheckSum(packet,[0,client.receiveCounter],client.secretKeyBytes); - assert.equal(checksum.toString("hex"),computedCheckSum.toString("hex")); - client.receiveCounter++; - if(checksum.toString("hex")==computedCheckSum.toString("hex")) this.push(packet); - cb(); - } - }); - client.addChecksumTransform = new Transform({ - transform(chunk,enc,cb) { - const packet=Buffer.concat([chunk,computeCheckSum(chunk,[0,client.sendCounter],client.secretKeyBytes)]); - client.sendCounter++; - this.push(packet); - cb(); - } - }); - - - decipher.pipe(checksumTransform); - const proto=new ProtoDef(); - proto.addTypes(require("./datatypes/minecraft")); - proto.addTypes(require("../data/protocol").types); - client.mcpePacketParser=new Parser(proto,"mcpe_packet"); - client.mcpePacketSerializer=new Serializer(proto,"mcpe_packet"); - checksumTransform.pipe(client.mcpePacketParser); - client.mcpePacketParser.on("data",parsed => {if(parsed.data.name=="batch") parsed.data.name="batch_non_encrypted"; return client.emitPacket(parsed)}); - - - client.mcpePacketSerializer.pipe(client.addChecksumTransform); - client.addChecksumTransform.pipe(client.cipher); - - client.cipher.on('data', data => client.writeEncapsulated("mcpe_encrypted", data)); - }); - + client.writeMCPE = (name, params) => { if(client.encryptionEnabled) { - debug("write mcpe",name,params); + debug("write mcpe", name, params); client.mcpePacketSerializer.write({ name, params }); } else { From 5b1f1ab1627b45856d45ea4edb1945c2d0bd729e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 23 Jun 2016 22:03:52 +0200 Subject: [PATCH 029/106] Update protocol.json --- data/protocol.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/protocol.json b/data/protocol.json index c262ca3..340f0dc 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -689,6 +689,7 @@ "crafting_event": "packet_crafting_event", "adventure_settings": "packet_adventure_settings", "block_entity_data": "packet_block_entity_data", + "player_input": "packet_player_input", "full_chunk_data": "packet_full_chunk_data", "set_difficulty": "packet_set_difficulty", "player_list": "packet_player_list", From b4ed008d647a7f9a9c47ae3c89363f1afb1f58a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 26 Oct 2016 14:34:00 +0200 Subject: [PATCH 030/106] Update mappings to 0.16. --- data/protocol.json | 112 ++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 340f0dc..fe45c84 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -573,62 +573,62 @@ "0x04": "client_to_server_handshake", "0x05": "disconnect", "0x06": "batch", - "0x07": "text", - "0x08": "set_time", - "0x09": "start_game", - "0x0a": "add_player", - "0x0b": "add_entity", - "0x0c": "remove_entity", - "0x0d": "add_item_entity", - "0x0e": "take_item_entity", - "0x0f": "move_entity", - "0x10": "move_player", - "0x11": "rider_jump", - "0x12": "remove_block", - "0x13": "update_block", - "0x14": "add_painting", - "0x15": "explode", - "0x16": "level_event", - "0x17": "block_event", - "0x18": "entity_event", - "0x19": "mob_effect", - "0x1a": "update_attributes", - "0x1b": "mob_equipment", - "0x1c": "mob_armor_equipment", - "0x1d": "interact", - "0x1f": "use_item", - "0x20": "player_action", - "0x21": "hurt_armor", - "0x22": "set_entity_data", - "0x23": "set_entity_motion", - "0x24": "set_entity_link", - "0x25": "set_health", - "0x26": "set_spawn_position", - "0x27": "animate", - "0x28": "respawn", - "0x29": "drop_item", - "0x2a": "container_open", - "0x2b": "container_close", - "0x2c": "container_set_slot", - "0x2d": "container_set_data", - "0x2e": "container_set_content", - "0x2f": "crafting_data", - "0x30": "crafting_event", - "0x31": "adventure_settings", - "0x32": "block_entity_data", - "0x33": "player_input", - "0x34": "full_chunk_data", - "0x35": "set_difficulty", - "0x36": "change_dimension", - "0x37": "set_player_gametype", - "0x38": "player_list", - "0x39": "telemetry_event", - "0x3a": "spawn_experience_orb", - "0x3d": "request_chunk_radius", - "0x3e": "chunk_radius_update", - "0x3f": "item_frame_drop_item", - "0x40": "replace_selected_item", - "0x41": "add_item_item" + "0x0a": "text", + "0x0b": "set_time", + "0x0c": "start_game", + "0x0d": "add_player", + "0x0e": "add_entity", + "0x0f": "remove_entity", + "0x10": "add_item_entity", + "0x12": "take_item_entity", + "0x13": "move_entity", + "0x14": "move_player", + "0x15": "rider_jump", + "0x16": "remove_block", + "0x17": "update_block", + "0x18": "add_painting", + "0x19": "explode", + "0x1a": "level_event", + "0x1c": "block_event", + "0x1d": "entity_event", + "0x1e": "mob_effect", + "0x1f": "update_attributes", + "0x20": "mob_equipment", + "0x21": "mob_armor_equipment", + "0x22": "interact", + "0x23": "use_item", + "0x24": "player_action", + "0x25": "hurt_armor", + "0x26": "set_entity_data", + "0x27": "set_entity_motion", + "0x28": "set_entity_link", + "0x29": "set_health", + "0x2a": "set_spawn_position", + "0x2b": "animate", + "0x2c": "respawn", + "0x2d": "drop_item", + "0x2f": "container_open", + "0x30": "container_close", + "0x31": "container_set_slot", + "0x32": "container_set_data", + "0x33": "container_set_content", + "0x34": "crafting_data", + "0x35": "crafting_event", + "0x36": "adventure_settings", + "0x37": "block_entity_data", + "0x38": "player_input", + "0x39": "full_chunk_data", + "0x3b": "set_difficulty", + "0x3c": "change_dimension", + "0x3d": "set_player_gametype", + "0x3e": "player_list", + "0x3f": "telemetry_event", + "0x40": "spawn_experience_orb", + "0x43": "request_chunk_radius", + "0x44": "chunk_radius_update", + "0x45": "item_frame_drop_item", + "0x46": "replace_selected_item", + "0x49": "add_item_item" } } ] From 5f42967845749b92b97b4640984fa771c2344b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 26 Oct 2016 14:34:46 +0200 Subject: [PATCH 031/106] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 813b64b..d6110a5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Parse and serialize Minecraft PE packets. ## Features - * Supports Minecraft PE `0.14.3` and `0.15.0` + * Supports Minecraft Pocket Edition `0.16.0` * Pure JavaScript * Easily send and listen for any packet * RakNet support through [node-raknet](https://github.com/mhsjlw/node-raknet) @@ -23,5 +23,6 @@ Then view our `examples` for inspiration! ## Contributors This project is run by these guys: + - [Filiph Sandström](https://github.com/filfat) - [mhsjlw](https://github.com/mhsjlw) - [rom1504](https://github.com/rom1504) From c7d9191420e420c3f94967a5742fd437815f9d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 26 Oct 2016 15:05:07 +0200 Subject: [PATCH 032/106] Update to 4 tabs. --- data/protocol.json | 3914 ++++++++++++++++++++++---------------------- 1 file changed, 1976 insertions(+), 1938 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index fe45c84..5139f1e 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -1,1964 +1,2002 @@ { - "types": { - "string": [ - "pstring", - { - "countType":"i16" - } - ], - "lstring": [ - "pstring", - { - "countType":"li16" - } - ], - "shapeless_recipe": [ - "container", - [ - { - "name":"ingredientList", - "type": - [ - "array", + "types":{ + "string":[ + "pstring", { - "countType":"i32", - "type":"slot" + "countType":"i16" } - ] - }, - { - "name": "resultCount", - "type": "i32" - }, - { - "name": "slot", - "type": "slot" - }, - { - "name": "id", - "type": "uuid" - } - ] - ], - "shaped_recipe": [ - "container", - [ - { - "name": "width", - "type": [ - "count", { - "type": "i32", - "countFor": "shape" - } - ] - }, - { - "name": "height", - "type": [ - "count", + ], + "lstring":[ + "pstring", { - "type": "i32", - "countFor": "shape/0" + "countType":"li16" } - ] - }, - { - "name": "shape", - "type": [ - "array", - { - "count": "width", - "type": [ - "array", + ], + "shapeless_recipe":[ + "container", + [ { - "count": "height", - "type": "slot" + "name":"ingredientList", + "type":[ + "array", + { + "countType":"i32", + "type":"slot" + } + ] + }, + { + "name":"resultCount", + "type":"i32" + }, + { + "name":"slot", + "type":"slot" + }, + { + "name":"id", + "type":"uuid" } - ] - } - ] - }, - { - "name": "resultCount", - "type": "i32" - }, - { - "name": "slot", - "type": "slot" - }, - { - "name": "id", - "type": "uuid" - } - ] - ], - "furnace_recipe": [ - "container", - [ - { - "name": "meta", - "type": "i16" - }, - { - "name": "id", - "type": "i16" - }, - { - "name": "result", - "type": "slot" - } - ] - ], - "furnace_recipe_data": [ - "container", - [ - { - "name": "id", - "type": "i16" - }, - { - "name": "meta", - "type": "i16" - }, - { - "name": "result", - "type": "slot" - } - ] - ], - "enchant_list": [ - "array", - { - "countType": "i8", - "type": [ - "container", - [ - { - "name": "cost", - "type": "i32" - }, - { - "name": "enchantments", - "type": [ - "array", + ] + ], + "shaped_recipe":[ + "container", + [ { - "countType": "i8", - "type": [ + "name":"width", + "type":[ + "count", + { + "type":"i32", + "countFor":"shape" + } + ] + }, + { + "name":"height", + "type":[ + "count", + { + "type":"i32", + "countFor":"shape/0" + } + ] + }, + { + "name":"shape", + "type":[ + "array", + { + "count":"width", + "type":[ + "array", + { + "count":"height", + "type":"slot" + } + ] + } + ] + }, + { + "name":"resultCount", + "type":"i32" + }, + { + "name":"slot", + "type":"slot" + }, + { + "name":"id", + "type":"uuid" + } + ] + ], + "furnace_recipe":[ + "container", + [ + { + "name":"meta", + "type":"i16" + }, + { + "name":"id", + "type":"i16" + }, + { + "name":"result", + "type":"slot" + } + ] + ], + "furnace_recipe_data":[ + "container", + [ + { + "name":"id", + "type":"i16" + }, + { + "name":"meta", + "type":"i16" + }, + { + "name":"result", + "type":"slot" + } + ] + ], + "enchant_list":[ + "array", + { + "countType":"i8", + "type":[ "container", [ - { - "name": "id", - "type": "i32" - }, - { - "name": "level", - "type": "i32" - } - ] - ] - } - ] - }, - { - "name": "name", - "type": "string" - } - ] - ] - } - ], - "entityMetadataItem": [ - "switch", - { - "compareTo": "$compareTo", - "fields": { - "0": "li8", - "1": "li16", - "2": "li32", - "3": "lf32", - "4": "lstring", - "5": ["container",[ - { - "name":"blockId", - "type":"li16" - }, - { - "name":"itemCount", - "type":"li8" - }, - { - "name":"itemDamage", - "type":"li16" - } - ]], - "6": [ - "container", - [ - { - "name": "x", - "type": "li32" - }, - { - "name": "y", - "type": "li32" - }, - { - "name": "z", - "type": "li32" - } - ] - ], - "7": [ - "container", - [ - { - "name": "pitch", - "type": "lf32" - }, - { - "name": "yaw", - "type": "lf32" - }, - { - "name": "roll", - "type": "lf32" - } - ] - ], - "8": "li64" - } - } - ], - "metadatadictionary": [ - "entityMetadataLoop", - { - "endVal": 127, - "type": [ - "container", - [ - { - "anon": true, - "type": [ - "bitfield", - [ - { - "name": "type", - "size": 3, - "signed": false - }, - { - "name": "key", - "size": 5, - "signed": false - } - ] - ] - }, - { - "name": "value", - "type": [ - "entityMetadataItem", - { - "compareTo": "type" - } - ] - } - ] - ] - } - ], - "slot": [ - "container", - [ - { - "name": "blockId", - "type": "i16" - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "blockId", - "fields": { - "0": "void" - }, - "default": [ - "container", - [ - { - "name": "itemCount", - "type": "i8" - }, - { - "name": "itemDamage", - "type": "i16" - }, - { - "name": "nbtData", - "type": ["buffer",{"countType":"li16"}] - } - ] - ] - } - ] - } - ] - ], - "itemstacks": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ - { - "name": "slot", - "type": "itemstacks" - } - ] - ] - } - ], - "skin": [ - "container", - [ - { - "name": "skin_type", - "type": "string" - }, - { - "name": "texture", - "type": ["buffer",{"countType":"i16"}] - } - ] - ], - "blockrecords": [ - "array", - { - "countType":"i32", - "type": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "y", - "type": "i8" - }, - { - "name": "blockId", - "type": "i8" - }, - { - "anon": true, - "type": [ - "bitfield", - [ - { - "name": "blockData", - "size": 4, - "signed": false - }, - { - "name": "flags", - "size": 4, - "signed": false - } - ] - ] - } - ] - ] - } - ], - "records": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ - { - "name": "x", - "type": "i8" - }, - { - "name": "y", - "type": "i8" - }, - { - "name": "z", - "type": "i8" - } - ] - ] - } - ], - "playerattributes": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ - { - "name": "minValue", - "type": "f32" - }, - { - "name": "maxValue", - "type": "f32" - }, - { - "name": "id", - "type": "f32" - }, - { - "name": "name", - "type": "string" - } - ] - ] - } - ], - "entitymotions": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ - { - "name": "eid", - "type": "i64" - }, - { - "name": "motX", - "type": "f32" - }, - { - "name": "motY", - "type": "f32" - }, - { - "name": "motZ", - "type": "f32" - } - ] - ] - } - ], - "vector3": [ - "container", - [ - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - } - ] - ], - "blockcoordinates": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - } - ] - ], - "entitylocations": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ - { - "name": "eid", - "type": "i64" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "yaw", - "type": "f32" - }, - { - "name": "headYaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - } - ] - ] - } - ], - "encapsulated_packet":[ - "container", - [ - { - "name": "name", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0xfe": "mcpe" - } - } - ] - }, - { - "name": "params", - "type": [ - "switch", - { - "compareTo": "name", - "fields": { - "mcpe":"mcpe_packet" - } - } - ] - } - ] - ], - "mcpe_packet": [ - "container", - [ - { - "name": "name", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0x01": "game_login", - "0x02": "player_status", - "0x03": "server_to_client_handshake", - "0x04": "client_to_server_handshake", - "0x05": "disconnect", - "0x06": "batch", - "0x0a": "text", - "0x0b": "set_time", - "0x0c": "start_game", - "0x0d": "add_player", - "0x0e": "add_entity", - "0x0f": "remove_entity", - "0x10": "add_item_entity", - "0x12": "take_item_entity", - "0x13": "move_entity", - "0x14": "move_player", - "0x15": "rider_jump", - "0x16": "remove_block", - "0x17": "update_block", - "0x18": "add_painting", - "0x19": "explode", - "0x1a": "level_event", - "0x1c": "block_event", - "0x1d": "entity_event", - "0x1e": "mob_effect", - "0x1f": "update_attributes", - "0x20": "mob_equipment", - "0x21": "mob_armor_equipment", - "0x22": "interact", - "0x23": "use_item", - "0x24": "player_action", - "0x25": "hurt_armor", - "0x26": "set_entity_data", - "0x27": "set_entity_motion", - "0x28": "set_entity_link", - "0x29": "set_health", - "0x2a": "set_spawn_position", - "0x2b": "animate", - "0x2c": "respawn", - "0x2d": "drop_item", - "0x2f": "container_open", - "0x30": "container_close", - "0x31": "container_set_slot", - "0x32": "container_set_data", - "0x33": "container_set_content", - "0x34": "crafting_data", - "0x35": "crafting_event", - "0x36": "adventure_settings", - "0x37": "block_entity_data", - "0x38": "player_input", - "0x39": "full_chunk_data", - "0x3b": "set_difficulty", - "0x3c": "change_dimension", - "0x3d": "set_player_gametype", - "0x3e": "player_list", - "0x3f": "telemetry_event", - "0x40": "spawn_experience_orb", - "0x43": "request_chunk_radius", - "0x44": "chunk_radius_update", - "0x45": "item_frame_drop_item", - "0x46": "replace_selected_item", - "0x49": "add_item_item" - } - } - ] - }, - { - "name": "params", - "type": [ - "switch", - { - "compareTo": "name", - "fields": { - "server_to_client_handshake": "packet_server_to_client_handshake", - "client_to_server_handshake": "packet_client_to_server_handshake", - "game_login": "packet_game_login", - "player_status": "packet_player_status", - "disconnect": "packet_disconnect", - "batch": "packet_batch", - "text": "packet_text", - "set_time": "packet_set_time", - "start_game": "packet_start_game", - "add_player": "packet_add_player", - "remove_player": "packet_remove_player", - "add_entity": "packet_add_entity", - "remove_entity": "packet_remove_entity", - "add_item_entity": "packet_add_item_entity", - "take_item_entity": "packet_take_item_entity", - "move_entity": "packet_move_entity", - "move_player": "packet_move_player", - "remove_block": "packet_remove_block", - "update_block": "packet_update_block", - "add_painting": "packet_add_painting", - "explode": "packet_explode", - "level_event": "packet_level_event", - "block_event": "packet_block_event", - "entity_event": "packet_entity_event", - "mob_effect": "packet_mob_effect", - "update_attributes": "packet_update_attributes", - "mob_equipment": "packet_mob_equipment", - "mob_armor_equipment": "packet_mob_armor_equipment", - "interact": "packet_interact", - "use_item": "packet_use_item", - "player_action": "packet_player_action", - "hurt_armor": "packet_hurt_armor", - "set_entity_data": "packet_set_entity_data", - "set_entity_motion": "packet_set_entity_motion", - "set_entity_link": "packet_set_entity_link", - "set_health": "packet_set_health", - "set_spawn_position": "packet_set_spawn_position", - "animate": "packet_animate", - "respawn": "packet_respawn", - "drop_item": "packet_drop_item", - "container_open": "packet_container_open", - "container_close": "packet_container_close", - "container_set_slot": "packet_container_set_slot", - "container_set_data": "packet_container_set_data", - "container_set_content": "packet_container_set_content", - "crafting_data": "packet_crafting_data", - "crafting_event": "packet_crafting_event", - "adventure_settings": "packet_adventure_settings", - "block_entity_data": "packet_block_entity_data", - "player_input": "packet_player_input", - "full_chunk_data": "packet_full_chunk_data", - "set_difficulty": "packet_set_difficulty", - "player_list": "packet_player_list", - "request_chunk_radius": "packet_request_chunk_radius", - "chunk_radius_update": "packet_chunk_radius_update", - "transfer": "packet_transfer", - "spawn_experience_orb": "packet_spawn_experience_orb", - "replace_selected_item": "packet_replace_selected_item" - } - } - ] - } - ] - ], - "packet_id_detect_lost_connections": [ - "container", - [] - ], - "packet_id_no_free_incoming_connections": [ - "container", - [] - ], - "packet_id_connection_banned": [ - "container", - [] - ], - "packet_id_ip_recently_connected": [ - "container", - [] - ], - "packet_server_to_client_handshake": [ - "container", - [ - { - "name": "publicKey", - "type": "string" - }, - { - "name": "serverToken", - "type": "string" - } - ] - ], - "packet_client_to_server_handshake": [ - "container", - [ - ] - ], - "packet_game_login": [ - "container", - [ - { - "name": "protocol", - "type": "i32" - }, - { - "name": "body", - "type": ["buffer",{"countType":"i32"}] - } - ] - ], - "packet_player_status": [ - "container", - [ - { - "name": "status", - "type": "i32" - } - ] - ], - "packet_disconnect": [ - "container", - [ - { - "name": "message", - "type": "string" - } - ] - ], - "packet_batch": [ - "container", - [ - { - "name": "payload", - "type":["buffer",{"countType":"i32"}] - } - ] - ], - "packet_text": [ - "container", - [ - { - "name": "type", - "type": "i8" - }, - { - "name": "name", - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "1": "string", - "3": "string" - }, - "default": "void" - } - ] - }, - { - "name": "message", - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "0": "string", - "1": "string", - "2": "string", - "3": "string", - "4": "string", - "5": "string" - } - } - ] - }, - { - "name": "parameters", - "type": [ - "switch", - { - "compareTo": "type", - "fields":{ - "2":[ - "array", { - "countType":"i8", - "type":"string" - } - ] - }, - "default":"void" - } - ] - } - ] - ], - "packet_set_time": [ - "container", - [ - { - "name": "time", - "type": "i32" - }, - { - "name": "started", - "type": "i8" - } - ] - ], - "packet_start_game": [ - "container", - [ - { - "name": "seed", - "type": "i32" - }, - { - "name": "dimension", - "type": "i8" - }, - { - "name": "generator", - "type": "i32" - }, - { - "name": "gamemode", - "type": "i8" - }, - { - "name": "entityId", - "type": "i64" - }, - { - "name": "spawnX", - "type": "i32" - }, - { - "name": "spawnY", - "type": "i32" - }, - { - "name": "spawnZ", - "type": "i32" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "isLoadedInCreative", - "type": "bool" - }, - { - "name": "dayCycleStopTime", - "type": "i8" - }, - { - "name": "eduMode", - "type": "bool" - }, - { - "name": "worldName", - "type": "string" - } - ] - ], - "packet_add_player": [ - "container", - [ - { - "name": "uuid", - "type": "uuid" - }, - { - "name": "username", - "type": "string" - }, - { - "name": "entityId", - "type": "i64" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "speedX", - "type": "f32" - }, - { - "name": "speedY", - "type": "f32" - }, - { - "name": "speedZ", - "type": "f32" - }, - { - "name": "yaw", - "type": "f32" - }, - { - "name": "headYaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - }, - { - "name": "item", - "type": "slot" - }, - { - "name": "metadata", - "type": "metadatadictionary" - } - ] - ], - "packet_remove_player": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "clientUuid", - "type": "uuid" - } - ] - ], - "packet_add_entity": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "entityType", - "type": "i32" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "speedX", - "type": "f32" - }, - { - "name": "speedY", - "type": "f32" - }, - { - "name": "speedZ", - "type": "f32" - }, - { - "name": "yaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - }, - { - "name": "metadata", - "type": "metadatadictionary" - }, - { - "name": "links", - "type": "i16" - } - ] - ], - "packet_remove_entity": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - } - ] - ], - "packet_add_item_entity": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "item", - "type": "slot" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "speedX", - "type": "f32" - }, - { - "name": "speedY", - "type": "f32" - }, - { - "name": "speedZ", - "type": "f32" - } - ] - ], - "packet_take_item_entity": [ - "container", - [ - { - "name": "target", - "type": "i64" - }, - { - "name": "entityId", - "type": "i64" - } - ] - ], - "packet_move_entity": [ - "container", - [ - { - "name": "entities", - "type": "entitylocations" - } - ] - ], - "packet_move_player": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "yaw", - "type": "f32" - }, - { - "name": "headYaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - }, - { - "name": "mode", - "type": "i8" - }, - { - "name": "onGround", - "type": "i8" - } - ] - ], - "packet_remove_block": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "y", - "type": "i8" - } - ] - ], - "packet_update_block": [ - "container", - [ - { - "name": "blocks", - "type": "blockrecords" - } - ] - ], - "packet_add_painting": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "direction", - "type": "i32" - }, - { - "name": "title", - "type": "string" - } - ] - ], - "packet_explode": [ - "container", - [ - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "radius", - "type": "f32" - }, - { - "name": "records", - "type": "records" - } - ] - ], - "packet_level_event": [ - "container", - [ - { - "name": "eventId", - "type": "i16" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "data", - "type": "i32" - } - ] - ], - "packet_block_event": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "case1", - "type": "i32" - }, - { - "name": "case2", - "type": "i32" - } - ] - ], - "packet_entity_event": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "eventId", - "type": "i8" - } - ] - ], - "packet_mob_effect": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "eventId", - "type": "i8" - }, - { - "name": "effectId", - "type": "i8" - }, - { - "name": "amplifier", - "type": "i8" - }, - { - "name": "particles", - "type": "i8" - }, - { - "name": "duration", - "type": "i32" - } - ] - ], - "packet_update_attributes": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "attributes", - "type": "playerattributes" - } - ] - ], - "packet_mob_equipment": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "item", - "type": "slot" - }, - { - "name": "slot", - "type": "i8" - }, - { - "name": "selectedSlot", - "type": "i8" - } - ] - ], - "packet_mob_armor_equipment": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "helmet", - "type": "slot" - }, - { - "name": "chestplate", - "type": "slot" - }, - { - "name": "leggings", - "type": "slot" - }, - { - "name": "boots", - "type": "slot" - } - ] - ], - "packet_interact": [ - "container", - [ - { - "name": "actionId", - "type": "i8" - }, - { - "name": "targetEntityId", - "type": "i64" - } - ] - ], - "packet_use_item": [ - "container", - [ - { - "name": "blockcoordinates", - "type": "blockcoordinates" - }, - { - "name": "face", - "type": "i8" - }, - { - "name": "facecoordinates", - "type": "vector3" - }, - { - "name": "playerposition", - "type": "vector3" - }, - { - "name": "slot", - "type": "i32" - }, - { - "name": "item", - "type": "slot" - } - ] - ], - "packet_player_action": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "actionId", - "type": "i32" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "face", - "type": "i32" - } - ] - ], - "packet_hurt_armor": [ - "container", - [ - { - "name": "health", - "type": "i8" - } - ] - ], - "packet_set_entity_data": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "metadata", - "type": "metadatadictionary" - } - ] - ], - "packet_set_entity_motion": [ - "container", - [ - { - "name": "entities", - "type": "entitymotions" - } - ] - ], - "packet_set_entity_link": [ - "container", - [ - { - "name": "riderId", - "type": "i64" - }, - { - "name": "riddenId", - "type": "i64" - }, - { - "name": "linkType", - "type": "i8" - } - ] - ], - "packet_set_health": [ - "container", - [ - { - "name": "health", - "type": "i32" - } - ] - ], - "packet_set_spawn_position": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - } - ] - ], - "packet_animate": [ - "container", - [ - { - "name": "actionId", - "type": "i8" - }, - { - "name": "entityId", - "type": "i64" - } - ] - ], - "packet_respawn": [ - "container", - [ - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - } - ] - ], - "packet_drop_item": [ - "container", - [ - { - "name": "itemtype", - "type": "i8" - }, - { - "name": "item", - "type": "slot" - } - ] - ], - "packet_container_open": [ - "container", - [ - { - "name": "windowId", - "type": "i8" - }, - { - "name": "type", - "type": "i8" - }, - { - "name": "slotCount", - "type": "i16" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - } - ] - ], - "packet_container_close": [ - "container", - [ - { - "name": "windowId", - "type": "i8" - } - ] - ], - "packet_container_set_slot": [ - "container", - [ - { - "name": "windowId", - "type": "i8" - }, - { - "name": "slot", - "type": "i16" - }, - { - "name": "unknown", - "type": "i16" - }, - { - "name": "item", - "type": "slot" - } - ] - ], - "packet_container_set_data": [ - "container", - [ - { - "name": "windowId", - "type": "i8" - }, - { - "name": "property", - "type": "i16" - }, - { - "name": "value", - "type": "i16" - } - ] - ], - "packet_container_set_content": [ - "container", - [ - { - "name": "windowId", - "type": "i8" - }, - { - "name": "slotData", - "type": "itemstacks" - }, - { - "name": "hotbarData", - "type": [ - "switch", - { - "compareTo": "windowId", - "fields": { - "0": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ { - "name": "slot", - "type": "i32" + "name":"cost", + "type":"i32" + }, + { + "name":"enchantments", + "type":[ + "array", + { + "countType":"i8", + "type":[ + "container", + [ + { + "name":"id", + "type":"i32" + }, + { + "name":"level", + "type":"i32" + } + ] + ] + } + ] + }, + { + "name":"name", + "type":"string" } - ] ] - } ] - }, - "default": "i16" } - ] - } - ] - ], - "packet_crafting_data": [ - "container", - [ - { - "name": "recipes", - "type": [ + ], + "entityMetadataItem":[ + "switch", + { + "compareTo":"$compareTo", + "fields":{ + "0":"li8", + "1":"li16", + "2":"li32", + "3":"lf32", + "4":"lstring", + "5":[ + "container", + [ + { + "name":"blockId", + "type":"li16" + }, + { + "name":"itemCount", + "type":"li8" + }, + { + "name":"itemDamage", + "type":"li16" + } + ] + ], + "6":[ + "container", + [ + { + "name":"x", + "type":"li32" + }, + { + "name":"y", + "type":"li32" + }, + { + "name":"z", + "type":"li32" + } + ] + ], + "7":[ + "container", + [ + { + "name":"pitch", + "type":"lf32" + }, + { + "name":"yaw", + "type":"lf32" + }, + { + "name":"roll", + "type":"lf32" + } + ] + ], + "8":"li64" + } + } + ], + "metadatadictionary":[ + "entityMetadataLoop", + { + "endVal":127, + "type":[ + "container", + [ + { + "anon":true, + "type":[ + "bitfield", + [ + { + "name":"type", + "size":3, + "signed":false + }, + { + "name":"key", + "size":5, + "signed":false + } + ] + ] + }, + { + "name":"value", + "type":[ + "entityMetadataItem", + { + "compareTo":"type" + } + ] + } + ] + ] + } + ], + "slot":[ "container", [ - { - "name": "entryType", - "type": "i32" - }, - { - "name": "recipe", - "type": [ - "array", - { - "countType": "i32", - "type": [ - "switch", - { - "compareTo": "entryType", - "fields": { - "0": "shapelessRecipe", - "1": "shapedRecipe", - "2": "furnaceRecipe", - "3": "furnaceRecipeData", - "4": "enchantList" - }, - "default":"void" - } + { + "name":"blockId", + "type":"i16" + }, + { + "anon":true, + "type":[ + "switch", + { + "compareTo":"blockId", + "fields":{ + "0":"void" + }, + "default":[ + "container", + [ + { + "name":"itemCount", + "type":"i8" + }, + { + "name":"itemDamage", + "type":"i16" + }, + { + "name":"nbtData", + "type":[ + "buffer", + { + "countType":"li16" + } + ] + } + ] + ] + } ] - } - ] - } + } ] - ] - }, - { - "name": "cleanRecipes", - "type": "i8" - } - ] - ], - "packet_crafting_event": [ - "container", - [ - { - "name": "windowId", - "type": "i8" - }, - { - "name": "recipeType", - "type": "i32" - }, - { - "name": "recipeId", - "type": "uuid" - }, - { - "name": "input", - "type": "itemstacks" - }, - { - "name": "result", - "type": "itemstacks" - } - ] - ], - "packet_adventure_settings": [ - "container", - [ - { - "name": "flags", - "type": "i32" - }, - { - "name": "userPermission", - "type": "i32" - }, - { - "name": "globalPermission", - "type": "i32" - } - ] - ], - "packet_block_entity_data": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "namedtag", - "type": "restBuffer" - } - ] - ], - "packet_player_input": [ - "container", - [ - { - "name": "motionX", - "type": "f32" - }, - { - "name": "motionZ", - "type": "f32" - }, - { - "name": "flags", - "type": "i16" - } - ] - ], - "packet_full_chunk_data": [ - "container", - [ - { - "name": "chunkX", - "type": "i32" - }, - { - "name": "chunkZ", - "type": "i32" - }, - { - "name": "order", - "type": "i8" - }, - { - "name": "chunkData", - "type":["buffer",{"countType":"i32"}] - } - ] - ], - "packet_set_difficulty": [ - "container", - [ - { - "name": "difficulty", - "type": "i32" - } - ] - ], - "packet_player_list": [ - "container", - [ - { - "name": "type", - "type": "i8" - }, - { - "name": "entries", - "type": [ + ], + "itemstacks":[ "array", { - "countType": "i32", - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "0": [ - "container", - [ + "countType":"i16", + "type":[ + "container", + [ { - "name": "clientUuid", - "type": "uuid" - }, - { - "name": "entityId", - "type": "i64" - }, - { - "name": "displayName", - "type": "string" - }, - { - "name": "skin", - "type": "skin" + "name":"slot", + "type":"itemstacks" } - ] - ], - "1": [ - "container", - [ - { - "name": "clientUuid", - "type": "uuid" - } - ] ] - } - } - ] + ] } - ] - } - ] - ], - "packet_request_chunk_radius": [ - "container", - [ - { - "name": "chunkRadius", - "type": "i32" - } - ] - ], - "packet_chunk_radius_update": [ - "container", - [ - { - "name": "chunkRadius", - "type": "i32" - } - ] - ], - "packet_transfer": [ - "container", - [ - { - "name": "endpoint", - "type": "ipAddress" - } - ] - ], - "packet_spawn_experience_orb": [ - "container", - [ - { - "name": "entityId", - "type": "i64" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "count", - "type": "i32" - } - ] - ], - "packet_replace_selected_item": [ - "container", - [ - { - "name": "slot", - "type": "slot" - } - ] - ] - } + ], + "skin":[ + "container", + [ + { + "name":"skin_type", + "type":"string" + }, + { + "name":"texture", + "type":[ + "buffer", + { + "countType":"i16" + } + ] + } + ] + ], + "blockrecords":[ + "array", + { + "countType":"i32", + "type":[ + "container", + [ + { + "name":"x", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"y", + "type":"i8" + }, + { + "name":"blockId", + "type":"i8" + }, + { + "anon":true, + "type":[ + "bitfield", + [ + { + "name":"blockData", + "size":4, + "signed":false + }, + { + "name":"flags", + "size":4, + "signed":false + } + ] + ] + } + ] + ] + } + ], + "records":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"x", + "type":"i8" + }, + { + "name":"y", + "type":"i8" + }, + { + "name":"z", + "type":"i8" + } + ] + ] + } + ], + "playerattributes":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"minValue", + "type":"f32" + }, + { + "name":"maxValue", + "type":"f32" + }, + { + "name":"id", + "type":"f32" + }, + { + "name":"name", + "type":"string" + } + ] + ] + } + ], + "entitymotions":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"eid", + "type":"i64" + }, + { + "name":"motX", + "type":"f32" + }, + { + "name":"motY", + "type":"f32" + }, + { + "name":"motZ", + "type":"f32" + } + ] + ] + } + ], + "vector3":[ + "container", + [ + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + } + ] + ], + "blockcoordinates":[ + "container", + [ + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + } + ] + ], + "entitylocations":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"eid", + "type":"i64" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"yaw", + "type":"f32" + }, + { + "name":"headYaw", + "type":"f32" + }, + { + "name":"pitch", + "type":"f32" + } + ] + ] + } + ], + "encapsulated_packet":[ + "container", + [ + { + "name":"name", + "type":[ + "mapper", + { + "type":"u8", + "mappings":{ + "0xfe":"mcpe" + } + } + ] + }, + { + "name":"params", + "type":[ + "switch", + { + "compareTo":"name", + "fields":{ + "mcpe":"mcpe_packet" + } + } + ] + } + ] + ], + "mcpe_packet":[ + "container", + [ + { + "name":"name", + "type":[ + "mapper", + { + "type":"u8", + "mappings":{ + "0x01":"game_login", + "0x02":"player_status", + "0x03":"server_to_client_handshake", + "0x04":"client_to_server_handshake", + "0x05":"disconnect", + "0x06":"batch", + "0x0a":"text", + "0x0b":"set_time", + "0x0c":"start_game", + "0x0d":"add_player", + "0x0e":"add_entity", + "0x0f":"remove_entity", + "0x10":"add_item_entity", + "0x12":"take_item_entity", + "0x13":"move_entity", + "0x14":"move_player", + "0x15":"rider_jump", + "0x16":"remove_block", + "0x17":"update_block", + "0x18":"add_painting", + "0x19":"explode", + "0x1a":"level_event", + "0x1c":"block_event", + "0x1d":"entity_event", + "0x1e":"mob_effect", + "0x1f":"update_attributes", + "0x20":"mob_equipment", + "0x21":"mob_armor_equipment", + "0x22":"interact", + "0x23":"use_item", + "0x24":"player_action", + "0x25":"hurt_armor", + "0x26":"set_entity_data", + "0x27":"set_entity_motion", + "0x28":"set_entity_link", + "0x29":"set_health", + "0x2a":"set_spawn_position", + "0x2b":"animate", + "0x2c":"respawn", + "0x2d":"drop_item", + "0x2f":"container_open", + "0x30":"container_close", + "0x31":"container_set_slot", + "0x32":"container_set_data", + "0x33":"container_set_content", + "0x34":"crafting_data", + "0x35":"crafting_event", + "0x36":"adventure_settings", + "0x37":"block_entity_data", + "0x38":"player_input", + "0x39":"full_chunk_data", + "0x3b":"set_difficulty", + "0x3c":"change_dimension", + "0x3d":"set_player_gametype", + "0x3e":"player_list", + "0x3f":"telemetry_event", + "0x40":"spawn_experience_orb", + "0x43":"request_chunk_radius", + "0x44":"chunk_radius_update", + "0x45":"item_frame_drop_item", + "0x46":"replace_selected_item", + "0x49":"add_item_item" + } + } + ] + }, + { + "name":"params", + "type":[ + "switch", + { + "compareTo":"name", + "fields":{ + "server_to_client_handshake":"packet_server_to_client_handshake", + "client_to_server_handshake":"packet_client_to_server_handshake", + "game_login":"packet_game_login", + "player_status":"packet_player_status", + "disconnect":"packet_disconnect", + "batch":"packet_batch", + "text":"packet_text", + "set_time":"packet_set_time", + "start_game":"packet_start_game", + "add_player":"packet_add_player", + "remove_player":"packet_remove_player", + "add_entity":"packet_add_entity", + "remove_entity":"packet_remove_entity", + "add_item_entity":"packet_add_item_entity", + "take_item_entity":"packet_take_item_entity", + "move_entity":"packet_move_entity", + "move_player":"packet_move_player", + "remove_block":"packet_remove_block", + "update_block":"packet_update_block", + "add_painting":"packet_add_painting", + "explode":"packet_explode", + "level_event":"packet_level_event", + "block_event":"packet_block_event", + "entity_event":"packet_entity_event", + "mob_effect":"packet_mob_effect", + "update_attributes":"packet_update_attributes", + "mob_equipment":"packet_mob_equipment", + "mob_armor_equipment":"packet_mob_armor_equipment", + "interact":"packet_interact", + "use_item":"packet_use_item", + "player_action":"packet_player_action", + "hurt_armor":"packet_hurt_armor", + "set_entity_data":"packet_set_entity_data", + "set_entity_motion":"packet_set_entity_motion", + "set_entity_link":"packet_set_entity_link", + "set_health":"packet_set_health", + "set_spawn_position":"packet_set_spawn_position", + "animate":"packet_animate", + "respawn":"packet_respawn", + "drop_item":"packet_drop_item", + "container_open":"packet_container_open", + "container_close":"packet_container_close", + "container_set_slot":"packet_container_set_slot", + "container_set_data":"packet_container_set_data", + "container_set_content":"packet_container_set_content", + "crafting_data":"packet_crafting_data", + "crafting_event":"packet_crafting_event", + "adventure_settings":"packet_adventure_settings", + "block_entity_data":"packet_block_entity_data", + "player_input":"packet_player_input", + "full_chunk_data":"packet_full_chunk_data", + "set_difficulty":"packet_set_difficulty", + "player_list":"packet_player_list", + "request_chunk_radius":"packet_request_chunk_radius", + "chunk_radius_update":"packet_chunk_radius_update", + "transfer":"packet_transfer", + "spawn_experience_orb":"packet_spawn_experience_orb", + "replace_selected_item":"packet_replace_selected_item" + } + } + ] + } + ] + ], + "packet_id_detect_lost_connections":[ + "container", + [ + + ] + ], + "packet_id_no_free_incoming_connections":[ + "container", + [ + + ] + ], + "packet_id_connection_banned":[ + "container", + [ + + ] + ], + "packet_id_ip_recently_connected":[ + "container", + [ + + ] + ], + "packet_server_to_client_handshake":[ + "container", + [ + { + "name":"publicKey", + "type":"string" + }, + { + "name":"serverToken", + "type":"string" + } + ] + ], + "packet_client_to_server_handshake":[ + "container", + [ + + ] + ], + "packet_game_login":[ + "container", + [ + { + "name":"protocol", + "type":"i32" + }, + { + "name":"body", + "type":[ + "buffer", + { + "countType":"i32" + } + ] + } + ] + ], + "packet_player_status":[ + "container", + [ + { + "name":"status", + "type":"i32" + } + ] + ], + "packet_disconnect":[ + "container", + [ + { + "name":"message", + "type":"string" + } + ] + ], + "packet_batch":[ + "container", + [ + { + "name":"payload", + "type":[ + "buffer", + { + "countType":"i32" + } + ] + } + ] + ], + "packet_text":[ + "container", + [ + { + "name":"type", + "type":"i8" + }, + { + "name":"name", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "1":"string", + "3":"string" + }, + "default":"void" + } + ] + }, + { + "name":"message", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "0":"string", + "1":"string", + "2":"string", + "3":"string", + "4":"string", + "5":"string" + } + } + ] + }, + { + "name":"parameters", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "2":[ + "array", + { + "countType":"i8", + "type":"string" + } + ] + }, + "default":"void" + } + ] + } + ] + ], + "packet_set_time":[ + "container", + [ + { + "name":"time", + "type":"i32" + }, + { + "name":"started", + "type":"i8" + } + ] + ], + "packet_start_game":[ + "container", + [ + { + "name":"seed", + "type":"i32" + }, + { + "name":"dimension", + "type":"i8" + }, + { + "name":"generator", + "type":"i32" + }, + { + "name":"gamemode", + "type":"i8" + }, + { + "name":"entityId", + "type":"i64" + }, + { + "name":"spawnX", + "type":"i32" + }, + { + "name":"spawnY", + "type":"i32" + }, + { + "name":"spawnZ", + "type":"i32" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"isLoadedInCreative", + "type":"bool" + }, + { + "name":"dayCycleStopTime", + "type":"i8" + }, + { + "name":"eduMode", + "type":"bool" + }, + { + "name":"worldName", + "type":"string" + } + ] + ], + "packet_add_player":[ + "container", + [ + { + "name":"uuid", + "type":"uuid" + }, + { + "name":"username", + "type":"string" + }, + { + "name":"entityId", + "type":"i64" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"speedX", + "type":"f32" + }, + { + "name":"speedY", + "type":"f32" + }, + { + "name":"speedZ", + "type":"f32" + }, + { + "name":"yaw", + "type":"f32" + }, + { + "name":"headYaw", + "type":"f32" + }, + { + "name":"pitch", + "type":"f32" + }, + { + "name":"item", + "type":"slot" + }, + { + "name":"metadata", + "type":"metadatadictionary" + } + ] + ], + "packet_remove_player":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"clientUuid", + "type":"uuid" + } + ] + ], + "packet_add_entity":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"entityType", + "type":"i32" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"speedX", + "type":"f32" + }, + { + "name":"speedY", + "type":"f32" + }, + { + "name":"speedZ", + "type":"f32" + }, + { + "name":"yaw", + "type":"f32" + }, + { + "name":"pitch", + "type":"f32" + }, + { + "name":"metadata", + "type":"metadatadictionary" + }, + { + "name":"links", + "type":"i16" + } + ] + ], + "packet_remove_entity":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + } + ] + ], + "packet_add_item_entity":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"item", + "type":"slot" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"speedX", + "type":"f32" + }, + { + "name":"speedY", + "type":"f32" + }, + { + "name":"speedZ", + "type":"f32" + } + ] + ], + "packet_take_item_entity":[ + "container", + [ + { + "name":"target", + "type":"i64" + }, + { + "name":"entityId", + "type":"i64" + } + ] + ], + "packet_move_entity":[ + "container", + [ + { + "name":"entities", + "type":"entitylocations" + } + ] + ], + "packet_move_player":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"yaw", + "type":"f32" + }, + { + "name":"headYaw", + "type":"f32" + }, + { + "name":"pitch", + "type":"f32" + }, + { + "name":"mode", + "type":"i8" + }, + { + "name":"onGround", + "type":"i8" + } + ] + ], + "packet_remove_block":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"x", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"y", + "type":"i8" + } + ] + ], + "packet_update_block":[ + "container", + [ + { + "name":"blocks", + "type":"blockrecords" + } + ] + ], + "packet_add_painting":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"direction", + "type":"i32" + }, + { + "name":"title", + "type":"string" + } + ] + ], + "packet_explode":[ + "container", + [ + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"radius", + "type":"f32" + }, + { + "name":"records", + "type":"records" + } + ] + ], + "packet_level_event":[ + "container", + [ + { + "name":"eventId", + "type":"i16" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, + { + "name":"data", + "type":"i32" + } + ] + ], + "packet_block_event":[ + "container", + [ + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"case1", + "type":"i32" + }, + { + "name":"case2", + "type":"i32" + } + ] + ], + "packet_entity_event":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"eventId", + "type":"i8" + } + ] + ], + "packet_mob_effect":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"eventId", + "type":"i8" + }, + { + "name":"effectId", + "type":"i8" + }, + { + "name":"amplifier", + "type":"i8" + }, + { + "name":"particles", + "type":"i8" + }, + { + "name":"duration", + "type":"i32" + } + ] + ], + "packet_update_attributes":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"attributes", + "type":"playerattributes" + } + ] + ], + "packet_mob_equipment":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"item", + "type":"slot" + }, + { + "name":"slot", + "type":"i8" + }, + { + "name":"selectedSlot", + "type":"i8" + } + ] + ], + "packet_mob_armor_equipment":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"helmet", + "type":"slot" + }, + { + "name":"chestplate", + "type":"slot" + }, + { + "name":"leggings", + "type":"slot" + }, + { + "name":"boots", + "type":"slot" + } + ] + ], + "packet_interact":[ + "container", + [ + { + "name":"actionId", + "type":"i8" + }, + { + "name":"targetEntityId", + "type":"i64" + } + ] + ], + "packet_use_item":[ + "container", + [ + { + "name":"blockcoordinates", + "type":"blockcoordinates" + }, + { + "name":"face", + "type":"i8" + }, + { + "name":"facecoordinates", + "type":"vector3" + }, + { + "name":"playerposition", + "type":"vector3" + }, + { + "name":"slot", + "type":"i32" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_player_action":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"actionId", + "type":"i32" + }, + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"face", + "type":"i32" + } + ] + ], + "packet_hurt_armor":[ + "container", + [ + { + "name":"health", + "type":"i8" + } + ] + ], + "packet_set_entity_data":[ + "container", + [ + { + "name":"entity_id", + "type":"i64" + }, + { + "name":"metadata", + "type":"metadatadictionary" + } + ] + ], + "packet_set_entity_motion":[ + "container", + [ + { + "name":"entities", + "type":"entitymotions" + } + ] + ], + "packet_set_entity_link":[ + "container", + [ + { + "name":"riderId", + "type":"i64" + }, + { + "name":"riddenId", + "type":"i64" + }, + { + "name":"linkType", + "type":"i8" + } + ] + ], + "packet_set_health":[ + "container", + [ + { + "name":"health", + "type":"i32" + } + ] + ], + "packet_set_spawn_position":[ + "container", + [ + { + "name":"x", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + } + ] + ], + "packet_animate":[ + "container", + [ + { + "name":"actionId", + "type":"i8" + }, + { + "name":"entityId", + "type":"i64" + } + ] + ], + "packet_respawn":[ + "container", + [ + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + } + ] + ], + "packet_drop_item":[ + "container", + [ + { + "name":"itemtype", + "type":"i8" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_container_open":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + }, + { + "name":"type", + "type":"i8" + }, + { + "name":"slotCount", + "type":"i16" + }, + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + } + ] + ], + "packet_container_close":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + } + ] + ], + "packet_container_set_slot":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + }, + { + "name":"slot", + "type":"i16" + }, + { + "name":"unknown", + "type":"i16" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_container_set_data":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + }, + { + "name":"property", + "type":"i16" + }, + { + "name":"value", + "type":"i16" + } + ] + ], + "packet_container_set_content":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + }, + { + "name":"slotData", + "type":"itemstacks" + }, + { + "name":"hotbarData", + "type":[ + "switch", + { + "compareTo":"windowId", + "fields":{ + "0":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"slot", + "type":"i32" + } + ] + ] + } + ] + }, + "default":"i16" + } + ] + } + ] + ], + "packet_crafting_data":[ + "container", + [ + { + "name":"recipes", + "type":[ + "container", + [ + { + "name":"entryType", + "type":"i32" + }, + { + "name":"recipe", + "type":[ + "array", + { + "countType":"i32", + "type":[ + "switch", + { + "compareTo":"entryType", + "fields":{ + "0":"shapelessRecipe", + "1":"shapedRecipe", + "2":"furnaceRecipe", + "3":"furnaceRecipeData", + "4":"enchantList" + }, + "default":"void" + } + ] + } + ] + } + ] + ] + }, + { + "name":"cleanRecipes", + "type":"i8" + } + ] + ], + "packet_crafting_event":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + }, + { + "name":"recipeType", + "type":"i32" + }, + { + "name":"recipeId", + "type":"uuid" + }, + { + "name":"input", + "type":"itemstacks" + }, + { + "name":"result", + "type":"itemstacks" + } + ] + ], + "packet_adventure_settings":[ + "container", + [ + { + "name":"flags", + "type":"i32" + }, + { + "name":"userPermission", + "type":"i32" + }, + { + "name":"globalPermission", + "type":"i32" + } + ] + ], + "packet_block_entity_data":[ + "container", + [ + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"namedtag", + "type":"restBuffer" + } + ] + ], + "packet_player_input":[ + "container", + [ + { + "name":"motionX", + "type":"f32" + }, + { + "name":"motionZ", + "type":"f32" + }, + { + "name":"flags", + "type":"i16" + } + ] + ], + "packet_full_chunk_data":[ + "container", + [ + { + "name":"chunkX", + "type":"i32" + }, + { + "name":"chunkZ", + "type":"i32" + }, + { + "name":"order", + "type":"i8" + }, + { + "name":"chunkData", + "type":[ + "buffer", + { + "countType":"i32" + } + ] + } + ] + ], + "packet_set_difficulty":[ + "container", + [ + { + "name":"difficulty", + "type":"i32" + } + ] + ], + "packet_player_list":[ + "container", + [ + { + "name":"type", + "type":"i8" + }, + { + "name":"entries", + "type":[ + "array", + { + "countType":"i32", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "0":[ + "container", + [ + { + "name":"clientUuid", + "type":"uuid" + }, + { + "name":"entityId", + "type":"i64" + }, + { + "name":"displayName", + "type":"string" + }, + { + "name":"skin", + "type":"skin" + } + ] + ], + "1":[ + "container", + [ + { + "name":"clientUuid", + "type":"uuid" + } + ] + ] + } + } + ] + } + ] + } + ] + ], + "packet_request_chunk_radius":[ + "container", + [ + { + "name":"chunkRadius", + "type":"i32" + } + ] + ], + "packet_chunk_radius_update":[ + "container", + [ + { + "name":"chunkRadius", + "type":"i32" + } + ] + ], + "packet_transfer":[ + "container", + [ + { + "name":"endpoint", + "type":"ipAddress" + } + ] + ], + "packet_spawn_experience_orb":[ + "container", + [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + }, + { + "name":"count", + "type":"i32" + } + ] + ], + "packet_replace_selected_item":[ + "container", + [ + { + "name":"slot", + "type":"slot" + } + ] + ] + } } From d910a96ee37799d19959eaa41bd83240c44fcb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 26 Oct 2016 15:05:42 +0200 Subject: [PATCH 033/106] Bump version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e4d8237..bb932c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pocket-minecraft-protocol", - "version": "2.2.3", - "description": "Parse and serialize Minecraft PE packets", + "version": "2.3.0", + "description": "Parse and serialize Minecraft Pocket Edition packets", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 44b262294de984538f60207302a61999bfa0cd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 26 Oct 2016 22:06:45 +0200 Subject: [PATCH 034/106] Add missing packets (doesn't work yet). --- data/protocol.json | 82 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 5139f1e..35c012b 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -586,6 +586,9 @@ "0x04":"client_to_server_handshake", "0x05":"disconnect", "0x06":"batch", + "0x07": "resource_pack_info", + "0x08": "resource_pack_stack", + "0x09": "resource_pack_client_response", "0x0a":"text", "0x0b":"set_time", "0x0c":"start_game", @@ -641,7 +644,10 @@ "0x44":"chunk_radius_update", "0x45":"item_frame_drop_item", "0x46":"replace_selected_item", - "0x49":"add_item_item" + "0x49":"add_item_item", + "0x4d": "resource_pack_data_info", + "0x4e": "resource_pack_chunk_data", + "0x4f": "resource_pack_chunk_request" } } ] @@ -659,6 +665,7 @@ "player_status":"packet_player_status", "disconnect":"packet_disconnect", "batch":"packet_batch", + "resource_pack_client_response": "packet_resource_pack_client_response", "text":"packet_text", "set_time":"packet_set_time", "start_game":"packet_start_game", @@ -810,6 +817,21 @@ } ] ], + + "packet_resource_pack_client_response": [ + "container", + [ + { + "name": "unknownByte", + "type": "i8" + }, + { + "name": "unknownShort", + "type": "i16" + } + ] + ], + "packet_text":[ "container", [ @@ -885,6 +907,26 @@ "packet_start_game":[ "container", [ + { + "name":"entityId", + "type":"i64" + }, + { + "name":"runtimeEntityId", + "type":"i64" + }, + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + }, + { + "name":"z", + "type":"f32" + }, { "name":"seed", "type":"i32" @@ -902,8 +944,8 @@ "type":"i8" }, { - "name":"entityId", - "type":"i64" + "name":"difficulty", + "type":"i8" }, { "name":"spawnX", @@ -918,19 +960,7 @@ "type":"i32" }, { - "name":"x", - "type":"f32" - }, - { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" - }, - { - "name":"isLoadedInCreative", + "name":"achievementsDisabled", "type":"bool" }, { @@ -941,6 +971,26 @@ "name":"eduMode", "type":"bool" }, + { + "name":"rainLevel", + "type":"f32" + }, + { + "name":"lightningLevel", + "type":"f32" + }, + { + "name":"enableCommands", + "type":"bool" + }, + { + "name":"requireResourcePack", + "type":"bool" + }, + { + "name":"unknownString1", + "type":"string" + }, { "name":"worldName", "type":"string" From ed6870f8d5abbc505f3d5798f81495cefd7a9009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 26 Oct 2016 22:36:32 +0200 Subject: [PATCH 035/106] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb932c8..ded725a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lodash.merge": "^4.4.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.0", - "raknet": "^1.8.0", + "raknet": "git+https://github.com/filfat/node-raknet.git", "uuid-1345": "^0.99.6" }, "devDependencies": { From a1b4c6b02ba6dfaa56e234c9b809ee22932f2d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 27 Oct 2016 10:38:48 +0200 Subject: [PATCH 036/106] Getting response now. --- data/protocol.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/protocol.json b/data/protocol.json index 35c012b..33322c2 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -774,6 +774,10 @@ "name":"protocol", "type":"i32" }, + { + "name": "edition", + "type": "i8" + }, { "name":"body", "type":[ From 89a63bb1371c934753afb981c8d14eca20186135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 27 Oct 2016 10:42:08 +0200 Subject: [PATCH 037/106] Apparently it's a byte array now. --- data/protocol.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/protocol.json b/data/protocol.json index 33322c2..1fb41b9 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -783,7 +783,7 @@ "type":[ "buffer", { - "countType":"i32" + "countType":"i8" } ] } From 7739d5c810cec77a1e3ed6dc0ffb356069795e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sat, 29 Oct 2016 17:05:08 +0200 Subject: [PATCH 038/106] Fix login packet. --- data/protocol.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/protocol.json b/data/protocol.json index 1fb41b9..ea3838d 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -783,7 +783,7 @@ "type":[ "buffer", { - "countType":"i8" + "countType":"varint" } ] } From 8e920e8399dbd4b1acbca5f3730132f222e2350e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sat, 29 Oct 2016 18:03:00 +0200 Subject: [PATCH 039/106] Update start game (doesn't work yet, need varlong) --- data/protocol.json | 56 +++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index ea3838d..16e9305 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -815,7 +815,7 @@ "type":[ "buffer", { - "countType":"i32" + "countType":"varint" } ] } @@ -900,7 +900,7 @@ [ { "name":"time", - "type":"i32" + "type":"varint" }, { "name":"started", @@ -913,43 +913,53 @@ [ { "name":"entityId", - "type":"i64" + "type":"i64", + "comment": "supposed to be varlong" }, { "name":"runtimeEntityId", - "type":"i64" + "type":"u64", + "comment": "supposed to be uvarlong" }, { "name":"x", - "type":"f32" + "type":"varint" }, { "name":"y", - "type":"f32" + "type":"varint" }, { "name":"z", - "type":"f32" + "type":"varint" + }, + { + "name":"unknownF1", + "type":"f64" + }, + { + "name":"unknownF2", + "type":"f64" }, { "name":"seed", - "type":"i32" + "type":"varint" }, { "name":"dimension", - "type":"i8" + "type":"varint" }, { "name":"generator", - "type":"i32" + "type":"varint" }, { "name":"gamemode", - "type":"i8" + "type":"varint" }, { "name":"difficulty", - "type":"i8" + "type":"varint" }, { "name":"spawnX", @@ -969,7 +979,7 @@ }, { "name":"dayCycleStopTime", - "type":"i8" + "type":"varint" }, { "name":"eduMode", @@ -977,11 +987,11 @@ }, { "name":"rainLevel", - "type":"f32" + "type":"f64" }, { "name":"lightningLevel", - "type":"f32" + "type":"f64" }, { "name":"enableCommands", @@ -992,7 +1002,7 @@ "type":"bool" }, { - "name":"unknownString1", + "name":"levelId", "type":"string" }, { @@ -1850,15 +1860,11 @@ [ { "name":"flags", - "type":"i32" + "type":"varint" }, { "name":"userPermission", - "type":"i32" - }, - { - "name":"globalPermission", - "type":"i32" + "type":"varint" } ] ], @@ -1905,11 +1911,11 @@ [ { "name":"chunkX", - "type":"i32" + "type":"varint" }, { "name":"chunkZ", - "type":"i32" + "type":"varint" }, { "name":"order", @@ -1920,7 +1926,7 @@ "type":[ "buffer", { - "countType":"i32" + "countType":"varint" } ] } From 27372031011c8d895b03ed6486db946d1883aa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Mon, 5 Dec 2016 20:40:32 +0100 Subject: [PATCH 040/106] Update protodef --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ded725a..0c6f27e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "jwt-simple": "^0.5.0", "lodash.merge": "^4.4.0", "prismarine-nbt": "^1.0.0", - "protodef": "^1.2.0", + "protodef": "git+https://github.com/deathcap/ProtoDef.git#varlong", "raknet": "git+https://github.com/filfat/node-raknet.git", "uuid-1345": "^0.99.6" }, From 332d0a5e49ee1795b28e77338552d40bbd538eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Mon, 5 Dec 2016 20:57:48 +0100 Subject: [PATCH 041/106] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c6f27e..f73a761 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "jwt-simple": "^0.5.0", "lodash.merge": "^4.4.0", "prismarine-nbt": "^1.0.0", - "protodef": "git+https://github.com/deathcap/ProtoDef.git#varlong", + "protodef": "^1.2.3", "raknet": "git+https://github.com/filfat/node-raknet.git", "uuid-1345": "^0.99.6" }, From 6332fe50729d1b43b49eccc3c055be85ab169777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 11 Dec 2016 00:33:24 +0100 Subject: [PATCH 042/106] Add minor fixes. --- data/protocol.json | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 16e9305..2d83570 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -355,19 +355,19 @@ [ { "name":"x", - "type":"i32" + "type":"varint" }, { "name":"z", - "type":"i32" + "type":"varint" }, { "name":"y", - "type":"i8" + "type":"varint" }, { "name":"blockId", - "type":"i8" + "type":"varint" }, { "anon":true, @@ -376,12 +376,12 @@ [ { "name":"blockData", - "size":4, + "size":8, "signed":false }, { "name":"flags", - "size":4, + "size":8, "signed":false } ] @@ -913,12 +913,12 @@ [ { "name":"entityId", - "type":"i64", + "type":"varint", "comment": "supposed to be varlong" }, { "name":"runtimeEntityId", - "type":"u64", + "type":"varint", "comment": "supposed to be uvarlong" }, { @@ -1917,10 +1917,6 @@ "name":"chunkZ", "type":"varint" }, - { - "name":"order", - "type":"i8" - }, { "name":"chunkData", "type":[ @@ -1937,7 +1933,7 @@ [ { "name":"difficulty", - "type":"i32" + "type":"varint" } ] ], @@ -2002,7 +1998,7 @@ [ { "name":"chunkRadius", - "type":"i32" + "type":"varint" } ] ], @@ -2011,7 +2007,7 @@ [ { "name":"chunkRadius", - "type":"i32" + "type":"varint" } ] ], From 559942de75c312c16926f83aba97de75ba73377d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 11 Dec 2016 19:13:32 +0100 Subject: [PATCH 043/106] Update protocol.json --- data/protocol.json | 79 +++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 2d83570..658d41d 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -640,6 +640,7 @@ "0x3e":"player_list", "0x3f":"telemetry_event", "0x40":"spawn_experience_orb", + "0x42":"map_info_request", "0x43":"request_chunk_radius", "0x44":"chunk_radius_update", "0x45":"item_frame_drop_item", @@ -665,6 +666,7 @@ "player_status":"packet_player_status", "disconnect":"packet_disconnect", "batch":"packet_batch", + "resource_pack_info": "packet_resource_pack_info", "resource_pack_client_response": "packet_resource_pack_client_response", "text":"packet_text", "set_time":"packet_set_time", @@ -713,11 +715,13 @@ "full_chunk_data":"packet_full_chunk_data", "set_difficulty":"packet_set_difficulty", "player_list":"packet_player_list", + "map_info_request": "packet_map_info_request", "request_chunk_radius":"packet_request_chunk_radius", "chunk_radius_update":"packet_chunk_radius_update", "transfer":"packet_transfer", "spawn_experience_orb":"packet_spawn_experience_orb", - "replace_selected_item":"packet_replace_selected_item" + "replace_selected_item":"packet_replace_selected_item", + "resource_pack_data_info": "packet_resource_pack_data_info" } } ] @@ -821,17 +825,37 @@ } ] ], - + "packet_resource_pack_info": [ + "container", + [ + { + "name":"mustAccept", + "type":"bool" + }, + { + "name":"behaviourPackLength", + "type":"u16" + }, + { + "name":"resourcePackLength", + "type":"u16" + } + ] + ], "packet_resource_pack_client_response": [ "container", [ { - "name": "unknownByte", + "name": "status", "type": "i8" }, { - "name": "unknownShort", - "type": "i16" + "name": "version", + "type": "string" + }, + { + "name": "size", + "type": "u32" } ] ], @@ -904,7 +928,7 @@ }, { "name":"started", - "type":"i8" + "type":"bool" } ] ], @@ -913,25 +937,23 @@ [ { "name":"entityId", - "type":"varint", - "comment": "supposed to be varlong" + "type":"varint" }, { "name":"runtimeEntityId", - "type":"varint", - "comment": "supposed to be uvarlong" + "type":"varint" }, { "name":"x", - "type":"varint" + "type":"f32" }, { "name":"y", - "type":"varint" + "type":"f32" }, { "name":"z", - "type":"varint" + "type":"f32" }, { "name":"unknownF1", @@ -963,15 +985,15 @@ }, { "name":"spawnX", - "type":"i32" + "type":"f32" }, { "name":"spawnY", - "type":"i32" + "type":"f32" }, { "name":"spawnZ", - "type":"i32" + "type":"f32" }, { "name":"achievementsDisabled", @@ -1211,7 +1233,7 @@ [ { "name":"entityId", - "type":"i64" + "type":"varint" }, { "name":"x", @@ -1226,7 +1248,7 @@ "type":"f32" }, { - "name":"yaw", + "name":"pitch", "type":"f32" }, { @@ -1234,7 +1256,7 @@ "type":"f32" }, { - "name":"pitch", + "name":"yaw", "type":"f32" }, { @@ -1243,7 +1265,7 @@ }, { "name":"onGround", - "type":"i8" + "type":"bool" } ] ], @@ -1502,9 +1524,13 @@ "name":"blockcoordinates", "type":"blockcoordinates" }, + { + "name":"unknown", + "type":"varint" + }, { "name":"face", - "type":"i8" + "type":"varint" }, { "name":"facecoordinates", @@ -1516,7 +1542,7 @@ }, { "name":"slot", - "type":"i32" + "type":"varint" }, { "name":"item", @@ -1993,6 +2019,15 @@ } ] ], + "map_info_request": [ + "container", + [ + { + "name":"mapID", + "type":"varint" + } + ] + ], "packet_request_chunk_radius":[ "container", [ From 0af8627d232382ae7245c2f27579a644d851f447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 11 Dec 2016 21:43:29 +0100 Subject: [PATCH 044/106] Update protocol.json --- data/protocol.json | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 658d41d..1bb2b80 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -867,6 +867,7 @@ "name":"type", "type":"i8" }, + { "name":"name", "type":[ @@ -1555,27 +1556,19 @@ [ { "name":"entityId", - "type":"i64" + "type":"varint" }, { "name":"actionId", - "type":"i32" + "type":"varint" }, { - "name":"x", - "type":"i32" - }, - { - "name":"y", - "type":"i32" - }, - { - "name":"z", - "type":"i32" + "name":"blockcoordinates", + "type":"blockcoordinates" }, { "name":"face", - "type":"i32" + "type":"varint" } ] ], @@ -1943,6 +1936,10 @@ "name":"chunkZ", "type":"varint" }, + { + "name":"order", + "type":"i8" + }, { "name":"chunkData", "type":[ From 0094941fd57fbf323b04e3cf2b4f2cd72690f5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Mon, 12 Dec 2016 08:44:19 +0100 Subject: [PATCH 045/106] Cleanup create server. --- src/createServer.js | 257 ++++++++++++++++++-------------------------- 1 file changed, 105 insertions(+), 152 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 1dec6a0..da78b6f 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,173 +1,126 @@ 'use strict'; -const raknet = require('raknet'); -const zlib = require('zlib'); -const ProtoDef = require('protodef').ProtoDef; -const Parser = require('protodef').Parser; -const Serializer = require('protodef').Serializer; -const jwt = require('jwt-simple'); -const crypto = require('crypto'); -const Ber = require('asn1').Ber; -const merge=require("lodash.merge"); -const assert=require("assert"); -var debug = require('debug')("raknet"); -// const BN = require('bn.js'); +let raknet = require('raknet'), + zlib = require('zlib'), + ProtoDef = require('protodef').ProtoDef, + Parser = require('protodef').Parser, + Serializer = require('protodef').Serializer, + jwt = require('jwt-simple'), + crypto = require('crypto'), + Ber = require('asn1').Ber, + merge = require('lodash.merge'), + assert = require('assert'); +var debug = require('debug')('raknet'); const batchProto = new ProtoDef(); -batchProto.addTypes(require("./datatypes/minecraft")); -batchProto.addType("insideBatch", ["endOfArray", { - "type": ["buffer", { - "countType": "i32" - }] +batchProto.addTypes(require('./datatypes/minecraft')); +batchProto.addType('insideBatch', ['endOfArray', { + 'type': ['buffer', { + 'countType': 'varint' + }] }]); -const dataProto = new ProtoDef(); -dataProto.addType("data_chain", ["container", [{ - "name": "chain", - "type": ["pstring", { - "countType": "li32" - }] -}, { - "name": "clientData", - "type": ["pstring", { - "countType": "li32" - }] -}]]); - - -function writeLI64(value, buffer, offset) { - buffer.writeInt32LE(value[0], offset+4); - buffer.writeInt32LE(value[1], offset); - return offset + 8; -} - -function computeCheckSum(packetPlaintext,sendCounter,secretKeyBytes) { - let digest = crypto.createHash('sha256'); - let counter=new Buffer(8); - writeLI64(sendCounter,counter,0); - digest.update(counter); - digest.update(packetPlaintext); - digest.update(secretKeyBytes); - let hash = digest.digest(); - - return hash.slice(0,8); -} - - -function readX509PublicKey(key) { - var reader = new Ber.Reader(new Buffer(key, "base64")); - reader.readSequence(); - reader.readSequence(); - reader.readOID(); - reader.readOID(); - return new Buffer(reader.readString(Ber.BitString, true)).slice(1); -} - -function writeX509PublicKey(key) { - var writer = new Ber.Writer(); - writer.startSequence(); - writer.startSequence(); - writer.writeOID("1.2.840.10045.2.1"); - writer.writeOID("1.3.132.0.34"); - writer.endSequence(); - writer.writeBuffer(Buffer.concat([new Buffer([0x00]),key]),Ber.BitString); - writer.endSequence(); - return writer.buffer.toString("base64"); -} - -const Transform = require('stream').Transform; - - const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; - function createServer(options) { - options = options || {}; - var port = options.port != null ? - options.port : - options['server-port'] != null ? - options['server-port'] : - 19132; - var host = options.host || '0.0.0.0'; + options = options || {}; + var port = options.port != null ? + options.port : + options['server-port'] != null ? + options['server-port'] : + 19132; + var host = options.host || '0.0.0.0'; - options.customPackets = require("../data/protocol"); - options.customTypes = require("./datatypes/minecraft"); - var server = raknet.createServer(options); + options.customPackets = require('../data/protocol'); + options.customTypes = require('./datatypes/minecraft'); + var server = raknet.createServer(options); - server.name = options.name || "Minecraft Server"; - server.motd = options.motd || "A Minecraft server"; - server.maxPlayers = options['max-players'] || 20; - server.playerCount = 0; + server.name = options.name || 'Minecraft Server'; + server.motd = options.motd || 'A Minecraft server'; + server.maxPlayers = options['max-players'] || 20; + server.playerCount = 0; - server.on("connection", function(client) { + server.on('connection', function(client) { - client.receiveCounter=0; - client.sendCounter=0; + client.receiveCounter=0; + client.sendCounter=0; - client.encryptionEnabled = false; + client.encryptionEnabled = false; - let proto = new ProtoDef(); - proto.addTypes(require("./datatypes/minecraft")); - proto.addTypes(require("../data/protocol").types); - client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); + let proto = new ProtoDef(); + proto.addTypes(require('./datatypes/minecraft')); + proto.addTypes(require('../data/protocol').types); + client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); - client.on("mcpe", packet => { - client.emit(packet.name, packet.params) - }); - - client.writeMCPE = (name, params) => { - if(client.encryptionEnabled) { - debug("write mcpe", name, params); - client.mcpePacketSerializer.write({ name, params }); - } - else { - client.writeEncapsulated("mcpe", { name, params }); - } - }; - - client.writeBatch = function(packets) { - const payload = zlib.deflateSync(batchProto.createPacketBuffer("insideBatch", - packets.map(packet => - client.mcpePacketSerializer.createPacketBuffer(packet)))); - - client.writeMCPE("batch", { - payload: payload + client.on('mcpe', packet => { + client.emit(packet.name, packet.params) }); - }; + + client.writeMCPE = (name, params) => { + if (client.encryptionEnabled) { + client.mcpePacketSerializer.write({ name, params }); + } + else { + client.writeEncapsulated('mcpe', { name, params }); + } + }; - client.on('batch', function(packet) { - var buf = zlib.inflateSync(packet.payload); - var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); + client.writeBatch = function(packets) { + const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', + packets.map(packet => + client.mcpePacketSerializer.createPacketBuffer(packet)))); + + client.writeMCPE('batch', { + payload: payload + }); + }; + + client.on('batch', function(packet) { + var buf = zlib.inflateSync(packet.payload); + var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); + }); + + client.on('game_login', (packet) => { + try { + const dataProto = new ProtoDef(); + dataProto.addType('data_chain', ['container', [{ + 'name': 'chain', + 'type': ['pstring', { + 'countType': 'li32' + }] + }, { + 'name': 'clientData', + 'type': ['pstring', { + 'countType': 'li32' + }] + }]]); + + let body = dataProto.parsePacketBuffer('data_chain', zlib.inflateSync(packet.body)), + chain = null, + decode = null, + data = null; + + body.data.chain = JSON.parse(body.data.chain); + chain = body.data.chain.chain[0]; + + decode = jwt.decode(chain, 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V', 'ES384'); + data = jwt.decode(body.data.clientData, decode.identityPublicKey, 'ES384'); + + data.SkinData = null; + client.emit('mcpe_login', { + protocol: packet.protocol, + uuid: (decode.extraData != null) ? decode.extraData.identity : null, + id: (decode.extraData != null) ? decode.extraData.identityPublicKey : null, + username: (decode.extraData != null) ? decode.extraData.displayName : null, + skinData: data.SkinData, + skinId: data.SkinId + }) + } catch(err) { + console.log(err); + } + }); }); - - client.on('client_to_server_handshake',() => { - client.emit('login_mcpe', { - displayName: client.displayName, - randomId: client.randomId, - skinData: client.skinData, - skinId: client.skinId, - identity: client.identity, - XUID: client.XUID - }); - }); - - - client.on('batch_non_encrypted', function(packet) { - var buf = zlib.inflateSync(packet.payload); - var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; - packets.forEach(packet => { - try { - debug("handle mcpe",packet); - var r = client.mcpePacketParser.parsePacketBuffer(packet); - client.emitPacket(r); - } - catch(err) { - client.emit("error",err); - } - }); - }); - }); - return server; + return server; } module.exports = createServer; From 710f4372e65c54a1917fde56c4ba0901414f820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 14 Dec 2016 18:19:16 +0100 Subject: [PATCH 046/106] Updated to automatically generated protocol. --- data/protocol.json | 2688 +++++++++++++++++++------------------------- 1 file changed, 1175 insertions(+), 1513 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 1bb2b80..ba86305 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -1,651 +1,197 @@ { - "types":{ - "string":[ + "types": { + "string": [ "pstring", { - "countType":"i16" + "countType": "i16" } ], - "lstring":[ + "lstring": [ "pstring", { - "countType":"li16" + "countType": "li16" } ], - "shapeless_recipe":[ + "vector3": [ "container", [ { - "name":"ingredientList", - "type":[ - "array", - { - "countType":"i32", - "type":"slot" - } - ] + "name": "x", + "type": "f32" }, { - "name":"resultCount", - "type":"i32" + "name": "y", + "type": "f32" }, { - "name":"slot", - "type":"slot" - }, - { - "name":"id", - "type":"uuid" + "name": "z", + "type": "f32" } ] ], - "shaped_recipe":[ + "vector2": [ "container", [ { - "name":"width", - "type":[ - "count", - { - "type":"i32", - "countFor":"shape" - } - ] + "name": "x", + "type": "f32" }, { - "name":"height", - "type":[ - "count", - { - "type":"i32", - "countFor":"shape/0" - } - ] - }, - { - "name":"shape", - "type":[ - "array", - { - "count":"width", - "type":[ - "array", - { - "count":"height", - "type":"slot" - } - ] - } - ] - }, - { - "name":"resultCount", - "type":"i32" - }, - { - "name":"slot", - "type":"slot" - }, - { - "name":"id", - "type":"uuid" + "name": "y", + "type": "f32" } ] ], - "furnace_recipe":[ - "container", - [ - { - "name":"meta", - "type":"i16" - }, - { - "name":"id", - "type":"i16" - }, - { - "name":"result", - "type":"slot" - } - ] - ], - "furnace_recipe_data":[ - "container", - [ - { - "name":"id", - "type":"i16" - }, - { - "name":"meta", - "type":"i16" - }, - { - "name":"result", - "type":"slot" - } - ] - ], - "enchant_list":[ + "playerlocation": [ "array", { - "countType":"i8", - "type":[ + "countType": "i16", + "type": [ "container", [ { - "name":"cost", - "type":"i32" + "name": "x", + "type": "f32" }, { - "name":"enchantments", - "type":[ - "array", - { - "countType":"i8", - "type":[ - "container", - [ - { - "name":"id", - "type":"i32" - }, - { - "name":"level", - "type":"i32" - } - ] - ] - } - ] + "name": "y", + "type": "f32" }, { - "name":"name", - "type":"string" + "name": "z", + "type": "f32" + }, + { + "name": "yaw", + "type": "f32" + }, + { + "name": "pitch", + "type": "f32" + }, + { + "name": "headYaw", + "type": "f32" } ] ] } ], - "entityMetadataItem":[ - "switch", - { - "compareTo":"$compareTo", - "fields":{ - "0":"li8", - "1":"li16", - "2":"li32", - "3":"lf32", - "4":"lstring", - "5":[ - "container", - [ - { - "name":"blockId", - "type":"li16" - }, - { - "name":"itemCount", - "type":"li8" - }, - { - "name":"itemDamage", - "type":"li16" - } - ] - ], - "6":[ - "container", - [ - { - "name":"x", - "type":"li32" - }, - { - "name":"y", - "type":"li32" - }, - { - "name":"z", - "type":"li32" - } - ] - ], - "7":[ - "container", - [ - { - "name":"pitch", - "type":"lf32" - }, - { - "name":"yaw", - "type":"lf32" - }, - { - "name":"roll", - "type":"lf32" - } - ] - ], - "8":"li64" - } - } - ], - "metadatadictionary":[ - "entityMetadataLoop", - { - "endVal":127, - "type":[ - "container", - [ - { - "anon":true, - "type":[ - "bitfield", - [ - { - "name":"type", - "size":3, - "signed":false - }, - { - "name":"key", - "size":5, - "signed":false - } - ] - ] - }, - { - "name":"value", - "type":[ - "entityMetadataItem", - { - "compareTo":"type" - } - ] - } - ] - ] - } - ], - "slot":[ + "encapsulated_packet": [ "container", [ { - "name":"blockId", - "type":"i16" - }, - { - "anon":true, - "type":[ - "switch", - { - "compareTo":"blockId", - "fields":{ - "0":"void" - }, - "default":[ - "container", - [ - { - "name":"itemCount", - "type":"i8" - }, - { - "name":"itemDamage", - "type":"i16" - }, - { - "name":"nbtData", - "type":[ - "buffer", - { - "countType":"li16" - } - ] - } - ] - ] - } - ] - } - ] - ], - "itemstacks":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"slot", - "type":"itemstacks" - } - ] - ] - } - ], - "skin":[ - "container", - [ - { - "name":"skin_type", - "type":"string" - }, - { - "name":"texture", - "type":[ - "buffer", - { - "countType":"i16" - } - ] - } - ] - ], - "blockrecords":[ - "array", - { - "countType":"i32", - "type":[ - "container", - [ - { - "name":"x", - "type":"varint" - }, - { - "name":"z", - "type":"varint" - }, - { - "name":"y", - "type":"varint" - }, - { - "name":"blockId", - "type":"varint" - }, - { - "anon":true, - "type":[ - "bitfield", - [ - { - "name":"blockData", - "size":8, - "signed":false - }, - { - "name":"flags", - "size":8, - "signed":false - } - ] - ] - } - ] - ] - } - ], - "records":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"x", - "type":"i8" - }, - { - "name":"y", - "type":"i8" - }, - { - "name":"z", - "type":"i8" - } - ] - ] - } - ], - "playerattributes":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"minValue", - "type":"f32" - }, - { - "name":"maxValue", - "type":"f32" - }, - { - "name":"id", - "type":"f32" - }, - { - "name":"name", - "type":"string" - } - ] - ] - } - ], - "entitymotions":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"eid", - "type":"i64" - }, - { - "name":"motX", - "type":"f32" - }, - { - "name":"motY", - "type":"f32" - }, - { - "name":"motZ", - "type":"f32" - } - ] - ] - } - ], - "vector3":[ - "container", - [ - { - "name":"x", - "type":"f32" - }, - { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" - } - ] - ], - "blockcoordinates":[ - "container", - [ - { - "name":"x", - "type":"i32" - }, - { - "name":"y", - "type":"i32" - }, - { - "name":"z", - "type":"i32" - } - ] - ], - "entitylocations":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"eid", - "type":"i64" - }, - { - "name":"x", - "type":"f32" - }, - { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" - }, - { - "name":"yaw", - "type":"f32" - }, - { - "name":"headYaw", - "type":"f32" - }, - { - "name":"pitch", - "type":"f32" - } - ] - ] - } - ], - "encapsulated_packet":[ - "container", - [ - { - "name":"name", - "type":[ + "name": "name", + "type": [ "mapper", { - "type":"u8", - "mappings":{ - "0xfe":"mcpe" + "type": "u8", + "mappings": { + "0xfe": "mcpe" } } ] }, { - "name":"params", - "type":[ + "name": "params", + "type": [ "switch", { - "compareTo":"name", - "fields":{ - "mcpe":"mcpe_packet" + "compareTo": "name", + "fields": { + "mcpe": "mcpe_packet" } } ] } ] ], - "mcpe_packet":[ + "mcpe_packet": [ "container", [ { - "name":"name", - "type":[ + "name": "name", + "type": [ "mapper", { - "type":"u8", - "mappings":{ - "0x01":"game_login", - "0x02":"player_status", - "0x03":"server_to_client_handshake", - "0x04":"client_to_server_handshake", - "0x05":"disconnect", - "0x06":"batch", - "0x07": "resource_pack_info", + "type": "u8", + "mappings": { + "0x01": "game_login", + "0x02": "player_status", + "0x03": "server_to_client_handshake", + "0x04": "client_to_server_handshake", + "0x05": "disconnect", + "0x06": "batch", + "0x07": "resource_packs_info", "0x08": "resource_pack_stack", "0x09": "resource_pack_client_response", - "0x0a":"text", - "0x0b":"set_time", - "0x0c":"start_game", - "0x0d":"add_player", - "0x0e":"add_entity", - "0x0f":"remove_entity", - "0x10":"add_item_entity", - "0x12":"take_item_entity", - "0x13":"move_entity", - "0x14":"move_player", - "0x15":"rider_jump", - "0x16":"remove_block", - "0x17":"update_block", - "0x18":"add_painting", - "0x19":"explode", - "0x1a":"level_event", - "0x1c":"block_event", - "0x1d":"entity_event", - "0x1e":"mob_effect", - "0x1f":"update_attributes", - "0x20":"mob_equipment", - "0x21":"mob_armor_equipment", - "0x22":"interact", - "0x23":"use_item", - "0x24":"player_action", - "0x25":"hurt_armor", - "0x26":"set_entity_data", - "0x27":"set_entity_motion", - "0x28":"set_entity_link", - "0x29":"set_health", - "0x2a":"set_spawn_position", - "0x2b":"animate", - "0x2c":"respawn", - "0x2d":"drop_item", - "0x2f":"container_open", - "0x30":"container_close", - "0x31":"container_set_slot", - "0x32":"container_set_data", - "0x33":"container_set_content", - "0x34":"crafting_data", - "0x35":"crafting_event", - "0x36":"adventure_settings", - "0x37":"block_entity_data", - "0x38":"player_input", - "0x39":"full_chunk_data", - "0x3b":"set_difficulty", - "0x3c":"change_dimension", - "0x3d":"set_player_gametype", - "0x3e":"player_list", - "0x3f":"telemetry_event", - "0x40":"spawn_experience_orb", - "0x42":"map_info_request", - "0x43":"request_chunk_radius", - "0x44":"chunk_radius_update", - "0x45":"item_frame_drop_item", - "0x46":"replace_selected_item", - "0x49":"add_item_item", + "0x0a": "text", + "0x0b": "set_time", + "0x0c": "start_game", + "0x0d": "add_player", + "0x0e": "add_entity", + "0x0f": "remove_entity", + "0x10": "add_item_entity", + "0x11": "add_hanging_entity", + "0x12": "take_item_entity", + "0x13": "move_entity", + "0x14": "move_player", + "0x15": "rider_jump", + "0x16": "remove_block", + "0x17": "update_block", + "0x18": "add_painting", + "0x19": "explode", + "0x1a": "level_sound_event", + "0x1b": "level_event", + "0x1c": "block_event", + "0x1d": "entity_event", + "0x1e": "mob_effect", + "0x1f": "update_attributes", + "0x20": "mob_equipment", + "0x21": "mob_armor_equipment", + "0x22": "interact", + "0x23": "use_item", + "0x24": "player_action", + "0x25": "hurt_armor", + "0x26": "set_entity_data", + "0x27": "set_entity_motion", + "0x28": "set_entity_link", + "0x29": "set_health", + "0x2a": "set_spawn_position", + "0x2b": "animate", + "0x2c": "respawn", + "0x2d": "drop_item", + "0x2e": "inventory_action", + "0x2f": "container_open", + "0x30": "container_close", + "0x31": "container_set_slot", + "0x32": "container_set_data", + "0x33": "container_set_content", + "0x34": "crafting_data", + "0x35": "crafting_event", + "0x36": "adventure_settings", + "0x37": "block_entity_data", + "0x38": "player_input", + "0x39": "full_chunk_data", + "0x3a": "set_commands_enabled", + "0x3b": "set_difficulty", + "0x3c": "change_dimension", + "0x3d": "set_player_game_type", + "0x3e": "player_list", + "0x3f": "event", + "0x40": "spawn_experience_orb", + "0x41": "clientbound_map_item_data_", + "0x42": "map_info_request", + "0x43": "request_chunk_radius", + "0x44": "chunk_radius_update", + "0x45": "item_fram_drop_item", + "0x46": "replace_selected_item", + "0x47": "game_rules_changed", + "0x48": "camera", + "0x49": "add_item", + "0x4a": "boss_event", + "0x4b": "available_commands", + "0x4c": "command_step", "0x4d": "resource_pack_data_info", "0x4e": "resource_pack_chunk_data", "0x4f": "resource_pack_chunk_request" @@ -654,191 +200,214 @@ ] }, { - "name":"params", - "type":[ + "name": "params", + "type": [ "switch", { - "compareTo":"name", - "fields":{ - "server_to_client_handshake":"packet_server_to_client_handshake", - "client_to_server_handshake":"packet_client_to_server_handshake", - "game_login":"packet_game_login", - "player_status":"packet_player_status", - "disconnect":"packet_disconnect", - "batch":"packet_batch", - "resource_pack_info": "packet_resource_pack_info", + "compareTo": "name", + "fields": { + "game_login": "packet_game_login", + "player_status": "packet_player_status", + "server_to_client_handshake": "packet_server_to_client_handshake", + "client_to_server_handshake": "packet_client_to_server_handshake", + "disconnect": "packet_disconnect", + "batch": "packet_batch", + "resource_packs_info": "packet_resource_packs_info", + "resource_pack_stack": "packet_resource_pack_stack", "resource_pack_client_response": "packet_resource_pack_client_response", - "text":"packet_text", - "set_time":"packet_set_time", - "start_game":"packet_start_game", - "add_player":"packet_add_player", - "remove_player":"packet_remove_player", - "add_entity":"packet_add_entity", - "remove_entity":"packet_remove_entity", - "add_item_entity":"packet_add_item_entity", - "take_item_entity":"packet_take_item_entity", - "move_entity":"packet_move_entity", - "move_player":"packet_move_player", - "remove_block":"packet_remove_block", - "update_block":"packet_update_block", - "add_painting":"packet_add_painting", - "explode":"packet_explode", - "level_event":"packet_level_event", - "block_event":"packet_block_event", - "entity_event":"packet_entity_event", - "mob_effect":"packet_mob_effect", - "update_attributes":"packet_update_attributes", - "mob_equipment":"packet_mob_equipment", - "mob_armor_equipment":"packet_mob_armor_equipment", - "interact":"packet_interact", - "use_item":"packet_use_item", - "player_action":"packet_player_action", - "hurt_armor":"packet_hurt_armor", - "set_entity_data":"packet_set_entity_data", - "set_entity_motion":"packet_set_entity_motion", - "set_entity_link":"packet_set_entity_link", - "set_health":"packet_set_health", - "set_spawn_position":"packet_set_spawn_position", - "animate":"packet_animate", - "respawn":"packet_respawn", - "drop_item":"packet_drop_item", - "container_open":"packet_container_open", - "container_close":"packet_container_close", - "container_set_slot":"packet_container_set_slot", - "container_set_data":"packet_container_set_data", - "container_set_content":"packet_container_set_content", - "crafting_data":"packet_crafting_data", - "crafting_event":"packet_crafting_event", - "adventure_settings":"packet_adventure_settings", - "block_entity_data":"packet_block_entity_data", - "player_input":"packet_player_input", - "full_chunk_data":"packet_full_chunk_data", - "set_difficulty":"packet_set_difficulty", - "player_list":"packet_player_list", + "text": "packet_text", + "set_time": "packet_set_time", + "start_game": "packet_start_game", + "add_player": "packet_add_player", + "add_entity": "packet_add_entity", + "remove_entity": "packet_remove_entity", + "add_item_entity": "packet_add_item_entity", + "add_hanging_entity": "packet_add_hanging_entity", + "take_item_entity": "packet_take_item_entity", + "move_entity": "packet_move_entity", + "move_player": "packet_move_player", + "rider_jump": "packet_rider_jump", + "remove_block": "packet_remove_block", + "update_block": "packet_update_block", + "add_painting": "packet_add_painting", + "explode": "packet_explode", + "level_sound_event": "packet_level_sound_event", + "level_event": "packet_level_event", + "block_event": "packet_block_event", + "entity_event": "packet_entity_event", + "mob_effect": "packet_mob_effect", + "update_attributes": "packet_update_attributes", + "mob_equipment": "packet_mob_equipment", + "mob_armor_equipment": "packet_mob_armor_equipment", + "interact": "packet_interact", + "use_item": "packet_use_item", + "player_action": "packet_player_action", + "hurt_armor": "packet_hurt_armor", + "set_entity_data": "packet_set_entity_data", + "set_entity_motion": "packet_set_entity_motion", + "set_entity_link": "packet_set_entity_link", + "set_health": "packet_set_health", + "set_spawn_position": "packet_set_spawn_position", + "animate": "packet_animate", + "respawn": "packet_respawn", + "drop_item": "packet_drop_item", + "inventory_action": "packet_inventory_action", + "container_open": "packet_container_open", + "container_close": "packet_container_close", + "container_set_slot": "packet_container_set_slot", + "container_set_data": "packet_container_set_data", + "container_set_content": "packet_container_set_content", + "crafting_data": "packet_crafting_data", + "crafting_event": "packet_crafting_event", + "adventure_settings": "packet_adventure_settings", + "block_entity_data": "packet_block_entity_data", + "player_input": "packet_player_input", + "full_chunk_data": "packet_full_chunk_data", + "set_commands_enabled": "packet_set_commands_enabled", + "set_difficulty": "packet_set_difficulty", + "change_dimension": "packet_change_dimension", + "set_player_game_type": "packet_set_player_game_type", + "player_list": "packet_player_list", + "event": "packet_event", + "spawn_experience_orb": "packet_spawn_experience_orb", + "clientbound_map_item_data_": "packet_clientbound_map_item_data_", "map_info_request": "packet_map_info_request", - "request_chunk_radius":"packet_request_chunk_radius", - "chunk_radius_update":"packet_chunk_radius_update", - "transfer":"packet_transfer", - "spawn_experience_orb":"packet_spawn_experience_orb", - "replace_selected_item":"packet_replace_selected_item", - "resource_pack_data_info": "packet_resource_pack_data_info" + "request_chunk_radius": "packet_request_chunk_radius", + "chunk_radius_update": "packet_chunk_radius_update", + "item_fram_drop_item": "packet_item_fram_drop_item", + "replace_selected_item": "packet_replace_selected_item", + "game_rules_changed": "packet_game_rules_changed", + "camera": "packet_camera", + "add_item": "packet_add_item", + "boss_event": "packet_boss_event", + "available_commands": "packet_available_commands", + "command_step": "packet_command_step", + "resource_pack_data_info": "packet_resource_pack_data_info", + "resource_pack_chunk_data": "packet_resource_pack_chunk_data", + "resource_pack_chunk_request": "packet_resource_pack_chunk_request" } } ] } ] ], - "packet_id_detect_lost_connections":[ - "container", - [ - - ] - ], - "packet_id_no_free_incoming_connections":[ - "container", - [ - - ] - ], - "packet_id_connection_banned":[ - "container", - [ - - ] - ], - "packet_id_ip_recently_connected":[ - "container", - [ - - ] - ], - "packet_server_to_client_handshake":[ + "packet_game_login": [ "container", [ { - "name":"publicKey", - "type":"string" - }, - { - "name":"serverToken", - "type":"string" - } - ] - ], - "packet_client_to_server_handshake":[ - "container", - [ - - ] - ], - "packet_game_login":[ - "container", - [ - { - "name":"protocol", - "type":"i32" + "name": "protocol", + "type": "i32" }, { "name": "edition", "type": "i8" }, { - "name":"body", - "type":[ + "name": "body", + "type": [ "buffer", { - "countType":"varint" + "countType": "varint" } ] } ] ], - "packet_player_status":[ + "packet_player_status": [ "container", [ { - "name":"status", - "type":"i32" + "name": "status", + "type": "i32" } ] ], - "packet_disconnect":[ + "packet_server_to_client_handshake": [ "container", [ { - "name":"message", - "type":"string" - } - ] - ], - "packet_batch":[ - "container", - [ + "name": "server_public_key", + "type": "string" + }, { - "name":"payload", - "type":[ + "name": "token_length", + "type": "length" + }, + { + "name": "token", + "type": [ "buffer", { - "countType":"varint" + "countType": "varint", + "type": "i8" } ] } ] ], - "packet_resource_pack_info": [ + "packet_client_to_server_handshake": [ + "container", + [] + ], + "packet_disconnect": [ "container", [ { - "name":"mustAccept", - "type":"bool" + "name": "hide_disconnect_reason", + "type": "bool" }, { - "name":"behaviourPackLength", - "type":"u16" + "name": "message", + "type": "string" + } + ] + ], + "packet_batch": [ + "container", + [ + { + "name": "payload", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] + } + ] + ], + "packet_resource_packs_info": [ + "container", + [ + { + "name": "must_accept", + "type": "bool" }, { - "name":"resourcePackLength", - "type":"u16" + "name": "behahaviorpackinfos", + "type": "varint" + }, + { + "name": "resourcepackinfos", + "type": "varint" + } + ] + ], + "packet_resource_pack_stack": [ + "container", + [ + { + "name": "must_accept", + "type": "bool" + }, + { + "name": "behaviorpackidversions", + "type": "varint" + }, + { + "name": "resourcepackidversions", + "type": "varint" } ] ], @@ -846,1243 +415,1336 @@ "container", [ { - "name": "status", + "name": "response_status", + "type": "u8" + }, + { + "name": "resourcepackidversions", + "type": "varint" + } + ] + ], + "packet_text": [ + "container", + [ + { + "name": "type", "type": "i8" }, { - "name": "version", + "name": "source", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "1": "string", + "3": "string" + }, + "default": "void" + } + ] + }, + { + "name": "message", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string" + }, + "default": "void" + } + ] + } + ] + ], + "packet_set_time": [ + "container", + [ + { + "name": "time", + "type": "varint" + }, + { + "name": "started", + "type": "bool" + } + ] + ], + "packet_start_game": [ + "container", + [ + { + "name": "entity_id", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "spawn", + "type": "vector3" + }, + { + "name": "unknown_1", + "type": "vector2" + }, + { + "name": "seed", + "type": "varint" + }, + { + "name": "dimension", + "type": "varint" + }, + { + "name": "generator", + "type": "varint" + }, + { + "name": "gamemode", + "type": "varint" + }, + { + "name": "difficulty", + "type": "varint" + }, + { + "name": "x", + "type": "varint" + }, + { + "name": "y", + "type": "varint" + }, + { + "name": "z", + "type": "varint" + }, + { + "name": "has_achievements_disabled", + "type": "bool" + }, + { + "name": "day_cycle_stop_time", + "type": "varint" + }, + { + "name": "edu_mode", + "type": "bool" + }, + { + "name": "rain_level", + "type": "f32" + }, + { + "name": "lightnig_level", + "type": "f32" + }, + { + "name": "enable_commands", + "type": "bool" + }, + { + "name": "is_texturepacks_required", + "type": "bool" + }, + { + "name": "secret", "type": "string" }, { - "name": "size", - "type": "u32" + "name": "world_name", + "type": "string" } ] ], - - "packet_text":[ + "packet_add_player": [ "container", [ { - "name":"type", - "type":"i8" - }, - - { - "name":"name", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "1":"string", - "3":"string" - }, - "default":"void" - } - ] + "name": "uuid", + "type": "uuid" }, { - "name":"message", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "0":"string", - "1":"string", - "2":"string", - "3":"string", - "4":"string", - "5":"string" - } - } - ] + "name": "username", + "type": "string" }, { - "name":"parameters", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "2":[ - "array", - { - "countType":"i8", - "type":"string" - } - ] - }, - "default":"void" - } - ] + "name": "entity_id", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "x", + "type": "f32" + }, + { + "name": "y", + "type": "f32" + }, + { + "name": "z", + "type": "f32" + }, + { + "name": "speed_x", + "type": "f32" + }, + { + "name": "speed_y", + "type": "f32" + }, + { + "name": "speed_z", + "type": "f32" + }, + { + "name": "pitch", + "type": "f32" + }, + { + "name": "head_yaw", + "type": "f32" + }, + { + "name": "yaw", + "type": "f32" + }, + { + "name": "item", + "type": "varint" + }, + { + "name": "metadata", + "type": "varint" } ] ], - "packet_set_time":[ + "packet_add_entity": [ "container", [ { - "name":"time", - "type":"varint" + "name": "entity_id", + "type": "varint" }, { - "name":"started", - "type":"bool" + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "entity_type", + "type": "varint" + }, + { + "name": "x", + "type": "f32" + }, + { + "name": "y", + "type": "f32" + }, + { + "name": "z", + "type": "f32" + }, + { + "name": "speed_x", + "type": "f32" + }, + { + "name": "speed_y", + "type": "f32" + }, + { + "name": "speed_z", + "type": "f32" + }, + { + "name": "yaw", + "type": "f32" + }, + { + "name": "pitch", + "type": "f32" + }, + { + "name": "attributes", + "type": "varint" + }, + { + "name": "metadata", + "type": "varint" + }, + { + "name": "links", + "type": "links" } ] ], - "packet_start_game":[ + "packet_remove_entity": [ "container", [ { - "name":"entityId", - "type":"varint" - }, - { - "name":"runtimeEntityId", - "type":"varint" - }, - { - "name":"x", - "type":"f32" - }, - { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" - }, - { - "name":"unknownF1", - "type":"f64" - }, - { - "name":"unknownF2", - "type":"f64" - }, - { - "name":"seed", - "type":"varint" - }, - { - "name":"dimension", - "type":"varint" - }, - { - "name":"generator", - "type":"varint" - }, - { - "name":"gamemode", - "type":"varint" - }, - { - "name":"difficulty", - "type":"varint" - }, - { - "name":"spawnX", - "type":"f32" - }, - { - "name":"spawnY", - "type":"f32" - }, - { - "name":"spawnZ", - "type":"f32" - }, - { - "name":"achievementsDisabled", - "type":"bool" - }, - { - "name":"dayCycleStopTime", - "type":"varint" - }, - { - "name":"eduMode", - "type":"bool" - }, - { - "name":"rainLevel", - "type":"f64" - }, - { - "name":"lightningLevel", - "type":"f64" - }, - { - "name":"enableCommands", - "type":"bool" - }, - { - "name":"requireResourcePack", - "type":"bool" - }, - { - "name":"levelId", - "type":"string" - }, - { - "name":"worldName", - "type":"string" + "name": "entity_id", + "type": "varint" } ] ], - "packet_add_player":[ + "packet_add_item_entity": [ "container", [ { - "name":"uuid", - "type":"uuid" + "name": "entity_id", + "type": "varint" }, { - "name":"username", - "type":"string" + "name": "runtime_entity_id", + "type": "varint" }, { - "name":"entityId", - "type":"i64" + "name": "item", + "type": "varint" }, { - "name":"x", - "type":"f32" + "name": "x", + "type": "f32" }, { - "name":"y", - "type":"f32" + "name": "y", + "type": "f32" }, { - "name":"z", - "type":"f32" + "name": "z", + "type": "f32" }, { - "name":"speedX", - "type":"f32" + "name": "speed_x", + "type": "f32" }, { - "name":"speedY", - "type":"f32" + "name": "speed_y", + "type": "f32" }, { - "name":"speedZ", - "type":"f32" - }, - { - "name":"yaw", - "type":"f32" - }, - { - "name":"headYaw", - "type":"f32" - }, - { - "name":"pitch", - "type":"f32" - }, - { - "name":"item", - "type":"slot" - }, - { - "name":"metadata", - "type":"metadatadictionary" + "name": "speed_z", + "type": "f32" } ] ], - "packet_remove_player":[ + "packet_add_hanging_entity": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "entity_id", + "type": "varint" }, { - "name":"clientUuid", - "type":"uuid" + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "unknown", + "type": "varint" } ] ], - "packet_add_entity":[ + "packet_take_item_entity": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "target", + "type": "varint" }, { - "name":"entityType", - "type":"i32" - }, - { - "name":"x", - "type":"f32" - }, - { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" - }, - { - "name":"speedX", - "type":"f32" - }, - { - "name":"speedY", - "type":"f32" - }, - { - "name":"speedZ", - "type":"f32" - }, - { - "name":"yaw", - "type":"f32" - }, - { - "name":"pitch", - "type":"f32" - }, - { - "name":"metadata", - "type":"metadatadictionary" - }, - { - "name":"links", - "type":"i16" + "name": "entity_id", + "type": "varint" } ] ], - "packet_remove_entity":[ + "packet_move_entity": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "entity_id", + "type": "varint" + }, + { + "name": "position", + "type": "playerlocation" } ] ], - "packet_add_item_entity":[ + "packet_move_player": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "entity_id", + "type": "varint" }, { - "name":"item", - "type":"slot" + "name": "x", + "type": "f32" }, { - "name":"x", - "type":"f32" + "name": "y", + "type": "f32" }, { - "name":"y", - "type":"f32" + "name": "z", + "type": "f32" }, { - "name":"z", - "type":"f32" + "name": "pitch", + "type": "f32" }, { - "name":"speedX", - "type":"f32" + "name": "head_yaw", + "type": "f32" }, { - "name":"speedY", - "type":"f32" + "name": "yaw", + "type": "f32" }, { - "name":"speedZ", - "type":"f32" + "name": "mode", + "type": "u8" + }, + { + "name": "on_ground", + "type": "bool" } ] ], - "packet_take_item_entity":[ + "packet_rider_jump": [ + "container", + [] + ], + "packet_remove_block": [ "container", [ { - "name":"target", - "type":"i64" - }, - { - "name":"entityId", - "type":"i64" + "name": "coordinates", + "type": "varint" } ] ], - "packet_move_entity":[ + "packet_update_block": [ "container", [ { - "name":"entities", - "type":"entitylocations" + "name": "coordinates", + "type": "varint" + }, + { + "name": "block_id", + "type": "varint" + }, + { + "name": "block_meta_and_priority", + "type": "varint" } ] ], - "packet_move_player":[ + "packet_add_painting": [ "container", [ { - "name":"entityId", - "type":"varint" + "name": "entity_id", + "type": "varint" }, { - "name":"x", - "type":"f32" + "name": "runtime_entity_id", + "type": "varint" }, { - "name":"y", - "type":"f32" + "name": "coordinates", + "type": "varint" }, { - "name":"z", - "type":"f32" + "name": "direction", + "type": "varint" }, { - "name":"pitch", - "type":"f32" - }, - { - "name":"headYaw", - "type":"f32" - }, - { - "name":"yaw", - "type":"f32" - }, - { - "name":"mode", - "type":"i8" - }, - { - "name":"onGround", - "type":"bool" + "name": "title", + "type": "string" } ] ], - "packet_remove_block":[ + "packet_explode": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "position", + "type": "vector3" }, { - "name":"x", - "type":"i32" + "name": "radius", + "type": "f32" }, { - "name":"z", - "type":"i32" - }, - { - "name":"y", - "type":"i8" + "name": "records", + "type": "varint" } ] ], - "packet_update_block":[ + "packet_level_sound_event": [ "container", [ { - "name":"blocks", - "type":"blockrecords" + "name": "sound_id", + "type": "u8" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "volume", + "type": "varint" + }, + { + "name": "pitch", + "type": "varint" + }, + { + "name": "unknown1", + "type": "bool" + }, + { + "name": "unknown2", + "type": "bool" } ] ], - "packet_add_painting":[ + "packet_level_event": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "event_id", + "type": "varint" }, { - "name":"x", - "type":"i32" + "name": "x", + "type": "f32" }, { - "name":"y", - "type":"i32" + "name": "y", + "type": "f32" }, { - "name":"z", - "type":"i32" + "name": "z", + "type": "f32" }, { - "name":"direction", - "type":"i32" - }, - { - "name":"title", - "type":"string" + "name": "data", + "type": "varint" } ] ], - "packet_explode":[ + "packet_block_event": [ "container", [ { - "name":"x", - "type":"f32" + "name": "coordinates", + "type": "varint" }, { - "name":"y", - "type":"f32" + "name": "case_1", + "type": "varint" }, { - "name":"z", - "type":"f32" - }, - { - "name":"radius", - "type":"f32" - }, - { - "name":"records", - "type":"records" + "name": "case_2", + "type": "varint" } ] ], - "packet_level_event":[ + "packet_entity_event": [ "container", [ { - "name":"eventId", - "type":"i16" + "name": "entity_id", + "type": "varint" }, { - "name":"x", - "type":"f32" + "name": "event_id", + "type": "u8" }, { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" - }, - { - "name":"data", - "type":"i32" + "name": "unknown", + "type": "varint" } ] ], - "packet_block_event":[ + "packet_mob_effect": [ "container", [ { - "name":"x", - "type":"i32" + "name": "entity_id", + "type": "varint" }, { - "name":"y", - "type":"i32" + "name": "event_id", + "type": "u8" }, { - "name":"z", - "type":"i32" + "name": "effect_id", + "type": "varint" }, { - "name":"case1", - "type":"i32" + "name": "amplifier", + "type": "varint" }, { - "name":"case2", - "type":"i32" + "name": "particles", + "type": "bool" + }, + { + "name": "duration", + "type": "varint" } ] ], - "packet_entity_event":[ + "packet_update_attributes": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "entity_id", + "type": "varint" }, { - "name":"eventId", - "type":"i8" + "name": "attributes", + "type": "varint" } ] ], - "packet_mob_effect":[ + "packet_mob_equipment": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "entity_id", + "type": "varint" }, { - "name":"eventId", - "type":"i8" + "name": "item", + "type": "varint" }, { - "name":"effectId", - "type":"i8" + "name": "slot", + "type": "u8" }, { - "name":"amplifier", - "type":"i8" + "name": "selected_slot", + "type": "u8" }, { - "name":"particles", - "type":"i8" - }, - { - "name":"duration", - "type":"i32" + "name": "unknown", + "type": "u8" } ] ], - "packet_update_attributes":[ + "packet_mob_armor_equipment": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "entity_id", + "type": "varint" }, { - "name":"attributes", - "type":"playerattributes" + "name": "helmet", + "type": "varint" + }, + { + "name": "chestplate", + "type": "varint" + }, + { + "name": "leggings", + "type": "varint" + }, + { + "name": "boots", + "type": "varint" } ] ], - "packet_mob_equipment":[ + "packet_interact": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "action_id", + "type": "u8" }, { - "name":"item", - "type":"slot" - }, - { - "name":"slot", - "type":"i8" - }, - { - "name":"selectedSlot", - "type":"i8" + "name": "target_entity_id", + "type": "varint" } ] ], - "packet_mob_armor_equipment":[ + "packet_use_item": [ "container", [ { - "name":"entityId", - "type":"i64" + "name": "blockcoordinates", + "type": "varint" }, { - "name":"helmet", - "type":"slot" + "name": "face", + "type": "varint" }, { - "name":"chestplate", - "type":"slot" + "name": "facecoordinates", + "type": "vector3" }, { - "name":"leggings", - "type":"slot" + "name": "playerposition", + "type": "vector3" }, { - "name":"boots", - "type":"slot" + "name": "slot", + "type": "varint" + }, + { + "name": "item", + "type": "varint" } ] ], - "packet_interact":[ + "packet_player_action": [ "container", [ { - "name":"actionId", - "type":"i8" + "name": "entity_id", + "type": "varint" }, { - "name":"targetEntityId", - "type":"i64" + "name": "action_id", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "face", + "type": "varint" } ] ], - "packet_use_item":[ + "packet_hurt_armor": [ "container", [ { - "name":"blockcoordinates", - "type":"blockcoordinates" - }, - { - "name":"unknown", - "type":"varint" - }, - { - "name":"face", - "type":"varint" - }, - { - "name":"facecoordinates", - "type":"vector3" - }, - { - "name":"playerposition", - "type":"vector3" - }, - { - "name":"slot", - "type":"varint" - }, - { - "name":"item", - "type":"slot" + "name": "health", + "type": "varint" } ] ], - "packet_player_action":[ + "packet_set_entity_data": [ "container", [ { - "name":"entityId", - "type":"varint" + "name": "entity_id", + "type": "varint" }, { - "name":"actionId", - "type":"varint" - }, - { - "name":"blockcoordinates", - "type":"blockcoordinates" - }, - { - "name":"face", - "type":"varint" + "name": "metadata", + "type": "varint" } ] ], - "packet_hurt_armor":[ + "packet_set_entity_motion": [ "container", [ { - "name":"health", - "type":"i8" + "name": "entity_id", + "type": "varint" + }, + { + "name": "velocity", + "type": "vector3" } ] ], - "packet_set_entity_data":[ + "packet_set_entity_link": [ "container", [ { - "name":"entity_id", - "type":"i64" + "name": "rider_id", + "type": "varint" }, { - "name":"metadata", - "type":"metadatadictionary" + "name": "ridden_id", + "type": "varint" + }, + { + "name": "link_type", + "type": "u8" } ] ], - "packet_set_entity_motion":[ + "packet_set_health": [ "container", [ { - "name":"entities", - "type":"entitymotions" + "name": "health", + "type": "varint" } ] ], - "packet_set_entity_link":[ + "packet_set_spawn_position": [ "container", [ { - "name":"riderId", - "type":"i64" + "name": "unknown_1", + "type": "varint" }, { - "name":"riddenId", - "type":"i64" - }, - { - "name":"linkType", - "type":"i8" + "name": "coordinates", + "type": "varint" } ] ], - "packet_set_health":[ + "packet_animate": [ "container", [ { - "name":"health", - "type":"i32" + "name": "action_id", + "type": "varint" + }, + { + "name": "entity_id", + "type": "varint" } ] ], - "packet_set_spawn_position":[ + "packet_respawn": [ "container", [ { - "name":"x", - "type":"i32" + "name": "x", + "type": "f32" }, { - "name":"z", - "type":"i32" + "name": "y", + "type": "f32" }, { - "name":"y", - "type":"i32" + "name": "z", + "type": "f32" } ] ], - "packet_animate":[ + "packet_drop_item": [ "container", [ { - "name":"actionId", - "type":"i8" + "name": "itemtype", + "type": "u8" }, { - "name":"entityId", - "type":"i64" + "name": "item", + "type": "varint" } ] ], - "packet_respawn":[ + "packet_inventory_action": [ "container", [ { - "name":"x", - "type":"f32" + "name": "unknown", + "type": "varint" }, { - "name":"y", - "type":"f32" - }, - { - "name":"z", - "type":"f32" + "name": "item", + "type": "varint" } ] ], - "packet_drop_item":[ + "packet_container_open": [ "container", [ { - "name":"itemtype", - "type":"i8" + "name": "window_id", + "type": "u8" }, { - "name":"item", - "type":"slot" + "name": "type", + "type": "u8" + }, + { + "name": "slot_count", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "unown_entity_id", + "type": "varint" } ] ], - "packet_container_open":[ + "packet_container_close": [ "container", [ { - "name":"windowId", - "type":"i8" - }, - { - "name":"type", - "type":"i8" - }, - { - "name":"slotCount", - "type":"i16" - }, - { - "name":"x", - "type":"i32" - }, - { - "name":"y", - "type":"i32" - }, - { - "name":"z", - "type":"i32" + "name": "window_id", + "type": "u8" } ] ], - "packet_container_close":[ + "packet_container_set_slot": [ "container", [ { - "name":"windowId", - "type":"i8" + "name": "window_id", + "type": "u8" + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "unknown", + "type": "varint" + }, + { + "name": "item", + "type": "varint" } ] ], - "packet_container_set_slot":[ + "packet_container_set_data": [ "container", [ { - "name":"windowId", - "type":"i8" + "name": "window_id", + "type": "u8" }, { - "name":"slot", - "type":"i16" + "name": "property", + "type": "varint" }, { - "name":"unknown", - "type":"i16" - }, - { - "name":"item", - "type":"slot" + "name": "value", + "type": "varint" } ] ], - "packet_container_set_data":[ + "packet_container_set_content": [ "container", [ { - "name":"windowId", - "type":"i8" + "name": "window_id", + "type": "u8" }, { - "name":"property", - "type":"i16" + "name": "slot_data", + "type": "varint" }, { - "name":"value", - "type":"i16" + "name": "hotbar_data", + "type": "varint" } ] ], - "packet_container_set_content":[ + "packet_crafting_data": [ "container", [ { - "name":"windowId", - "type":"i8" - }, - { - "name":"slotData", - "type":"itemstacks" - }, - { - "name":"hotbarData", - "type":[ - "switch", - { - "compareTo":"windowId", - "fields":{ - "0":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"slot", - "type":"i32" - } - ] - ] - } - ] - }, - "default":"i16" - } - ] + "name": "recipes", + "type": "varint" } ] ], - "packet_crafting_data":[ + "packet_crafting_event": [ "container", [ { - "name":"recipes", - "type":[ - "container", - [ - { - "name":"entryType", - "type":"i32" - }, - { - "name":"recipe", - "type":[ - "array", - { - "countType":"i32", - "type":[ - "switch", - { - "compareTo":"entryType", - "fields":{ - "0":"shapelessRecipe", - "1":"shapedRecipe", - "2":"furnaceRecipe", - "3":"furnaceRecipeData", - "4":"enchantList" - }, - "default":"void" - } - ] - } - ] - } - ] - ] + "name": "window_id", + "type": "u8" }, { - "name":"cleanRecipes", - "type":"i8" + "name": "recipe_type", + "type": "varint" + }, + { + "name": "recipe_id", + "type": "uuid" + }, + { + "name": "input", + "type": "varint" + }, + { + "name": "result", + "type": "varint" } ] ], - "packet_crafting_event":[ + "packet_adventure_settings": [ "container", [ { - "name":"windowId", - "type":"i8" + "name": "flags", + "type": "varint" }, { - "name":"recipeType", - "type":"i32" - }, - { - "name":"recipeId", - "type":"uuid" - }, - { - "name":"input", - "type":"itemstacks" - }, - { - "name":"result", - "type":"itemstacks" + "name": "user_permission", + "type": "varint" } ] ], - "packet_adventure_settings":[ + "packet_block_entity_data": [ "container", [ { - "name":"flags", - "type":"varint" + "name": "coordinates", + "type": "varint" }, { - "name":"userPermission", - "type":"varint" + "name": "namedtag", + "type": "varint" } ] ], - "packet_block_entity_data":[ + "packet_player_input": [ "container", [ { - "name":"x", - "type":"i32" + "name": "motion_x", + "type": "f32" }, { - "name":"y", - "type":"i32" + "name": "motion_z", + "type": "f32" }, { - "name":"z", - "type":"i32" + "name": "flag1", + "type": "bool" }, { - "name":"namedtag", - "type":"restBuffer" + "name": "flag2", + "type": "bool" } ] ], - "packet_player_input":[ + "packet_full_chunk_data": [ "container", [ { - "name":"motionX", - "type":"f32" + "name": "chunk_x", + "type": "varint" }, { - "name":"motionZ", - "type":"f32" + "name": "chunk_z", + "type": "varint" }, { - "name":"flags", - "type":"i16" - } - ] - ], - "packet_full_chunk_data":[ - "container", - [ - { - "name":"chunkX", - "type":"varint" + "name": "order", + "type": "u8" }, { - "name":"chunkZ", - "type":"varint" - }, - { - "name":"order", - "type":"i8" - }, - { - "name":"chunkData", - "type":[ + "name": "chunk_data", + "type": [ "buffer", { - "countType":"varint" + "countType": "varint", + "type": "i8" } ] } ] ], - "packet_set_difficulty":[ + "packet_set_commands_enabled": [ "container", [ { - "name":"difficulty", - "type":"varint" + "name": "enabled", + "type": "bool" } ] ], - "packet_player_list":[ + "packet_set_difficulty": [ "container", [ { - "name":"type", - "type":"i8" + "name": "difficulty", + "type": "varint" + } + ] + ], + "packet_change_dimension": [ + "container", + [ + { + "name": "dimension", + "type": "varint" }, { - "name":"entries", - "type":[ - "array", + "name": "position", + "type": "vector3" + }, + { + "name": "unknown", + "type": "bool" + } + ] + ], + "packet_set_player_game_type": [ + "container", + [ + { + "name": "unknown", + "type": "varint" + } + ] + ], + "packet_player_list": [ + "container", + [ + { + "name": "records", + "type": "varint" + } + ] + ], + "packet_event": [ + "container", + [] + ], + "packet_spawn_experience_orb": [ + "container", + [ + { + "name": "position", + "type": "vector3" + }, + { + "name": "count", + "type": "varint" + } + ] + ], + "packet_clientbound_map_item_data_": [ + "container", + [ + { + "name": "mapinfo", + "type": "varint" + } + ] + ], + "packet_map_info_request": [ + "container", + [ + { + "name": "map_id", + "type": "varint" + } + ] + ], + "packet_request_chunk_radius": [ + "container", + [ + { + "name": "chunk_radius", + "type": "varint" + } + ] + ], + "packet_chunk_radius_update": [ + "container", + [ + { + "name": "chunk_radius", + "type": "varint" + } + ] + ], + "packet_item_fram_drop_item": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "item", + "type": "varint" + } + ] + ], + "packet_replace_selected_item": [ + "container", + [] + ], + "packet_game_rules_changed": [ + "container", + [ + { + "name": "rules", + "type": "varint" + } + ] + ], + "packet_camera": [ + "container", + [] + ], + "packet_add_item": [ + "container", + [] + ], + "packet_boss_event": [ + "container", + [] + ], + "packet_available_commands": [ + "container", + [ + { + "name": "commands", + "type": "string" + }, + { + "name": "unknown", + "type": "string" + } + ] + ], + "packet_command_step": [ + "container", + [ + { + "name": "command_name", + "type": "string" + }, + { + "name": "command_overload", + "type": "string" + }, + { + "name": "unknown_1", + "type": "varint" + }, + { + "name": "unknown_2", + "type": "varint" + }, + { + "name": "is_output", + "type": "bool" + }, + { + "name": "unknown_5", + "type": "varint" + }, + { + "name": "command_input_json", + "type": "string" + }, + { + "name": "command_output_json", + "type": "string" + }, + { + "name": "unknown_7", + "type": "u8" + }, + { + "name": "unknown_8", + "type": "u8" + }, + { + "name": "entity_id", + "type": "varint" + } + ] + ], + "packet_resource_pack_data_info": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "unknown1", + "type": "u32" + }, + { + "name": "unknown2", + "type": "u32" + }, + { + "name": "unknown3", + "type": "u64" + }, + { + "name": "unknown4", + "type": "string" + } + ] + ], + "packet_resource_pack_chunk_data": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "unknown1", + "type": "u32" + }, + { + "name": "unknown3", + "type": "u64" + }, + { + "name": "length", + "type": "u32" + }, + { + "name": "payload", + "type": [ + "buffer", { - "countType":"i32", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "0":[ - "container", - [ - { - "name":"clientUuid", - "type":"uuid" - }, - { - "name":"entityId", - "type":"i64" - }, - { - "name":"displayName", - "type":"string" - }, - { - "name":"skin", - "type":"skin" - } - ] - ], - "1":[ - "container", - [ - { - "name":"clientUuid", - "type":"uuid" - } - ] - ] - } - } - ] + "countType": "varint", + "type": "i8" } ] } ] ], - "map_info_request": [ + "packet_resource_pack_chunk_request": [ "container", [ { - "name":"mapID", - "type":"varint" - } - ] - ], - "packet_request_chunk_radius":[ - "container", - [ - { - "name":"chunkRadius", - "type":"varint" - } - ] - ], - "packet_chunk_radius_update":[ - "container", - [ - { - "name":"chunkRadius", - "type":"varint" - } - ] - ], - "packet_transfer":[ - "container", - [ - { - "name":"endpoint", - "type":"ipAddress" - } - ] - ], - "packet_spawn_experience_orb":[ - "container", - [ - { - "name":"entityId", - "type":"i64" + "name": "package_id", + "type": "string" }, { - "name":"x", - "type":"i32" - }, - { - "name":"y", - "type":"i32" - }, - { - "name":"z", - "type":"i32" - }, - { - "name":"count", - "type":"i32" - } - ] - ], - "packet_replace_selected_item":[ - "container", - [ - { - "name":"slot", - "type":"slot" + "name": "chunk_index", + "type": "i32" } ] ] From d478b66324f4bf6b154a75a994edf34e78dcc482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 14 Dec 2016 18:22:24 +0100 Subject: [PATCH 047/106] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d6110a5..433bbe8 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ pocket-minecraft-protocol [![NPM version](https://img.shields.io/npm/v/pocket-minecraft-protocol.svg)](http://npmjs.com/package/pocket-minecraft-protocol) [![Join the chat at https://gitter.im/mhsjlw/pocket-minecraft-protocol](https://badges.gitter.im/mhsjlw/pocket-minecraft-protocol.svg)](https://gitter.im/mhsjlw/pocket-minecraft-protocol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -Parse and serialize Minecraft PE packets. +Parse and serialize Minecraft PE packets (use [this](https://gist.github.com/filfat/eb6cd08e1e789b5924f7f733babc4a25) to generate the protocol data). ## Features - * Supports Minecraft Pocket Edition `0.16.0` + * Supports Minecraft Pocket Edition `1.0` * Pure JavaScript * Easily send and listen for any packet * RakNet support through [node-raknet](https://github.com/mhsjlw/node-raknet) From f432468de3b925f18fb67ff7be4093fd7b7de3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sat, 17 Dec 2016 18:25:20 +0100 Subject: [PATCH 048/106] 1.0 --- data/protocol.json | 106 +++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index ba86305..02f4fdb 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -152,49 +152,50 @@ "0x22": "interact", "0x23": "use_item", "0x24": "player_action", - "0x25": "hurt_armor", - "0x26": "set_entity_data", - "0x27": "set_entity_motion", - "0x28": "set_entity_link", - "0x29": "set_health", - "0x2a": "set_spawn_position", - "0x2b": "animate", - "0x2c": "respawn", - "0x2d": "drop_item", - "0x2e": "inventory_action", - "0x2f": "container_open", - "0x30": "container_close", - "0x31": "container_set_slot", - "0x32": "container_set_data", - "0x33": "container_set_content", - "0x34": "crafting_data", - "0x35": "crafting_event", - "0x36": "adventure_settings", - "0x37": "block_entity_data", - "0x38": "player_input", - "0x39": "full_chunk_data", - "0x3a": "set_commands_enabled", - "0x3b": "set_difficulty", - "0x3c": "change_dimension", - "0x3d": "set_player_game_type", - "0x3e": "player_list", - "0x3f": "event", - "0x40": "spawn_experience_orb", - "0x41": "clientbound_map_item_data_", - "0x42": "map_info_request", - "0x43": "request_chunk_radius", - "0x44": "chunk_radius_update", - "0x45": "item_fram_drop_item", - "0x46": "replace_selected_item", - "0x47": "game_rules_changed", - "0x48": "camera", - "0x49": "add_item", - "0x4a": "boss_event", - "0x4b": "available_commands", - "0x4c": "command_step", - "0x4d": "resource_pack_data_info", - "0x4e": "resource_pack_chunk_data", - "0x4f": "resource_pack_chunk_request" + "0x25": "player_fall", + "0x26": "hurt_armor", + "0x27": "set_entity_data", + "0x28": "set_entity_motion", + "0x29": "set_entity_link", + "0x2a": "set_health", + "0x2b": "set_spawn_position", + "0x2c": "animate", + "0x2d": "respawn", + "0x2e": "drop_item", + "0x2f": "inventory_action", + "0x30": "container_open", + "0x31": "container_close", + "0x32": "container_set_slot", + "0x33": "container_set_data", + "0x34": "container_set_content", + "0x35": "crafting_data", + "0x36": "crafting_event", + "0x37": "adventure_settings", + "0x38": "block_entity_data", + "0x39": "player_input", + "0x3a": "full_chunk_data", + "0x3b": "set_commands_enabled", + "0x3c": "set_difficulty", + "0x3d": "change_dimension", + "0x3e": "set_player_game_type", + "0x3f": "player_list", + "0x40": "event", + "0x41": "spawn_experience_orb", + "0x42": "clientbound_map_item_data_", + "0x43": "map_info_request", + "0x44": "request_chunk_radius", + "0x45": "chunk_radius_update", + "0x46": "item_fram_drop_item", + "0x47": "replace_selected_item", + "0x48": "game_rules_changed", + "0x49": "camera", + "0x4a": "add_item", + "0x4b": "boss_event", + "0x4d": "available_commands", + "0x4e": "command_step", + "0x4f": "resource_pack_data_info", + "0x50": "resource_pack_chunk_data", + "0x51": "resource_pack_chunk_request" } } ] @@ -242,6 +243,7 @@ "interact": "packet_interact", "use_item": "packet_use_item", "player_action": "packet_player_action", + "player_fall": "packet_player_fall", "hurt_armor": "packet_hurt_armor", "set_entity_data": "packet_set_entity_data", "set_entity_motion": "packet_set_entity_motion", @@ -1103,6 +1105,10 @@ "name": "blockcoordinates", "type": "varint" }, + { + "name": "unknown", + "type": "varint" + }, { "name": "face", "type": "varint" @@ -1146,6 +1152,10 @@ } ] ], + "packet_player_fall": [ + "container", + [] + ], "packet_hurt_armor": [ "container", [ @@ -1322,12 +1332,16 @@ "type": "varint" }, { - "name": "unknown", + "name": "hotbarslot", "type": "varint" }, { "name": "item", "type": "varint" + }, + { + "name": "unknown2", + "type": "u8" } ] ], @@ -1457,10 +1471,6 @@ "name": "chunk_z", "type": "varint" }, - { - "name": "order", - "type": "u8" - }, { "name": "chunk_data", "type": [ From 74a3e6db452f27c24d5cc476fb38b482f6b4ce25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Tue, 20 Dec 2016 17:42:58 +0100 Subject: [PATCH 049/106] Add documentation. Add encryption toggle. --- src/createClient.js | 2 ++ src/createServer.js | 52 ++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/createClient.js b/src/createClient.js index 3cd58e1..55d8f08 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -10,6 +10,8 @@ batchProto.addTypes(require("./datatypes/minecraft")); batchProto.addType("insideBatch",["endOfArray",{"type":["buffer",{"countType":"i32"}]}]); function createClient(options) { + return null; //FIXME + assert.ok(options, 'options is required'); var port = options.port || 19132; var host = options.host || 'localhost'; diff --git a/src/createServer.js b/src/createServer.js index da78b6f..e4e103d 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -20,66 +20,64 @@ batchProto.addType('insideBatch', ['endOfArray', { }]); const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; -function createServer(options) { + +// createServer (object, boolean) +// +// Create & launch a MCPE raknet-based server. +// object: raknet options +// encryption: enable/disable encryption +function createServer(options, encryption) { options = options || {}; - var port = options.port != null ? + const port = options.port != null ? options.port : options['server-port'] != null ? options['server-port'] : 19132; - var host = options.host || '0.0.0.0'; + const host = options.host || '0.0.0.0'; options.customPackets = require('../data/protocol'); options.customTypes = require('./datatypes/minecraft'); - var server = raknet.createServer(options); + let server = raknet.createServer(options); server.name = options.name || 'Minecraft Server'; - server.motd = options.motd || 'A Minecraft server'; - server.maxPlayers = options['max-players'] || 20; - server.playerCount = 0; - + server.motd = options.motd || 'A Minecraft server'; //FIXME + server.maxPlayers = options['max-players'] || 20; //FIXME + server.playerCount = 0; //FIXME + server.on('connection', function(client) { - - client.receiveCounter=0; - client.sendCounter=0; - - client.encryptionEnabled = false; + client.receiveCounter = 0; + client.sendCounter = 0; + client.encryptionEnabled = encryption ? encryption : true; let proto = new ProtoDef(); proto.addTypes(require('./datatypes/minecraft')); proto.addTypes(require('../data/protocol').types); client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); - - client.on('mcpe', packet => { - client.emit(packet.name, packet.params) - }); client.writeMCPE = (name, params) => { - if (client.encryptionEnabled) { + if (client.encryptionEnabled) client.mcpePacketSerializer.write({ name, params }); - } - else { + else client.writeEncapsulated('mcpe', { name, params }); - } }; - client.writeBatch = function(packets) { const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', - packets.map(packet => - client.mcpePacketSerializer.createPacketBuffer(packet)))); + packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packet)))); client.writeMCPE('batch', { payload: payload }); }; + client.on('mcpe', packet => { + client.emit(packet.name, packet.params) + }); client.on('batch', function(packet) { var buf = zlib.inflateSync(packet.payload); var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); - client.on('game_login', (packet) => { try { const dataProto = new ProtoDef(); @@ -95,6 +93,7 @@ function createServer(options) { }] }]]); + //FIXME: Xbox & Non-Xbox support let body = dataProto.parsePacketBuffer('data_chain', zlib.inflateSync(packet.body)), chain = null, decode = null, @@ -115,8 +114,9 @@ function createServer(options) { skinData: data.SkinData, skinId: data.SkinId }) - } catch(err) { + } catch (err) { console.log(err); + return null; } }); }); From 0ed2e7b61cf6ab9905fa1d9d8e9238341a63fd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Tue, 20 Dec 2016 18:22:37 +0100 Subject: [PATCH 050/106] Remove unused modules. --- src/createServer.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index e4e103d..516d548 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -4,18 +4,14 @@ let raknet = require('raknet'), ProtoDef = require('protodef').ProtoDef, Parser = require('protodef').Parser, Serializer = require('protodef').Serializer, - jwt = require('jwt-simple'), - crypto = require('crypto'), - Ber = require('asn1').Ber, - merge = require('lodash.merge'), - assert = require('assert'); + jwt = require('jwt-simple'); var debug = require('debug')('raknet'); -const batchProto = new ProtoDef(); +let batchProto = new ProtoDef(); batchProto.addTypes(require('./datatypes/minecraft')); batchProto.addType('insideBatch', ['endOfArray', { 'type': ['buffer', { - 'countType': 'varint' + 'countType': 'varint', }] }]); @@ -48,13 +44,22 @@ function createServer(options, encryption) { server.on('connection', function(client) { client.receiveCounter = 0; client.sendCounter = 0; - client.encryptionEnabled = encryption ? encryption : true; + client.encryptionEnabled = encryption ? encryption : false; let proto = new ProtoDef(); proto.addTypes(require('./datatypes/minecraft')); proto.addTypes(require('../data/protocol').types); client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); + client.on('mcpe', packet => { + client.emit(packet.name, packet.params) + }); + client.on('batch', function (packet) { + var buf = zlib.inflateSync(packet.payload); + var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); + }); + client.writeMCPE = (name, params) => { if (client.encryptionEnabled) client.mcpePacketSerializer.write({ name, params }); @@ -70,17 +75,9 @@ function createServer(options, encryption) { }); }; - client.on('mcpe', packet => { - client.emit(packet.name, packet.params) - }); - client.on('batch', function(packet) { - var buf = zlib.inflateSync(packet.payload); - var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); - }); client.on('game_login', (packet) => { try { - const dataProto = new ProtoDef(); + let dataProto = new ProtoDef(); dataProto.addType('data_chain', ['container', [{ 'name': 'chain', 'type': ['pstring', { @@ -102,7 +99,7 @@ function createServer(options, encryption) { body.data.chain = JSON.parse(body.data.chain); chain = body.data.chain.chain[0]; - decode = jwt.decode(chain, 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V', 'ES384'); + decode = jwt.decode(chain, PUBLIC_KEY, 'ES384'); data = jwt.decode(body.data.clientData, decode.identityPublicKey, 'ES384'); data.SkinData = null; From 0c1bf07d0ca51b243d6cc0466e0072830e595fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Tue, 20 Dec 2016 18:23:26 +0100 Subject: [PATCH 051/106] Fix encryption toggle. From 151be30ca5c919e7878f932f61f93c334da19ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 29 Dec 2016 16:06:03 +0100 Subject: [PATCH 052/106] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 433bbe8..ce7feab 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,7 @@ This project is run by these guys: - [Filiph Sandström](https://github.com/filfat) - [mhsjlw](https://github.com/mhsjlw) - [rom1504](https://github.com/rom1504) + +## License +Licensed under the MIT license. +ANY modifications/patches made by Filiph Sandström is licensed under the [ABRMS license](https://gist.github.com/filfat/d2ef7dffb50901064df06609d00f82ec). From 1dae81fcb284be8e067020a955d2666e7673926a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Thu, 29 Dec 2016 16:19:41 +0100 Subject: [PATCH 053/106] Retracted the ABRMS license. I still don't like you RMS though. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ce7feab..cb69cf7 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,3 @@ This project is run by these guys: ## License Licensed under the MIT license. -ANY modifications/patches made by Filiph Sandström is licensed under the [ABRMS license](https://gist.github.com/filfat/d2ef7dffb50901064df06609d00f82ec). From 24ef9c5da1456cd0142d22e1f8ba23a64fcd32e7 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Tue, 17 Jan 2017 16:05:15 +0100 Subject: [PATCH 054/106] adapt chat except translate see https://github.com/NiclasOlofsson/MiNET/blob/master/src/MiNET/MiNET/Net/McpeText.cs --- data/protocol.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 02f4fdb..08d4f97 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -440,8 +440,7 @@ { "compareTo": "type", "fields": { - "1": "string", - "3": "string" + "1": "string" }, "default": "void" } @@ -458,8 +457,7 @@ "1": "string", "2": "string", "3": "string", - "4": "string", - "5": "string" + "4": "string" }, "default": "void" } From ae22c37c20e1ba72e8a6426d12df17d3c6832ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Tue, 17 Jan 2017 23:10:42 +0100 Subject: [PATCH 055/106] Changed order of "Contributors". Let's face it, they've done a lot more than I'll eve be able to do for this project. Also, most likely they're a lot better looking than me too; so there's that. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb69cf7..54f647e 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ Then view our `examples` for inspiration! ## Contributors This project is run by these guys: - - [Filiph Sandström](https://github.com/filfat) - [mhsjlw](https://github.com/mhsjlw) - [rom1504](https://github.com/rom1504) + - [Filiph Sandström](https://github.com/filfat) ## License Licensed under the MIT license. From e48f146528795cc7d003ea02b8fe270a3c8c14b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 18 Jan 2017 09:26:56 +0100 Subject: [PATCH 056/106] Add writePacket and writeData. --- src/createServer.js | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 516d548..90a6cdd 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -44,7 +44,7 @@ function createServer(options, encryption) { server.on('connection', function(client) { client.receiveCounter = 0; client.sendCounter = 0; - client.encryptionEnabled = encryption ? encryption : false; + client.encryptionEnabled = encryption ? true : false; let proto = new ProtoDef(); proto.addTypes(require('./datatypes/minecraft')); @@ -60,22 +60,45 @@ function createServer(options, encryption) { packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); - client.writeMCPE = (name, params) => { - if (client.encryptionEnabled) + // client.writePacket (string, object) + // Send data to the client + // + // string: packet name + // object: packet data + client.writeMCPE = function (name, params) { + if (client.encryptionEnabled) { client.mcpePacketSerializer.write({ name, params }); - else + } else { client.writeEncapsulated('mcpe', { name, params }); + } }; - client.writeBatch = function(packets) { + client.writePacket = client.writeMCPE; + + // client.writeData (array) + // Send data to the client + // + // array: packets to send + client.writeBatch = function (packets) { const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packet)))); - client.writeMCPE('batch', { + client.writePacket('batch', { payload: payload }); }; + client.writeData = client.writeBatch; - client.on('game_login', (packet) => { + // client.writeAll (string, object) + // Send data to the client + // + // string: packet name + // object: packet data + client.writeAll = function (name, data) { + return; //TODO + server._writeAll(name, data); + }; + + client.on('game_login', function (packet) { try { let dataProto = new ProtoDef(); dataProto.addType('data_chain', ['container', [{ @@ -91,6 +114,7 @@ function createServer(options, encryption) { }]]); //FIXME: Xbox & Non-Xbox support + console.log(packet); let body = dataProto.parsePacketBuffer('data_chain', zlib.inflateSync(packet.body)), chain = null, decode = null, @@ -120,4 +144,4 @@ function createServer(options, encryption) { return server; } -module.exports = createServer; +module.exports = createServer; \ No newline at end of file From 239acc73b4d24f115db0f9ed7a7834ee6c3b582e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Fri, 20 Jan 2017 09:18:06 +0100 Subject: [PATCH 057/106] Update createServer.js --- src/createServer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index 90a6cdd..01bcff3 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -80,7 +80,7 @@ function createServer(options, encryption) { // array: packets to send client.writeBatch = function (packets) { const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', - packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packet)))); + packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packets)))); client.writePacket('batch', { payload: payload @@ -144,4 +144,4 @@ function createServer(options, encryption) { return server; } -module.exports = createServer; \ No newline at end of file +module.exports = createServer; From 5c6042b61f3ba351033c43bba9a1c53aa4e482de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Fri, 20 Jan 2017 09:21:05 +0100 Subject: [PATCH 058/106] *faceplam* --- src/createServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/createServer.js b/src/createServer.js index 01bcff3..aaa3f44 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -80,7 +80,7 @@ function createServer(options, encryption) { // array: packets to send client.writeBatch = function (packets) { const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', - packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packets)))); + packets.map(packets => client.mcpePacketSerializer.createPacketBuffer(packets)))); client.writePacket('batch', { payload: payload From dd4393272061c45eedb06d0f0d5f2943478b7f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Fri, 20 Jan 2017 09:44:22 +0100 Subject: [PATCH 059/106] Update protocol.json --- data/protocol.json | 92 +++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 08d4f97..a6ba045 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -17,15 +17,15 @@ [ { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" } ] ], @@ -51,15 +51,15 @@ [ { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" }, { "name": "yaw", @@ -543,11 +543,11 @@ }, { "name": "rain_level", - "type": "f32" + "type": "lf32" }, { "name": "lightnig_level", - "type": "f32" + "type": "lf32" }, { "name": "enable_commands", @@ -588,39 +588,39 @@ }, { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" }, { "name": "speed_x", - "type": "f32" + "type": "lf32" }, { "name": "speed_y", - "type": "f32" + "type": "lf32" }, { "name": "speed_z", - "type": "f32" + "type": "lf32" }, { "name": "pitch", - "type": "f32" + "type": "lf32" }, { "name": "head_yaw", - "type": "f32" + "type": "lf32" }, { "name": "yaw", - "type": "f32" + "type": "lf32" }, { "name": "item", @@ -649,35 +649,35 @@ }, { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" }, { "name": "speed_x", - "type": "f32" + "type": "lf32" }, { "name": "speed_y", - "type": "f32" + "type": "lf32" }, { "name": "speed_z", - "type": "f32" + "type": "lf32" }, { "name": "yaw", - "type": "f32" + "type": "lf32" }, { "name": "pitch", - "type": "f32" + "type": "lf32" }, { "name": "attributes", @@ -719,27 +719,27 @@ }, { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" }, { "name": "speed_x", - "type": "f32" + "type": "lf32" }, { "name": "speed_y", - "type": "f32" + "type": "lf32" }, { "name": "speed_z", - "type": "f32" + "type": "lf32" } ] ], @@ -799,27 +799,27 @@ }, { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" }, { "name": "pitch", - "type": "f32" + "type": "lf32" }, { "name": "head_yaw", - "type": "f32" + "type": "lf32" }, { "name": "yaw", - "type": "f32" + "type": "lf32" }, { "name": "mode", @@ -895,7 +895,7 @@ }, { "name": "radius", - "type": "f32" + "type": "lf32" }, { "name": "records", @@ -941,15 +941,15 @@ }, { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" }, { "name": "data", @@ -1246,15 +1246,15 @@ [ { "name": "x", - "type": "f32" + "type": "lf32" }, { "name": "y", - "type": "f32" + "type": "lf32" }, { "name": "z", - "type": "f32" + "type": "lf32" } ] ], @@ -1442,11 +1442,11 @@ [ { "name": "motion_x", - "type": "f32" + "type": "lf32" }, { "name": "motion_z", - "type": "f32" + "type": "lf32" }, { "name": "flag1", From c3671edc01a060ecfb34c5a4e69c3444c4e4c159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sat, 21 Jan 2017 12:44:12 +0100 Subject: [PATCH 060/106] Fix minor issue. --- src/createServer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/createServer.js b/src/createServer.js index aaa3f44..afb0845 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -52,10 +52,11 @@ function createServer(options, encryption) { client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); client.on('mcpe', packet => { - client.emit(packet.name, packet.params) + client.emit(packet.name, packet.params); + client.emit('debug', packet.name); }); - client.on('batch', function (packet) { - var buf = zlib.inflateSync(packet.payload); + client.on('batch', function (packets) { + var buf = zlib.inflateSync(packets.payload); var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); @@ -80,7 +81,7 @@ function createServer(options, encryption) { // array: packets to send client.writeBatch = function (packets) { const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', - packets.map(packets => client.mcpePacketSerializer.createPacketBuffer(packets)))); + packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packet)))); client.writePacket('batch', { payload: payload From a187f0a9bedc8991b326db9af8b09b5fbea6222c Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Sun, 22 Jan 2017 13:28:23 -0500 Subject: [PATCH 061/106] updates ! --- data/protocol.json | 4045 +++++++++++++++++++++++++------------------- 1 file changed, 2296 insertions(+), 1749 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index a6ba045..5f72188 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -1,1760 +1,2307 @@ { - "types": { - "string": [ - "pstring", + "types":{ + "string":[ + "pstring", + { + "countType":"varint" + } + ], + "lstring":[ + "pstring", + { + "countType":"li16" + } + ], + "rules":[ + "array", + { + "countType":"varint", + "type":[ + "container", + [ { - "countType": "i16" - } - ], - "lstring": [ - "pstring", + "name":"name", + "type":"string" + }, { - "countType": "li16" + "name":"unknown1", + "type":"bool" + }, + { + "name":"unknown2", + "type":"bool" } - ], - "vector3": [ - "container", - [ - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - } - ] - ], - "vector2": [ - "container", - [ - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - } - ] - ], - "playerlocation": [ + ] + ] + } + ], + "shapeless_recipe":[ + "container", + [ + { + "name":"ingredientList", + "type":[ "array", { - "countType": "i16", - "type": [ + "countType":"i32", + "type":"slot" + } + ] + }, + { + "name":"resultCount", + "type":"i32" + }, + { + "name":"slot", + "type":"slot" + }, + { + "name":"id", + "type":"uuid" + } + ] + ], + "shaped_recipe":[ + "container", + [ + { + "name":"width", + "type":[ + "count", + { + "type":"i32", + "countFor":"shape" + } + ] + }, + { + "name":"height", + "type":[ + "count", + { + "type":"i32", + "countFor":"shape/0" + } + ] + }, + { + "name":"shape", + "type":[ + "array", + { + "count":"width", + "type":[ + "array", + { + "count":"height", + "type":"slot" + } + ] + } + ] + }, + { + "name":"resultCount", + "type":"i32" + }, + { + "name":"slot", + "type":"slot" + }, + { + "name":"id", + "type":"uuid" + } + ] + ], + "furnace_recipe":[ + "container", + [ + { + "name":"meta", + "type":"i16" + }, + { + "name":"id", + "type":"i16" + }, + { + "name":"result", + "type":"slot" + } + ] + ], + "furnace_recipe_data":[ + "container", + [ + { + "name":"id", + "type":"i16" + }, + { + "name":"meta", + "type":"i16" + }, + { + "name":"result", + "type":"slot" + } + ] + ], + "enchant_list":[ + "array", + { + "countType":"i8", + "type":[ + "container", + [ + { + "name":"cost", + "type":"i32" + }, + { + "name":"enchantments", + "type":[ + "array", + { + "countType":"i8", + "type":[ "container", [ - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "yaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - }, - { - "name": "headYaw", - "type": "f32" - } + { + "name":"id", + "type":"i32" + }, + { + "name":"level", + "type":"i32" + } ] - ] + ] + } + ] + }, + { + "name":"name", + "type":"string" } - ], - "encapsulated_packet": [ - "container", - [ - { - "name": "name", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0xfe": "mcpe" - } - } - ] - }, - { - "name": "params", - "type": [ - "switch", - { - "compareTo": "name", - "fields": { - "mcpe": "mcpe_packet" - } - } - ] - } - ] - ], - "mcpe_packet": [ - "container", - [ - { - "name": "name", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0x01": "game_login", - "0x02": "player_status", - "0x03": "server_to_client_handshake", - "0x04": "client_to_server_handshake", - "0x05": "disconnect", - "0x06": "batch", - "0x07": "resource_packs_info", - "0x08": "resource_pack_stack", - "0x09": "resource_pack_client_response", - "0x0a": "text", - "0x0b": "set_time", - "0x0c": "start_game", - "0x0d": "add_player", - "0x0e": "add_entity", - "0x0f": "remove_entity", - "0x10": "add_item_entity", - "0x11": "add_hanging_entity", - "0x12": "take_item_entity", - "0x13": "move_entity", - "0x14": "move_player", - "0x15": "rider_jump", - "0x16": "remove_block", - "0x17": "update_block", - "0x18": "add_painting", - "0x19": "explode", - "0x1a": "level_sound_event", - "0x1b": "level_event", - "0x1c": "block_event", - "0x1d": "entity_event", - "0x1e": "mob_effect", - "0x1f": "update_attributes", - "0x20": "mob_equipment", - "0x21": "mob_armor_equipment", - "0x22": "interact", - "0x23": "use_item", - "0x24": "player_action", - "0x25": "player_fall", - "0x26": "hurt_armor", - "0x27": "set_entity_data", - "0x28": "set_entity_motion", - "0x29": "set_entity_link", - "0x2a": "set_health", - "0x2b": "set_spawn_position", - "0x2c": "animate", - "0x2d": "respawn", - "0x2e": "drop_item", - "0x2f": "inventory_action", - "0x30": "container_open", - "0x31": "container_close", - "0x32": "container_set_slot", - "0x33": "container_set_data", - "0x34": "container_set_content", - "0x35": "crafting_data", - "0x36": "crafting_event", - "0x37": "adventure_settings", - "0x38": "block_entity_data", - "0x39": "player_input", - "0x3a": "full_chunk_data", - "0x3b": "set_commands_enabled", - "0x3c": "set_difficulty", - "0x3d": "change_dimension", - "0x3e": "set_player_game_type", - "0x3f": "player_list", - "0x40": "event", - "0x41": "spawn_experience_orb", - "0x42": "clientbound_map_item_data_", - "0x43": "map_info_request", - "0x44": "request_chunk_radius", - "0x45": "chunk_radius_update", - "0x46": "item_fram_drop_item", - "0x47": "replace_selected_item", - "0x48": "game_rules_changed", - "0x49": "camera", - "0x4a": "add_item", - "0x4b": "boss_event", - "0x4d": "available_commands", - "0x4e": "command_step", - "0x4f": "resource_pack_data_info", - "0x50": "resource_pack_chunk_data", - "0x51": "resource_pack_chunk_request" - } - } - ] - }, - { - "name": "params", - "type": [ - "switch", - { - "compareTo": "name", - "fields": { - "game_login": "packet_game_login", - "player_status": "packet_player_status", - "server_to_client_handshake": "packet_server_to_client_handshake", - "client_to_server_handshake": "packet_client_to_server_handshake", - "disconnect": "packet_disconnect", - "batch": "packet_batch", - "resource_packs_info": "packet_resource_packs_info", - "resource_pack_stack": "packet_resource_pack_stack", - "resource_pack_client_response": "packet_resource_pack_client_response", - "text": "packet_text", - "set_time": "packet_set_time", - "start_game": "packet_start_game", - "add_player": "packet_add_player", - "add_entity": "packet_add_entity", - "remove_entity": "packet_remove_entity", - "add_item_entity": "packet_add_item_entity", - "add_hanging_entity": "packet_add_hanging_entity", - "take_item_entity": "packet_take_item_entity", - "move_entity": "packet_move_entity", - "move_player": "packet_move_player", - "rider_jump": "packet_rider_jump", - "remove_block": "packet_remove_block", - "update_block": "packet_update_block", - "add_painting": "packet_add_painting", - "explode": "packet_explode", - "level_sound_event": "packet_level_sound_event", - "level_event": "packet_level_event", - "block_event": "packet_block_event", - "entity_event": "packet_entity_event", - "mob_effect": "packet_mob_effect", - "update_attributes": "packet_update_attributes", - "mob_equipment": "packet_mob_equipment", - "mob_armor_equipment": "packet_mob_armor_equipment", - "interact": "packet_interact", - "use_item": "packet_use_item", - "player_action": "packet_player_action", - "player_fall": "packet_player_fall", - "hurt_armor": "packet_hurt_armor", - "set_entity_data": "packet_set_entity_data", - "set_entity_motion": "packet_set_entity_motion", - "set_entity_link": "packet_set_entity_link", - "set_health": "packet_set_health", - "set_spawn_position": "packet_set_spawn_position", - "animate": "packet_animate", - "respawn": "packet_respawn", - "drop_item": "packet_drop_item", - "inventory_action": "packet_inventory_action", - "container_open": "packet_container_open", - "container_close": "packet_container_close", - "container_set_slot": "packet_container_set_slot", - "container_set_data": "packet_container_set_data", - "container_set_content": "packet_container_set_content", - "crafting_data": "packet_crafting_data", - "crafting_event": "packet_crafting_event", - "adventure_settings": "packet_adventure_settings", - "block_entity_data": "packet_block_entity_data", - "player_input": "packet_player_input", - "full_chunk_data": "packet_full_chunk_data", - "set_commands_enabled": "packet_set_commands_enabled", - "set_difficulty": "packet_set_difficulty", - "change_dimension": "packet_change_dimension", - "set_player_game_type": "packet_set_player_game_type", - "player_list": "packet_player_list", - "event": "packet_event", - "spawn_experience_orb": "packet_spawn_experience_orb", - "clientbound_map_item_data_": "packet_clientbound_map_item_data_", - "map_info_request": "packet_map_info_request", - "request_chunk_radius": "packet_request_chunk_radius", - "chunk_radius_update": "packet_chunk_radius_update", - "item_fram_drop_item": "packet_item_fram_drop_item", - "replace_selected_item": "packet_replace_selected_item", - "game_rules_changed": "packet_game_rules_changed", - "camera": "packet_camera", - "add_item": "packet_add_item", - "boss_event": "packet_boss_event", - "available_commands": "packet_available_commands", - "command_step": "packet_command_step", - "resource_pack_data_info": "packet_resource_pack_data_info", - "resource_pack_chunk_data": "packet_resource_pack_chunk_data", - "resource_pack_chunk_request": "packet_resource_pack_chunk_request" - } - } - ] - } - ] - ], - "packet_game_login": [ - "container", - [ - { - "name": "protocol", - "type": "i32" - }, - { - "name": "edition", - "type": "i8" - }, - { - "name": "body", - "type": [ - "buffer", - { - "countType": "varint" - } - ] - } - ] - ], - "packet_player_status": [ - "container", - [ - { - "name": "status", - "type": "i32" - } - ] - ], - "packet_server_to_client_handshake": [ - "container", - [ - { - "name": "server_public_key", - "type": "string" - }, - { - "name": "token_length", - "type": "length" - }, - { - "name": "token", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] - } - ] - ], - "packet_client_to_server_handshake": [ - "container", - [] - ], - "packet_disconnect": [ - "container", - [ - { - "name": "hide_disconnect_reason", - "type": "bool" - }, - { - "name": "message", - "type": "string" - } - ] - ], - "packet_batch": [ - "container", - [ - { - "name": "payload", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] - } - ] - ], - "packet_resource_packs_info": [ - "container", - [ - { - "name": "must_accept", - "type": "bool" - }, - { - "name": "behahaviorpackinfos", - "type": "varint" - }, - { - "name": "resourcepackinfos", - "type": "varint" - } - ] - ], - "packet_resource_pack_stack": [ - "container", - [ - { - "name": "must_accept", - "type": "bool" - }, - { - "name": "behaviorpackidversions", - "type": "varint" - }, - { - "name": "resourcepackidversions", - "type": "varint" - } - ] - ], - "packet_resource_pack_client_response": [ - "container", - [ - { - "name": "response_status", - "type": "u8" - }, - { - "name": "resourcepackidversions", - "type": "varint" - } - ] - ], - "packet_text": [ - "container", - [ - { - "name": "type", - "type": "i8" - }, - { - "name": "source", - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "1": "string" - }, - "default": "void" - } - ] - }, - { - "name": "message", - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "0": "string", - "1": "string", - "2": "string", - "3": "string", - "4": "string" - }, - "default": "void" - } - ] - } - ] - ], - "packet_set_time": [ - "container", - [ - { - "name": "time", - "type": "varint" - }, - { - "name": "started", - "type": "bool" - } - ] - ], - "packet_start_game": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "spawn", - "type": "vector3" - }, - { - "name": "unknown_1", - "type": "vector2" - }, - { - "name": "seed", - "type": "varint" - }, - { - "name": "dimension", - "type": "varint" - }, - { - "name": "generator", - "type": "varint" - }, - { - "name": "gamemode", - "type": "varint" - }, - { - "name": "difficulty", - "type": "varint" - }, - { - "name": "x", - "type": "varint" - }, - { - "name": "y", - "type": "varint" - }, - { - "name": "z", - "type": "varint" - }, - { - "name": "has_achievements_disabled", - "type": "bool" - }, - { - "name": "day_cycle_stop_time", - "type": "varint" - }, - { - "name": "edu_mode", - "type": "bool" - }, - { - "name": "rain_level", - "type": "lf32" - }, - { - "name": "lightnig_level", - "type": "lf32" - }, - { - "name": "enable_commands", - "type": "bool" - }, - { - "name": "is_texturepacks_required", - "type": "bool" - }, - { - "name": "secret", - "type": "string" - }, - { - "name": "world_name", - "type": "string" - } - ] - ], - "packet_add_player": [ - "container", - [ - { - "name": "uuid", - "type": "uuid" - }, - { - "name": "username", - "type": "string" - }, - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "speed_x", - "type": "lf32" - }, - { - "name": "speed_y", - "type": "lf32" - }, - { - "name": "speed_z", - "type": "lf32" - }, - { - "name": "pitch", - "type": "lf32" - }, - { - "name": "head_yaw", - "type": "lf32" - }, - { - "name": "yaw", - "type": "lf32" - }, - { - "name": "item", - "type": "varint" - }, - { - "name": "metadata", - "type": "varint" - } - ] - ], - "packet_add_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "entity_type", - "type": "varint" - }, - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "speed_x", - "type": "lf32" - }, - { - "name": "speed_y", - "type": "lf32" - }, - { - "name": "speed_z", - "type": "lf32" - }, - { - "name": "yaw", - "type": "lf32" - }, - { - "name": "pitch", - "type": "lf32" - }, - { - "name": "attributes", - "type": "varint" - }, - { - "name": "metadata", - "type": "varint" - }, - { - "name": "links", - "type": "links" - } - ] - ], - "packet_remove_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - } - ] - ], - "packet_add_item_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - }, - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "speed_x", - "type": "lf32" - }, - { - "name": "speed_y", - "type": "lf32" - }, - { - "name": "speed_z", - "type": "lf32" - } - ] - ], - "packet_add_hanging_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "unknown", - "type": "varint" - } - ] - ], - "packet_take_item_entity": [ - "container", - [ - { - "name": "target", - "type": "varint" - }, - { - "name": "entity_id", - "type": "varint" - } - ] - ], - "packet_move_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "position", - "type": "playerlocation" - } - ] - ], - "packet_move_player": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "pitch", - "type": "lf32" - }, - { - "name": "head_yaw", - "type": "lf32" - }, - { - "name": "yaw", - "type": "lf32" - }, - { - "name": "mode", - "type": "u8" - }, - { - "name": "on_ground", - "type": "bool" - } - ] - ], - "packet_rider_jump": [ - "container", - [] - ], - "packet_remove_block": [ - "container", - [ - { - "name": "coordinates", - "type": "varint" - } - ] - ], - "packet_update_block": [ - "container", - [ - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "block_id", - "type": "varint" - }, - { - "name": "block_meta_and_priority", - "type": "varint" - } - ] - ], - "packet_add_painting": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "direction", - "type": "varint" - }, - { - "name": "title", - "type": "string" - } - ] - ], - "packet_explode": [ - "container", - [ - { - "name": "position", - "type": "vector3" - }, - { - "name": "radius", - "type": "lf32" - }, - { - "name": "records", - "type": "varint" - } - ] - ], - "packet_level_sound_event": [ - "container", - [ - { - "name": "sound_id", - "type": "u8" - }, - { - "name": "position", - "type": "vector3" - }, - { - "name": "volume", - "type": "varint" - }, - { - "name": "pitch", - "type": "varint" - }, - { - "name": "unknown1", - "type": "bool" - }, - { - "name": "unknown2", - "type": "bool" - } - ] - ], - "packet_level_event": [ - "container", - [ - { - "name": "event_id", - "type": "varint" - }, - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "data", - "type": "varint" - } - ] - ], - "packet_block_event": [ - "container", - [ - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "case_1", - "type": "varint" - }, - { - "name": "case_2", - "type": "varint" - } - ] - ], - "packet_entity_event": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "event_id", - "type": "u8" - }, - { - "name": "unknown", - "type": "varint" - } - ] - ], - "packet_mob_effect": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "event_id", - "type": "u8" - }, - { - "name": "effect_id", - "type": "varint" - }, - { - "name": "amplifier", - "type": "varint" - }, - { - "name": "particles", - "type": "bool" - }, - { - "name": "duration", - "type": "varint" - } - ] - ], - "packet_update_attributes": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "attributes", - "type": "varint" - } - ] - ], - "packet_mob_equipment": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - }, - { - "name": "slot", - "type": "u8" - }, - { - "name": "selected_slot", - "type": "u8" - }, - { - "name": "unknown", - "type": "u8" - } - ] - ], - "packet_mob_armor_equipment": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "helmet", - "type": "varint" - }, - { - "name": "chestplate", - "type": "varint" - }, - { - "name": "leggings", - "type": "varint" - }, - { - "name": "boots", - "type": "varint" - } - ] - ], - "packet_interact": [ - "container", - [ - { - "name": "action_id", - "type": "u8" - }, - { - "name": "target_entity_id", - "type": "varint" - } - ] - ], - "packet_use_item": [ - "container", - [ - { - "name": "blockcoordinates", - "type": "varint" - }, - { - "name": "unknown", - "type": "varint" - }, - { - "name": "face", - "type": "varint" - }, - { - "name": "facecoordinates", - "type": "vector3" - }, - { - "name": "playerposition", - "type": "vector3" - }, - { - "name": "slot", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - } - ] - ], - "packet_player_action": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "action_id", - "type": "varint" - }, - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "face", - "type": "varint" - } - ] - ], - "packet_player_fall": [ - "container", - [] - ], - "packet_hurt_armor": [ - "container", - [ - { - "name": "health", - "type": "varint" - } - ] - ], - "packet_set_entity_data": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "metadata", - "type": "varint" - } - ] - ], - "packet_set_entity_motion": [ - "container", - [ - { - "name": "entity_id", - "type": "varint" - }, - { - "name": "velocity", - "type": "vector3" - } - ] - ], - "packet_set_entity_link": [ - "container", - [ - { - "name": "rider_id", - "type": "varint" - }, - { - "name": "ridden_id", - "type": "varint" - }, - { - "name": "link_type", - "type": "u8" - } - ] - ], - "packet_set_health": [ - "container", - [ - { - "name": "health", - "type": "varint" - } - ] - ], - "packet_set_spawn_position": [ - "container", - [ - { - "name": "unknown_1", - "type": "varint" - }, - { - "name": "coordinates", - "type": "varint" - } - ] - ], - "packet_animate": [ - "container", - [ - { - "name": "action_id", - "type": "varint" - }, - { - "name": "entity_id", - "type": "varint" - } - ] - ], - "packet_respawn": [ - "container", - [ - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - } - ] - ], - "packet_drop_item": [ - "container", - [ - { - "name": "itemtype", - "type": "u8" - }, - { - "name": "item", - "type": "varint" - } - ] - ], - "packet_inventory_action": [ - "container", - [ - { - "name": "unknown", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - } - ] - ], - "packet_container_open": [ - "container", - [ - { - "name": "window_id", - "type": "u8" - }, - { - "name": "type", - "type": "u8" - }, - { - "name": "slot_count", - "type": "varint" - }, - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "unown_entity_id", - "type": "varint" - } - ] - ], - "packet_container_close": [ - "container", - [ - { - "name": "window_id", - "type": "u8" - } - ] - ], - "packet_container_set_slot": [ - "container", - [ - { - "name": "window_id", - "type": "u8" - }, - { - "name": "slot", - "type": "varint" - }, - { - "name": "hotbarslot", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - }, - { - "name": "unknown2", - "type": "u8" - } - ] - ], - "packet_container_set_data": [ - "container", - [ - { - "name": "window_id", - "type": "u8" - }, - { - "name": "property", - "type": "varint" - }, - { - "name": "value", - "type": "varint" - } - ] - ], - "packet_container_set_content": [ - "container", - [ - { - "name": "window_id", - "type": "u8" - }, - { - "name": "slot_data", - "type": "varint" - }, - { - "name": "hotbar_data", - "type": "varint" - } - ] - ], - "packet_crafting_data": [ - "container", - [ - { - "name": "recipes", - "type": "varint" - } - ] - ], - "packet_crafting_event": [ - "container", - [ - { - "name": "window_id", - "type": "u8" - }, - { - "name": "recipe_type", - "type": "varint" - }, - { - "name": "recipe_id", - "type": "uuid" - }, - { - "name": "input", - "type": "varint" - }, - { - "name": "result", - "type": "varint" - } - ] - ], - "packet_adventure_settings": [ - "container", - [ - { - "name": "flags", - "type": "varint" - }, - { - "name": "user_permission", - "type": "varint" - } - ] - ], - "packet_block_entity_data": [ - "container", - [ - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "namedtag", - "type": "varint" - } - ] - ], - "packet_player_input": [ - "container", - [ - { - "name": "motion_x", - "type": "lf32" - }, - { - "name": "motion_z", - "type": "lf32" - }, - { - "name": "flag1", - "type": "bool" - }, - { - "name": "flag2", - "type": "bool" - } - ] - ], - "packet_full_chunk_data": [ - "container", - [ - { - "name": "chunk_x", - "type": "varint" - }, - { - "name": "chunk_z", - "type": "varint" - }, - { - "name": "chunk_data", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] - } - ] - ], - "packet_set_commands_enabled": [ - "container", - [ - { - "name": "enabled", - "type": "bool" - } - ] - ], - "packet_set_difficulty": [ - "container", - [ - { - "name": "difficulty", - "type": "varint" - } - ] - ], - "packet_change_dimension": [ - "container", - [ - { - "name": "dimension", - "type": "varint" - }, - { - "name": "position", - "type": "vector3" - }, - { - "name": "unknown", - "type": "bool" - } - ] - ], - "packet_set_player_game_type": [ - "container", - [ - { - "name": "unknown", - "type": "varint" - } - ] - ], - "packet_player_list": [ - "container", - [ - { - "name": "records", - "type": "varint" - } - ] - ], - "packet_event": [ - "container", - [] - ], - "packet_spawn_experience_orb": [ - "container", - [ - { - "name": "position", - "type": "vector3" - }, - { - "name": "count", - "type": "varint" - } - ] - ], - "packet_clientbound_map_item_data_": [ - "container", - [ - { - "name": "mapinfo", - "type": "varint" - } - ] - ], - "packet_map_info_request": [ - "container", - [ - { - "name": "map_id", - "type": "varint" - } - ] - ], - "packet_request_chunk_radius": [ - "container", - [ - { - "name": "chunk_radius", - "type": "varint" - } - ] - ], - "packet_chunk_radius_update": [ - "container", - [ - { - "name": "chunk_radius", - "type": "varint" - } - ] - ], - "packet_item_fram_drop_item": [ - "container", - [ - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - } - ] - ], - "packet_replace_selected_item": [ - "container", - [] - ], - "packet_game_rules_changed": [ - "container", - [ - { - "name": "rules", - "type": "varint" - } - ] - ], - "packet_camera": [ - "container", - [] - ], - "packet_add_item": [ - "container", - [] - ], - "packet_boss_event": [ - "container", - [] - ], - "packet_available_commands": [ - "container", - [ - { - "name": "commands", - "type": "string" - }, - { - "name": "unknown", - "type": "string" - } - ] - ], - "packet_command_step": [ - "container", - [ - { - "name": "command_name", - "type": "string" - }, - { - "name": "command_overload", - "type": "string" - }, - { - "name": "unknown_1", - "type": "varint" - }, - { - "name": "unknown_2", - "type": "varint" - }, - { - "name": "is_output", - "type": "bool" - }, - { - "name": "unknown_5", - "type": "varint" - }, - { - "name": "command_input_json", - "type": "string" - }, - { - "name": "command_output_json", - "type": "string" - }, - { - "name": "unknown_7", - "type": "u8" - }, - { - "name": "unknown_8", - "type": "u8" - }, - { - "name": "entity_id", - "type": "varint" - } - ] - ], - "packet_resource_pack_data_info": [ - "container", - [ - { - "name": "package_id", - "type": "string" - }, - { - "name": "unknown1", - "type": "u32" - }, - { - "name": "unknown2", - "type": "u32" - }, - { - "name": "unknown3", - "type": "u64" - }, - { - "name": "unknown4", - "type": "string" - } - ] - ], - "packet_resource_pack_chunk_data": [ - "container", - [ - { - "name": "package_id", - "type": "string" - }, - { - "name": "unknown1", - "type": "u32" - }, - { - "name": "unknown3", - "type": "u64" - }, - { - "name": "length", - "type": "u32" - }, - { - "name": "payload", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] - } - ] - ], - "packet_resource_pack_chunk_request": [ - "container", - [ - { - "name": "package_id", - "type": "string" - }, - { - "name": "chunk_index", - "type": "i32" - } - ] + ] ] - } -} + } + ], + "blockcoordinates":[ + "container", + [ + { + "name":"x", + "type":"i32" + }, + { + "name":"y", + "type":"i32" + }, + { + "name":"z", + "type":"i32" + } + ] + ], + "records":[ + "array", + { + "countType":"varint", + "type":[ + "container", + [ + { + "name":"record", + "type":"blockcoordinates" + } + ] + ] + } + ], + "itemstacks":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"slot", + "type":"slot" + } + ] + ] + } + ], + "links":[ + "array", + { + "countType":"varint", + "type":[ + "container", + [ + { + "name":"item_1", + "type":"varint" + }, + { + "name":"item_2", + "type":"varint" + }, + { + "name":"unknown", + "type":"li16" + } + ] + ] + } + ], + "player_attributes":[ + "array", + { + "countType":"varint", + "type":[ + "container", + [ + { + "name":"min_value", + "type":"f32" + }, + { + "name":"max_value", + "type":"f32" + }, + { + "name":"value", + "type":"f32" + }, + { + "name":"unknown", + "type":"f32" + }, + { + "name":"name", + "type":"string" + } + ] + ] + } + ], + "entity_attributes":[ + "array", + { + "countType":"varint", + "type":[ + "container", + [ + { + "name":"name", + "type":"string" + }, + { + "name":"min_value", + "type":"f32" + }, + { + "name":"value", + "type":"f32" + }, + { + "name":"max_value", + "type":"f32" + } + ] + ] + } + ], + "pack_entries":[ + "array", + { + "countType":"li16", + "type":[ + "container", + [ + { + "name":"pack_id", + "type":"string" + }, + { + "name":"version", + "type":"string" + }, + { + "name":"pack_size", + "type":"u64" + } + ] + ] + } + ], + "pack_versions":[ + "array", + { + "countType":"li16", + "type":[ + "container", + [ + { + "name":"pack_id", + "type":"string" + }, + { + "name":"version", + "type":"string" + } + ] + ] + } + ], + "vector3":[ + "container", + [ + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + } + ] + ], + "metadataints":[ + "array", + { + "countType":"varint", + "type":[ + "container", + [ + { + + } + ] + ] + } + ], + "vector2":[ + "container", + [ + { + "name":"x", + "type":"f32" + }, + { + "name":"y", + "type":"f32" + } + ] + ], + "metadatadictionary":[ + "entityMetadataLoop", + { + "endVal":127, + "type":[ + "container", + [ + { + "anon":true, + "type":[ + "bitfield", + [ + { + "name":"type", + "size":3, + "signed":false + }, + { + "name":"key", + "size":5, + "signed":false + } + ] + ] + }, + { + "name":"value", + "type":[ + "entityMetadataItem", + { + "compareTo":"type" + } + ] + } + ] + ] + } + ], + "slot":[ + "container", + [ + { + "name":"blockId", + "type":"i16" + }, + { + "anon":true, + "type":[ + "switch", + { + "compareTo":"blockId", + "fields":{ + "0":"void" + }, + "default":[ + "container", + [ + { + "name":"itemCount", + "type":"i8" + }, + { + "name":"itemDamage", + "type":"i16" + }, + { + "name":"nbtData", + "type":[ + "buffer", + { + "countType":"li16" + } + ] + } + ] + ] + } + ] + } + ] + ], + "playerlocation":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + }, + { + "name":"yaw", + "type":"f32" + }, + { + "name":"pitch", + "type":"f32" + }, + { + "name":"headYaw", + "type":"f32" + } + ] + ] + } + ], + "encapsulated_packet":[ + "container", + [ + { + "name":"name", + "type":[ + "mapper", + { + "type":"u8", + "mappings":{ + "0xfe":"mcpe" + } + } + ] + }, + { + "name":"params", + "type":[ + "switch", + { + "compareTo":"name", + "fields":{ + "mcpe":"mcpe_packet" + } + } + ] + } + ] + ], + "mcpe_packet":[ + "container", + [ + { + "name":"name", + "type":[ + "mapper", + { + "type":"u8", + "mappings":{ + "0x01":"game_login", + "0x02":"player_status", + "0x03":"server_to_client_handshake", + "0x04":"client_to_server_handshake", + "0x05":"disconnect", + "0x06":"batch", + "0x07":"resource_packs_info", + "0x08":"resource_pack_stack", + "0x09":"resource_pack_client_response", + "0x0a":"text", + "0x0b":"set_time", + "0x0c":"start_game", + "0x0d":"add_player", + "0x0e":"add_entity", + "0x0f":"remove_entity", + "0x10":"add_item_entity", + "0x11":"add_hanging_entity", + "0x12":"take_item_entity", + "0x13":"move_entity", + "0x14":"move_player", + "0x15":"rider_jump", + "0x16":"remove_block", + "0x17":"update_block", + "0x18":"add_painting", + "0x19":"explode", + "0x1a":"level_sound_event", + "0x1b":"level_event", + "0x1c":"block_event", + "0x1d":"entity_event", + "0x1e":"mob_effect", + "0x1f":"update_attributes", + "0x20":"mob_equipment", + "0x21":"mob_armor_equipment", + "0x22":"interact", + "0x23":"use_item", + "0x24":"player_action", + "0x25":"player_fall", + "0x26":"hurt_armor", + "0x27":"set_entity_data", + "0x28":"set_entity_motion", + "0x29":"set_entity_link", + "0x2a":"set_health", + "0x2b":"set_spawn_position", + "0x2c":"animate", + "0x2d":"respawn", + "0x2e":"drop_item", + "0x2f":"inventory_action", + "0x30":"container_open", + "0x31":"container_close", + "0x32":"container_set_slot", + "0x33":"container_set_data", + "0x34":"container_set_content", + "0x35":"crafting_data", + "0x36":"crafting_event", + "0x37":"adventure_settings", + "0x38":"block_entity_data", + "0x39":"player_input", + "0x3a":"full_chunk_data", + "0x3b":"set_commands_enabled", + "0x3c":"set_difficulty", + "0x3d":"change_dimension", + "0x3e":"set_player_game_type", + "0x3f":"player_list", + "0x40":"event", + "0x41":"spawn_experience_orb", + "0x42":"clientbound_map_item_data_", + "0x43":"map_info_request", + "0x44":"request_chunk_radius", + "0x45":"chunk_radius_update", + "0x46":"item_fram_drop_item", + "0x47":"replace_selected_item", + "0x48":"game_rules_changed", + "0x49":"camera", + "0x4a":"add_item", + "0x4b":"boss_event", + "0x4d":"available_commands", + "0x4e":"command_step", + "0x4f":"resource_pack_data_info", + "0x50":"resource_pack_chunk_data", + "0x51":"resource_pack_chunk_request" + } + } + ] + }, + { + "name":"params", + "type":[ + "switch", + { + "compareTo":"name", + "fields":{ + "game_login":"packet_game_login", + "player_status":"packet_player_status", + "server_to_client_handshake":"packet_server_to_client_handshake", + "client_to_server_handshake":"packet_client_to_server_handshake", + "disconnect":"packet_disconnect", + "batch":"packet_batch", + "resource_packs_info":"packet_resource_packs_info", + "resource_pack_stack":"packet_resource_pack_stack", + "resource_pack_client_response":"packet_resource_pack_client_response", + "text":"packet_text", + "set_time":"packet_set_time", + "start_game":"packet_start_game", + "add_player":"packet_add_player", + "add_entity":"packet_add_entity", + "remove_entity":"packet_remove_entity", + "add_item_entity":"packet_add_item_entity", + "add_hanging_entity":"packet_add_hanging_entity", + "take_item_entity":"packet_take_item_entity", + "move_entity":"packet_move_entity", + "move_player":"packet_move_player", + "rider_jump":"packet_rider_jump", + "remove_block":"packet_remove_block", + "update_block":"packet_update_block", + "add_painting":"packet_add_painting", + "explode":"packet_explode", + "level_sound_event":"packet_level_sound_event", + "level_event":"packet_level_event", + "block_event":"packet_block_event", + "entity_event":"packet_entity_event", + "mob_effect":"packet_mob_effect", + "update_attributes":"packet_update_attributes", + "mob_equipment":"packet_mob_equipment", + "mob_armor_equipment":"packet_mob_armor_equipment", + "interact":"packet_interact", + "use_item":"packet_use_item", + "player_action":"packet_player_action", + "player_fall":"packet_player_fall", + "hurt_armor":"packet_hurt_armor", + "set_entity_data":"packet_set_entity_data", + "set_entity_motion":"packet_set_entity_motion", + "set_entity_link":"packet_set_entity_link", + "set_health":"packet_set_health", + "set_spawn_position":"packet_set_spawn_position", + "animate":"packet_animate", + "respawn":"packet_respawn", + "drop_item":"packet_drop_item", + "inventory_action":"packet_inventory_action", + "container_open":"packet_container_open", + "container_close":"packet_container_close", + "container_set_slot":"packet_container_set_slot", + "container_set_data":"packet_container_set_data", + "container_set_content":"packet_container_set_content", + "crafting_data":"packet_crafting_data", + "crafting_event":"packet_crafting_event", + "adventure_settings":"packet_adventure_settings", + "block_entity_data":"packet_block_entity_data", + "player_input":"packet_player_input", + "full_chunk_data":"packet_full_chunk_data", + "set_commands_enabled":"packet_set_commands_enabled", + "set_difficulty":"packet_set_difficulty", + "change_dimension":"packet_change_dimension", + "set_player_game_type":"packet_set_player_game_type", + "player_list":"packet_player_list", + "event":"packet_event", + "spawn_experience_orb":"packet_spawn_experience_orb", + "clientbound_map_item_data_":"packet_clientbound_map_item_data_", + "map_info_request":"packet_map_info_request", + "request_chunk_radius":"packet_request_chunk_radius", + "chunk_radius_update":"packet_chunk_radius_update", + "item_fram_drop_item":"packet_item_fram_drop_item", + "replace_selected_item":"packet_replace_selected_item", + "game_rules_changed":"packet_game_rules_changed", + "camera":"packet_camera", + "add_item":"packet_add_item", + "boss_event":"packet_boss_event", + "available_commands":"packet_available_commands", + "command_step":"packet_command_step", + "resource_pack_data_info":"packet_resource_pack_data_info", + "resource_pack_chunk_data":"packet_resource_pack_chunk_data", + "resource_pack_chunk_request":"packet_resource_pack_chunk_request" + } + } + ] + } + ] + ], + "packet_game_login":[ + "container", + [ + { + "name":"protocol", + "type":"i32" + }, + { + "name":"edition", + "type":"i8" + }, + { + "name":"body", + "type":[ + "buffer", + { + "countType":"varint" + } + ] + } + ] + ], + "packet_player_status":[ + "container", + [ + { + "name":"status", + "type":"i32" + } + ] + ], + "packet_server_to_client_handshake":[ + "container", + [ + { + "name":"server_public_key", + "type":"string" + }, + { + "name":"token", + "type":[ + "buffer", + { + "countType":"varint", + "type":"i8" + } + ] + } + ] + ], + "packet_client_to_server_handshake":[ + "container", + [ + + ] + ], + "packet_disconnect":[ + "container", + [ + { + "name":"hide_disconnection_screen", + "type":"bool" + }, + { + "name":"message", + "type":"string" + } + ] + ], + "packet_batch":[ + "container", + [ + { + "name":"payload", + "type":[ + "buffer", + { + "countType":"varint", + "type":"i8" + } + ] + } + ] + ], + "packet_resource_packs_info":[ + "container", + [ + { + "name":"must_accept", + "type":"bool" + }, + { + "name":"behavior_pack_entries", + "type":"pack_entries" + }, + { + "name":"resource_pack_entries", + "type":"pack_entries" + } + ] + ], + "packet_resource_pack_stack":[ + "container", + [ + { + "name":"must_accept", + "type":"bool" + }, + { + "name":"behavior_pack_versions", + "type":"pack_versions" + }, + { + "name":"resource_pack_versions", + "type":"pack_versions" + } + ] + ], + "packet_resource_pack_client_response":[ + "container", + [ + { + "name":"response_status", + "type":"u8" + }, + { + "name":"resourcepackidversions", + "type":"pack_versions" + } + ] + ], + "packet_text":[ + "container", + [ + { + "name":"type", + "type":"i8" + }, + { + "name":"source", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "1":"string" + }, + "default":"void" + } + ] + }, + { + "name":"message", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "0":"string", + "1":"string", + "2":"string", + "3":"string", + "4":"string" + }, + "default":"void" + } + ] + } + ] + ], + "packet_set_time":[ + "container", + [ + { + "name":"time", + "type":"varint" + }, + { + "name":"started", + "type":"bool" + } + ] + ], + "packet_start_game":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"runtime_entity_id", + "type":"varint" + }, + { + "name":"spawn", + "type":"vector3" + }, + { + "name":"unknown_1", + "type":"vector2" + }, + { + "name":"seed", + "type":"varint" + }, + { + "name":"dimension", + "type":"varint" + }, + { + "name":"generator", + "type":"varint" + }, + { + "name":"gamemode", + "type":"varint" + }, + { + "name":"difficulty", + "type":"varint" + }, + { + "name":"x", + "type":"varint" + }, + { + "name":"y", + "type":"varint" + }, + { + "name":"z", + "type":"varint" + }, + { + "name":"has_achievements_disabled", + "type":"bool" + }, + { + "name":"day_cycle_stop_time", + "type":"varint" + }, + { + "name":"edu_mode", + "type":"bool" + }, + { + "name":"rain_level", + "type":"lf32" + }, + { + "name":"lightnig_level", + "type":"lf32" + }, + { + "name":"enable_commands", + "type":"bool" + }, + { + "name":"is_texturepacks_required", + "type":"bool" + }, + { + "name":"secret", + "type":"string" + }, + { + "name":"world_name", + "type":"string" + } + ] + ], + "packet_add_player":[ + "container", + [ + { + "name":"uuid", + "type":"uuid" + }, + { + "name":"username", + "type":"string" + }, + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"runtime_entity_id", + "type":"varint" + }, + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + }, + { + "name":"speed_x", + "type":"lf32" + }, + { + "name":"speed_y", + "type":"lf32" + }, + { + "name":"speed_z", + "type":"lf32" + }, + { + "name":"pitch", + "type":"lf32" + }, + { + "name":"head_yaw", + "type":"lf32" + }, + { + "name":"yaw", + "type":"lf32" + }, + { + "name":"item", + "type":"slot" + }, + { + "name":"metadata", + "type":"metadatadictionary" + } + ] + ], + "packet_add_entity":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"runtime_entity_id", + "type":"varint" + }, + { + "name":"entity_type", + "type":"varint" + }, + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + }, + { + "name":"speed_x", + "type":"lf32" + }, + { + "name":"speed_y", + "type":"lf32" + }, + { + "name":"speed_z", + "type":"lf32" + }, + { + "name":"yaw", + "type":"lf32" + }, + { + "name":"pitch", + "type":"lf32" + }, + { + "name":"attributes", + "type":"entity_attributes" + }, + { + "name":"metadata", + "type":"metadatadictionary" + }, + { + "name":"links", + "type":"links" + } + ] + ], + "packet_remove_entity":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + } + ] + ], + "packet_add_item_entity":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"runtime_entity_id", + "type":"varint" + }, + { + "name":"item", + "type":"slot" + }, + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + }, + { + "name":"speed_x", + "type":"lf32" + }, + { + "name":"speed_y", + "type":"lf32" + }, + { + "name":"speed_z", + "type":"lf32" + } + ] + ], + "packet_add_hanging_entity":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"runtime_entity_id", + "type":"varint" + }, + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"unknown", + "type":"varint" + } + ] + ], + "packet_take_item_entity":[ + "container", + [ + { + "name":"target", + "type":"varint" + }, + { + "name":"entity_id", + "type":"varint" + } + ] + ], + "packet_move_entity":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"position", + "type":"playerlocation" + } + ] + ], + "packet_move_player":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + }, + { + "name":"pitch", + "type":"lf32" + }, + { + "name":"head_yaw", + "type":"lf32" + }, + { + "name":"yaw", + "type":"lf32" + }, + { + "name":"mode", + "type":"u8" + }, + { + "name":"on_ground", + "type":"bool" + } + ] + ], + "packet_rider_jump":[ + "container", + [ + + ] + ], + "packet_remove_block":[ + "container", + [ + { + "name":"coordinates", + "type":"blockcoordinates" + } + ] + ], + "packet_update_block":[ + "container", + [ + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"block_id", + "type":"varint" + }, + { + "name":"block_meta_and_priority", + "type":"varint" + } + ] + ], + "packet_add_painting":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"runtime_entity_id", + "type":"varint" + }, + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"direction", + "type":"varint" + }, + { + "name":"title", + "type":"string" + } + ] + ], + "packet_explode":[ + "container", + [ + { + "name":"position", + "type":"vector3" + }, + { + "name":"radius", + "type":"lf32" + }, + { + "name":"records", + "type":"records" + } + ] + ], + "packet_level_sound_event":[ + "container", + [ + { + "name":"sound_id", + "type":"u8" + }, + { + "name":"position", + "type":"vector3" + }, + { + "name":"volume", + "type":"varint" + }, + { + "name":"pitch", + "type":"varint" + }, + { + "name":"unknown1", + "type":"bool" + }, + { + "name":"unknown2", + "type":"bool" + } + ] + ], + "packet_level_event":[ + "container", + [ + { + "name":"event_id", + "type":"varint" + }, + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + }, + { + "name":"data", + "type":"varint" + } + ] + ], + "packet_block_event":[ + "container", + [ + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"case_1", + "type":"varint" + }, + { + "name":"case_2", + "type":"varint" + } + ] + ], + "packet_entity_event":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"event_id", + "type":"u8" + }, + { + "name":"unknown", + "type":"varint" + } + ] + ], + "packet_mob_effect":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"event_id", + "type":"u8" + }, + { + "name":"effect_id", + "type":"varint" + }, + { + "name":"amplifier", + "type":"varint" + }, + { + "name":"particles", + "type":"bool" + }, + { + "name":"duration", + "type":"varint" + } + ] + ], + "packet_update_attributes":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"attributes", + "type":"player_attributes" + } + ] + ], + "packet_mob_equipment":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"item", + "type":"varint" + }, + { + "name":"slot", + "type":"u8" + }, + { + "name":"selected_slot", + "type":"u8" + }, + { + "name":"unknown", + "type":"u8" + } + ] + ], + "packet_mob_armor_equipment":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"helmet", + "type":"slot" + }, + { + "name":"chestplate", + "type":"slot" + }, + { + "name":"leggings", + "type":"slot" + }, + { + "name":"boots", + "type":"slot" + } + ] + ], + "packet_interact":[ + "container", + [ + { + "name":"action_id", + "type":"u8" + }, + { + "name":"target_entity_id", + "type":"varint" + } + ] + ], + "packet_use_item":[ + "container", + [ + { + "name":"blockcoordinates", + "type":"blockcoordinates" + }, + { + "name":"unknown", + "type":"varint" + }, + { + "name":"face", + "type":"varint" + }, + { + "name":"facecoordinates", + "type":"vector3" + }, + { + "name":"playerposition", + "type":"vector3" + }, + { + "name":"slot", + "type":"varint" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_player_action":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"action_id", + "type":"varint" + }, + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"face", + "type":"varint" + } + ] + ], + "packet_player_fall":[ + "container", + [ + + ] + ], + "packet_hurt_armor":[ + "container", + [ + { + "name":"health", + "type":"varint" + } + ] + ], + "packet_set_entity_data":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"metadata", + "type":"metadatadictionary" + } + ] + ], + "packet_set_entity_motion":[ + "container", + [ + { + "name":"entity_id", + "type":"varint" + }, + { + "name":"velocity", + "type":"vector3" + } + ] + ], + "packet_set_entity_link":[ + "container", + [ + { + "name":"rider_id", + "type":"varint" + }, + { + "name":"ridden_id", + "type":"varint" + }, + { + "name":"link_type", + "type":"u8" + } + ] + ], + "packet_set_health":[ + "container", + [ + { + "name":"health", + "type":"varint" + } + ] + ], + "packet_set_spawn_position":[ + "container", + [ + { + "name":"unknown_1", + "type":"varint" + }, + { + "name":"coordinates", + "type":"blockcoordinates" + } + ] + ], + "packet_animate":[ + "container", + [ + { + "name":"action_id", + "type":"varint" + }, + { + "name":"entity_id", + "type":"varint" + } + ] + ], + "packet_respawn":[ + "container", + [ + { + "name":"x", + "type":"lf32" + }, + { + "name":"y", + "type":"lf32" + }, + { + "name":"z", + "type":"lf32" + } + ] + ], + "packet_drop_item":[ + "container", + [ + { + "name":"itemtype", + "type":"u8" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_inventory_action":[ + "container", + [ + { + "name":"unknown", + "type":"varint" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_container_open":[ + "container", + [ + { + "name":"window_id", + "type":"u8" + }, + { + "name":"type", + "type":"u8" + }, + { + "name":"slot_count", + "type":"varint" + }, + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"unown_entity_id", + "type":"varint" + } + ] + ], + "packet_container_close":[ + "container", + [ + { + "name":"window_id", + "type":"u8" + } + ] + ], + "packet_container_set_slot":[ + "container", + [ + { + "name":"window_id", + "type":"u8" + }, + { + "name":"slot", + "type":"varint" + }, + { + "name":"hotbarslot", + "type":"varint" + }, + { + "name":"item", + "type":"slot" + }, + { + "name":"unknown2", + "type":"u8" + } + ] + ], + "packet_container_set_data":[ + "container", + [ + { + "name":"window_id", + "type":"u8" + }, + { + "name":"property", + "type":"varint" + }, + { + "name":"value", + "type":"varint" + } + ] + ], + "packet_container_set_content":[ + "container", + [ + { + "name":"windowId", + "type":"i8" + }, + { + "name":"slotData", + "type":"itemstacks" + }, + { + "name":"hotbarData", + "type":[ + "switch", + { + "compareTo":"windowId", + "fields":{ + "0":[ + "array", + { + "countType":"i16", + "type":[ + "container", + [ + { + "name":"slot", + "type":"i32" + } + ] + ] + } + ] + }, + "default":"i16" + } + ] + } + ] + ], + "packet_crafting_data":[ + "container", + [ + { + "name":"recipes", + "type":[ + "container", + [ + { + "name":"entryType", + "type":"i32" + }, + { + "name":"recipe", + "type":[ + "array", + { + "countType":"i32", + "type":[ + "switch", + { + "compareTo":"entryType", + "fields":{ + "0":"shapelessRecipe", + "1":"shapedRecipe", + "2":"furnaceRecipe", + "3":"furnaceRecipeData", + "4":"enchantList" + }, + "default":"void" + } + ] + } + ] + } + ] + ] + }, + { + "name":"cleanRecipes", + "type":"i8" + } + ] + ], + "packet_crafting_event":[ + "container", + [ + { + "name":"window_id", + "type":"u8" + }, + { + "name":"recipe_type", + "type":"varint" + }, + { + "name":"recipe_id", + "type":"uuid" + }, + { + "name":"input", + "type":"itemstacks" + }, + { + "name":"result", + "type":"itemstacks" + } + ] + ], + "packet_adventure_settings":[ + "container", + [ + { + "name":"flags", + "type":"varint" + }, + { + "name":"user_permission", + "type":"varint" + } + ] + ], + "packet_block_entity_data":[ + "container", + [ + { + "name":"coordinates", + "type":"blockcoordinates" + }, + { + "name":"nbtData", + "type":[ + "buffer", + { + "countType":"varint" + } + ] + } + ] + ], + "packet_player_input":[ + "container", + [ + { + "name":"motion_x", + "type":"lf32" + }, + { + "name":"motion_z", + "type":"lf32" + }, + { + "name":"flag1", + "type":"bool" + }, + { + "name":"flag2", + "type":"bool" + } + ] + ], + "packet_full_chunk_data":[ + "container", + [ + { + "name":"chunk_x", + "type":"varint" + }, + { + "name":"chunk_z", + "type":"varint" + }, + { + "name":"chunk_data", + "type":[ + "buffer", + { + "countType":"varint", + "type":"i8" + } + ] + } + ] + ], + "packet_set_commands_enabled":[ + "container", + [ + { + "name":"enabled", + "type":"bool" + } + ] + ], + "packet_set_difficulty":[ + "container", + [ + { + "name":"difficulty", + "type":"varint" + } + ] + ], + "packet_change_dimension":[ + "container", + [ + { + "name":"dimension", + "type":"varint" + }, + { + "name":"position", + "type":"vector3" + }, + { + "name":"unknown", + "type":"bool" + } + ] + ], + "packet_set_player_game_type":[ + "container", + [ + { + "name":"unknown", + "type":"varint" + } + ] + ], + "packet_player_list":[ + "container", + [ + { + "name":"type", + "type":"i8" + }, + { + "name":"entries", + "type":[ + "array", + { + "countType":"i32", + "type":[ + "switch", + { + "compareTo":"type", + "fields":{ + "0":[ + "container", + [ + { + "name":"clientUuid", + "type":"uuid" + }, + { + "name":"entityId", + "type":"i64" + }, + { + "name":"displayName", + "type":"string" + }, + { + "name":"skin", + "type":"skin" + } + ] + ], + "1":[ + "container", + [ + { + "name":"clientUuid", + "type":"uuid" + } + ] + ] + } + } + ] + } + ] + } + ] + ], + "packet_event":[ + "container", + [ + + ] + ], + "packet_spawn_experience_orb":[ + "container", + [ + { + "name":"position", + "type":"vector3" + }, + { + "name":"count", + "type":"varint" + } + ] + ], + "packet_request_chunk_radius":[ + "container", + [ + { + "name":"chunk_radius", + "type":"varint" + } + ] + ], + "packet_chunk_radius_update":[ + "container", + [ + { + "name":"chunk_radius", + "type":"varint" + } + ] + ], + "packet_item_frame_drop_item":[ + "container", + [ + { + "name":"coordinates", + "type":"blockcoordinatesk" + }, + { + "name":"item", + "type":"slot" + } + ] + ], + "packet_replace_selected_item":[ + "container", + [ + + ] + ], + "packet_game_rules_changed":[ + "container", + [ + { + "name":"rules", + "type":"rules" + } + ] + ], + "packet_camera":[ + "container", + [ + + ] + ], + "packet_add_item":[ + "container", + [ + + ] + ], + "packet_boss_event":[ + "container", + [ + + ] + ], + "packet_available_commands":[ + "container", + [ + { + "name":"commands", + "type":"string" + }, + { + "name":"unknown", + "type":"string" + } + ] + ], + "packet_command_step":[ + "container", + [ + { + "name":"command_name", + "type":"string" + }, + { + "name":"command_overload", + "type":"string" + }, + { + "name":"unknown_1", + "type":"varint" + }, + { + "name":"unknown_2", + "type":"varint" + }, + { + "name":"is_output", + "type":"bool" + }, + { + "name":"unknown_5", + "type":"varint" + }, + { + "name":"command_input_json", + "type":"string" + }, + { + "name":"command_output_json", + "type":"string" + }, + { + "name":"unknown_7", + "type":"u8" + }, + { + "name":"unknown_8", + "type":"u8" + }, + { + "name":"entity_id", + "type":"varint" + } + ] + ], + "packet_resource_pack_data_info":[ + "container", + [ + { + "name":"package_id", + "type":"string" + }, + { + "name":"unknown1", + "type":"u32" + }, + { + "name":"unknown2", + "type":"u32" + }, + { + "name":"unknown3", + "type":"u64" + }, + { + "name":"unknown4", + "type":"string" + } + ] + ], + "packet_resource_pack_chunk_data":[ + "container", + [ + { + "name":"package_id", + "type":"string" + }, + { + "name":"unknown1", + "type":"u32" + }, + { + "name":"unknown3", + "type":"u64" + }, + { + "name":"length", + "type":"u32" + }, + { + "name":"payload", + "type":[ + "buffer", + { + "countType":"varint", + "type":"i8" + } + ] + } + ] + ], + "packet_resource_pack_chunk_request":[ + "container", + [ + { + "name":"package_id", + "type":"string" + }, + { + "name":"chunk_index", + "type":"i32" + } + ] + ] + } +} \ No newline at end of file From 166960e2571f124c83616165591e85092b8b7703 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Sun, 22 Jan 2017 13:41:45 -0500 Subject: [PATCH 062/106] skin --- data/protocol.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/data/protocol.json b/data/protocol.json index 5f72188..5eaf9fc 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -12,6 +12,19 @@ "countType":"li16" } ], + "skin": [ + "container", + [ + { + "name": "skin_type", + "type": "string" + }, + { + "name": "texture", + "type": ["buffer",{"countType":"i16"}] + } + ] + ], "rules":[ "array", { From a244ed62dfdcff242001e5858a3e3a2f487323c5 Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Sun, 22 Jan 2017 13:44:21 -0500 Subject: [PATCH 063/106] skin data --- src/createServer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/createServer.js b/src/createServer.js index afb0845..65c0a37 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -127,7 +127,6 @@ function createServer(options, encryption) { decode = jwt.decode(chain, PUBLIC_KEY, 'ES384'); data = jwt.decode(body.data.clientData, decode.identityPublicKey, 'ES384'); - data.SkinData = null; client.emit('mcpe_login', { protocol: packet.protocol, uuid: (decode.extraData != null) ? decode.extraData.identity : null, From d61ddd7d20e71b3485f23f0a83e30488119e027b Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Sun, 22 Jan 2017 13:59:07 -0500 Subject: [PATCH 064/106] oops --- data/protocol.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 5eaf9fc..c8702c7 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -208,15 +208,15 @@ [ { "name":"x", - "type":"i32" + "type":"varint" }, { "name":"y", - "type":"i32" + "type":"varint" }, { "name":"z", - "type":"i32" + "type":"varint" } ] ], From 7c17673f3f6497d15624981c4ff4d8d6f7709ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 18 Jun 2017 17:54:02 +0200 Subject: [PATCH 065/106] TODO --- data/protocol.json | 4248 ++++++++++++++++++++------------------------ 1 file changed, 1948 insertions(+), 2300 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index c8702c7..a0c118d 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -1,2320 +1,1968 @@ { - "types":{ - "string":[ - "pstring", - { - "countType":"varint" - } - ], - "lstring":[ - "pstring", - { - "countType":"li16" - } - ], - "skin": [ - "container", - [ - { - "name": "skin_type", - "type": "string" - }, - { - "name": "texture", - "type": ["buffer",{"countType":"i16"}] - } - ] - ], - "rules":[ - "array", - { - "countType":"varint", - "type":[ - "container", - [ + "types": { + "string": [ + "pstring", { - "name":"name", - "type":"string" - }, - { - "name":"unknown1", - "type":"bool" - }, - { - "name":"unknown2", - "type":"bool" + "countType": "i16" } - ] - ] - } - ], - "shapeless_recipe":[ - "container", - [ - { - "name":"ingredientList", - "type":[ - "array", + ], + "lstring": [ + "pstring", { - "countType":"i32", - "type":"slot" + "countType": "li16" } - ] - }, - { - "name":"resultCount", - "type":"i32" - }, - { - "name":"slot", - "type":"slot" - }, - { - "name":"id", - "type":"uuid" - } - ] - ], - "shaped_recipe":[ - "container", - [ - { - "name":"width", - "type":[ - "count", - { - "type":"i32", - "countFor":"shape" - } - ] - }, - { - "name":"height", - "type":[ - "count", - { - "type":"i32", - "countFor":"shape/0" - } - ] - }, - { - "name":"shape", - "type":[ - "array", - { - "count":"width", - "type":[ - "array", - { - "count":"height", - "type":"slot" - } - ] - } - ] - }, - { - "name":"resultCount", - "type":"i32" - }, - { - "name":"slot", - "type":"slot" - }, - { - "name":"id", - "type":"uuid" - } - ] - ], - "furnace_recipe":[ - "container", - [ - { - "name":"meta", - "type":"i16" - }, - { - "name":"id", - "type":"i16" - }, - { - "name":"result", - "type":"slot" - } - ] - ], - "furnace_recipe_data":[ - "container", - [ - { - "name":"id", - "type":"i16" - }, - { - "name":"meta", - "type":"i16" - }, - { - "name":"result", - "type":"slot" - } - ] - ], - "enchant_list":[ - "array", - { - "countType":"i8", - "type":[ - "container", - [ - { - "name":"cost", - "type":"i32" - }, - { - "name":"enchantments", - "type":[ - "array", - { - "countType":"i8", - "type":[ - "container", - [ - { - "name":"id", - "type":"i32" - }, - { - "name":"level", - "type":"i32" - } - ] - ] - } - ] - }, - { - "name":"name", - "type":"string" - } - ] - ] - } - ], - "blockcoordinates":[ - "container", - [ - { - "name":"x", - "type":"varint" - }, - { - "name":"y", - "type":"varint" - }, - { - "name":"z", - "type":"varint" - } - ] - ], - "records":[ - "array", - { - "countType":"varint", - "type":[ - "container", - [ - { - "name":"record", - "type":"blockcoordinates" - } - ] - ] - } - ], - "itemstacks":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"slot", - "type":"slot" - } - ] - ] - } - ], - "links":[ - "array", - { - "countType":"varint", - "type":[ - "container", - [ - { - "name":"item_1", - "type":"varint" - }, - { - "name":"item_2", - "type":"varint" - }, - { - "name":"unknown", - "type":"li16" - } - ] - ] - } - ], - "player_attributes":[ - "array", - { - "countType":"varint", - "type":[ - "container", - [ - { - "name":"min_value", - "type":"f32" - }, - { - "name":"max_value", - "type":"f32" - }, - { - "name":"value", - "type":"f32" - }, - { - "name":"unknown", - "type":"f32" - }, - { - "name":"name", - "type":"string" - } - ] - ] - } - ], - "entity_attributes":[ - "array", - { - "countType":"varint", - "type":[ - "container", - [ - { - "name":"name", - "type":"string" - }, - { - "name":"min_value", - "type":"f32" - }, - { - "name":"value", - "type":"f32" - }, - { - "name":"max_value", - "type":"f32" - } - ] - ] - } - ], - "pack_entries":[ - "array", - { - "countType":"li16", - "type":[ - "container", - [ - { - "name":"pack_id", - "type":"string" - }, - { - "name":"version", - "type":"string" - }, - { - "name":"pack_size", - "type":"u64" - } - ] - ] - } - ], - "pack_versions":[ - "array", - { - "countType":"li16", - "type":[ - "container", - [ - { - "name":"pack_id", - "type":"string" - }, - { - "name":"version", - "type":"string" - } - ] - ] - } - ], - "vector3":[ - "container", - [ - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - } - ] - ], - "metadataints":[ - "array", - { - "countType":"varint", - "type":[ - "container", - [ - { - - } - ] - ] - } - ], - "vector2":[ - "container", - [ - { - "name":"x", - "type":"f32" - }, - { - "name":"y", - "type":"f32" - } - ] - ], - "metadatadictionary":[ - "entityMetadataLoop", - { - "endVal":127, - "type":[ - "container", - [ - { - "anon":true, - "type":[ - "bitfield", - [ - { - "name":"type", - "size":3, - "signed":false - }, - { - "name":"key", - "size":5, - "signed":false - } - ] - ] - }, - { - "name":"value", - "type":[ - "entityMetadataItem", - { - "compareTo":"type" - } - ] - } - ] - ] - } - ], - "slot":[ - "container", - [ - { - "name":"blockId", - "type":"i16" - }, - { - "anon":true, - "type":[ - "switch", - { - "compareTo":"blockId", - "fields":{ - "0":"void" - }, - "default":[ - "container", - [ - { - "name":"itemCount", - "type":"i8" - }, - { - "name":"itemDamage", - "type":"i16" - }, - { - "name":"nbtData", - "type":[ - "buffer", - { - "countType":"li16" - } - ] - } - ] - ] - } - ] - } - ] - ], - "playerlocation":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - }, - { - "name":"yaw", - "type":"f32" - }, - { - "name":"pitch", - "type":"f32" - }, - { - "name":"headYaw", - "type":"f32" - } - ] - ] - } - ], - "encapsulated_packet":[ - "container", - [ - { - "name":"name", - "type":[ - "mapper", - { - "type":"u8", - "mappings":{ - "0xfe":"mcpe" - } - } - ] - }, - { - "name":"params", - "type":[ - "switch", - { - "compareTo":"name", - "fields":{ - "mcpe":"mcpe_packet" - } - } - ] - } - ] - ], - "mcpe_packet":[ - "container", - [ - { - "name":"name", - "type":[ - "mapper", - { - "type":"u8", - "mappings":{ - "0x01":"game_login", - "0x02":"player_status", - "0x03":"server_to_client_handshake", - "0x04":"client_to_server_handshake", - "0x05":"disconnect", - "0x06":"batch", - "0x07":"resource_packs_info", - "0x08":"resource_pack_stack", - "0x09":"resource_pack_client_response", - "0x0a":"text", - "0x0b":"set_time", - "0x0c":"start_game", - "0x0d":"add_player", - "0x0e":"add_entity", - "0x0f":"remove_entity", - "0x10":"add_item_entity", - "0x11":"add_hanging_entity", - "0x12":"take_item_entity", - "0x13":"move_entity", - "0x14":"move_player", - "0x15":"rider_jump", - "0x16":"remove_block", - "0x17":"update_block", - "0x18":"add_painting", - "0x19":"explode", - "0x1a":"level_sound_event", - "0x1b":"level_event", - "0x1c":"block_event", - "0x1d":"entity_event", - "0x1e":"mob_effect", - "0x1f":"update_attributes", - "0x20":"mob_equipment", - "0x21":"mob_armor_equipment", - "0x22":"interact", - "0x23":"use_item", - "0x24":"player_action", - "0x25":"player_fall", - "0x26":"hurt_armor", - "0x27":"set_entity_data", - "0x28":"set_entity_motion", - "0x29":"set_entity_link", - "0x2a":"set_health", - "0x2b":"set_spawn_position", - "0x2c":"animate", - "0x2d":"respawn", - "0x2e":"drop_item", - "0x2f":"inventory_action", - "0x30":"container_open", - "0x31":"container_close", - "0x32":"container_set_slot", - "0x33":"container_set_data", - "0x34":"container_set_content", - "0x35":"crafting_data", - "0x36":"crafting_event", - "0x37":"adventure_settings", - "0x38":"block_entity_data", - "0x39":"player_input", - "0x3a":"full_chunk_data", - "0x3b":"set_commands_enabled", - "0x3c":"set_difficulty", - "0x3d":"change_dimension", - "0x3e":"set_player_game_type", - "0x3f":"player_list", - "0x40":"event", - "0x41":"spawn_experience_orb", - "0x42":"clientbound_map_item_data_", - "0x43":"map_info_request", - "0x44":"request_chunk_radius", - "0x45":"chunk_radius_update", - "0x46":"item_fram_drop_item", - "0x47":"replace_selected_item", - "0x48":"game_rules_changed", - "0x49":"camera", - "0x4a":"add_item", - "0x4b":"boss_event", - "0x4d":"available_commands", - "0x4e":"command_step", - "0x4f":"resource_pack_data_info", - "0x50":"resource_pack_chunk_data", - "0x51":"resource_pack_chunk_request" - } - } - ] - }, - { - "name":"params", - "type":[ - "switch", - { - "compareTo":"name", - "fields":{ - "game_login":"packet_game_login", - "player_status":"packet_player_status", - "server_to_client_handshake":"packet_server_to_client_handshake", - "client_to_server_handshake":"packet_client_to_server_handshake", - "disconnect":"packet_disconnect", - "batch":"packet_batch", - "resource_packs_info":"packet_resource_packs_info", - "resource_pack_stack":"packet_resource_pack_stack", - "resource_pack_client_response":"packet_resource_pack_client_response", - "text":"packet_text", - "set_time":"packet_set_time", - "start_game":"packet_start_game", - "add_player":"packet_add_player", - "add_entity":"packet_add_entity", - "remove_entity":"packet_remove_entity", - "add_item_entity":"packet_add_item_entity", - "add_hanging_entity":"packet_add_hanging_entity", - "take_item_entity":"packet_take_item_entity", - "move_entity":"packet_move_entity", - "move_player":"packet_move_player", - "rider_jump":"packet_rider_jump", - "remove_block":"packet_remove_block", - "update_block":"packet_update_block", - "add_painting":"packet_add_painting", - "explode":"packet_explode", - "level_sound_event":"packet_level_sound_event", - "level_event":"packet_level_event", - "block_event":"packet_block_event", - "entity_event":"packet_entity_event", - "mob_effect":"packet_mob_effect", - "update_attributes":"packet_update_attributes", - "mob_equipment":"packet_mob_equipment", - "mob_armor_equipment":"packet_mob_armor_equipment", - "interact":"packet_interact", - "use_item":"packet_use_item", - "player_action":"packet_player_action", - "player_fall":"packet_player_fall", - "hurt_armor":"packet_hurt_armor", - "set_entity_data":"packet_set_entity_data", - "set_entity_motion":"packet_set_entity_motion", - "set_entity_link":"packet_set_entity_link", - "set_health":"packet_set_health", - "set_spawn_position":"packet_set_spawn_position", - "animate":"packet_animate", - "respawn":"packet_respawn", - "drop_item":"packet_drop_item", - "inventory_action":"packet_inventory_action", - "container_open":"packet_container_open", - "container_close":"packet_container_close", - "container_set_slot":"packet_container_set_slot", - "container_set_data":"packet_container_set_data", - "container_set_content":"packet_container_set_content", - "crafting_data":"packet_crafting_data", - "crafting_event":"packet_crafting_event", - "adventure_settings":"packet_adventure_settings", - "block_entity_data":"packet_block_entity_data", - "player_input":"packet_player_input", - "full_chunk_data":"packet_full_chunk_data", - "set_commands_enabled":"packet_set_commands_enabled", - "set_difficulty":"packet_set_difficulty", - "change_dimension":"packet_change_dimension", - "set_player_game_type":"packet_set_player_game_type", - "player_list":"packet_player_list", - "event":"packet_event", - "spawn_experience_orb":"packet_spawn_experience_orb", - "clientbound_map_item_data_":"packet_clientbound_map_item_data_", - "map_info_request":"packet_map_info_request", - "request_chunk_radius":"packet_request_chunk_radius", - "chunk_radius_update":"packet_chunk_radius_update", - "item_fram_drop_item":"packet_item_fram_drop_item", - "replace_selected_item":"packet_replace_selected_item", - "game_rules_changed":"packet_game_rules_changed", - "camera":"packet_camera", - "add_item":"packet_add_item", - "boss_event":"packet_boss_event", - "available_commands":"packet_available_commands", - "command_step":"packet_command_step", - "resource_pack_data_info":"packet_resource_pack_data_info", - "resource_pack_chunk_data":"packet_resource_pack_chunk_data", - "resource_pack_chunk_request":"packet_resource_pack_chunk_request" - } - } - ] - } - ] - ], - "packet_game_login":[ - "container", - [ - { - "name":"protocol", - "type":"i32" - }, - { - "name":"edition", - "type":"i8" - }, - { - "name":"body", - "type":[ - "buffer", - { - "countType":"varint" - } - ] - } - ] - ], - "packet_player_status":[ - "container", - [ - { - "name":"status", - "type":"i32" - } - ] - ], - "packet_server_to_client_handshake":[ - "container", - [ - { - "name":"server_public_key", - "type":"string" - }, - { - "name":"token", - "type":[ - "buffer", - { - "countType":"varint", - "type":"i8" - } - ] - } - ] - ], - "packet_client_to_server_handshake":[ - "container", - [ - - ] - ], - "packet_disconnect":[ - "container", - [ - { - "name":"hide_disconnection_screen", - "type":"bool" - }, - { - "name":"message", - "type":"string" - } - ] - ], - "packet_batch":[ - "container", - [ - { - "name":"payload", - "type":[ - "buffer", - { - "countType":"varint", - "type":"i8" - } - ] - } - ] - ], - "packet_resource_packs_info":[ - "container", - [ - { - "name":"must_accept", - "type":"bool" - }, - { - "name":"behavior_pack_entries", - "type":"pack_entries" - }, - { - "name":"resource_pack_entries", - "type":"pack_entries" - } - ] - ], - "packet_resource_pack_stack":[ - "container", - [ - { - "name":"must_accept", - "type":"bool" - }, - { - "name":"behavior_pack_versions", - "type":"pack_versions" - }, - { - "name":"resource_pack_versions", - "type":"pack_versions" - } - ] - ], - "packet_resource_pack_client_response":[ - "container", - [ - { - "name":"response_status", - "type":"u8" - }, - { - "name":"resourcepackidversions", - "type":"pack_versions" - } - ] - ], - "packet_text":[ - "container", - [ - { - "name":"type", - "type":"i8" - }, - { - "name":"source", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "1":"string" - }, - "default":"void" - } - ] - }, - { - "name":"message", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "0":"string", - "1":"string", - "2":"string", - "3":"string", - "4":"string" - }, - "default":"void" - } - ] - } - ] - ], - "packet_set_time":[ - "container", - [ - { - "name":"time", - "type":"varint" - }, - { - "name":"started", - "type":"bool" - } - ] - ], - "packet_start_game":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"runtime_entity_id", - "type":"varint" - }, - { - "name":"spawn", - "type":"vector3" - }, - { - "name":"unknown_1", - "type":"vector2" - }, - { - "name":"seed", - "type":"varint" - }, - { - "name":"dimension", - "type":"varint" - }, - { - "name":"generator", - "type":"varint" - }, - { - "name":"gamemode", - "type":"varint" - }, - { - "name":"difficulty", - "type":"varint" - }, - { - "name":"x", - "type":"varint" - }, - { - "name":"y", - "type":"varint" - }, - { - "name":"z", - "type":"varint" - }, - { - "name":"has_achievements_disabled", - "type":"bool" - }, - { - "name":"day_cycle_stop_time", - "type":"varint" - }, - { - "name":"edu_mode", - "type":"bool" - }, - { - "name":"rain_level", - "type":"lf32" - }, - { - "name":"lightnig_level", - "type":"lf32" - }, - { - "name":"enable_commands", - "type":"bool" - }, - { - "name":"is_texturepacks_required", - "type":"bool" - }, - { - "name":"secret", - "type":"string" - }, - { - "name":"world_name", - "type":"string" - } - ] - ], - "packet_add_player":[ - "container", - [ - { - "name":"uuid", - "type":"uuid" - }, - { - "name":"username", - "type":"string" - }, - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"runtime_entity_id", - "type":"varint" - }, - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - }, - { - "name":"speed_x", - "type":"lf32" - }, - { - "name":"speed_y", - "type":"lf32" - }, - { - "name":"speed_z", - "type":"lf32" - }, - { - "name":"pitch", - "type":"lf32" - }, - { - "name":"head_yaw", - "type":"lf32" - }, - { - "name":"yaw", - "type":"lf32" - }, - { - "name":"item", - "type":"slot" - }, - { - "name":"metadata", - "type":"metadatadictionary" - } - ] - ], - "packet_add_entity":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"runtime_entity_id", - "type":"varint" - }, - { - "name":"entity_type", - "type":"varint" - }, - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - }, - { - "name":"speed_x", - "type":"lf32" - }, - { - "name":"speed_y", - "type":"lf32" - }, - { - "name":"speed_z", - "type":"lf32" - }, - { - "name":"yaw", - "type":"lf32" - }, - { - "name":"pitch", - "type":"lf32" - }, - { - "name":"attributes", - "type":"entity_attributes" - }, - { - "name":"metadata", - "type":"metadatadictionary" - }, - { - "name":"links", - "type":"links" - } - ] - ], - "packet_remove_entity":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - } - ] - ], - "packet_add_item_entity":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"runtime_entity_id", - "type":"varint" - }, - { - "name":"item", - "type":"slot" - }, - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - }, - { - "name":"speed_x", - "type":"lf32" - }, - { - "name":"speed_y", - "type":"lf32" - }, - { - "name":"speed_z", - "type":"lf32" - } - ] - ], - "packet_add_hanging_entity":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"runtime_entity_id", - "type":"varint" - }, - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"unknown", - "type":"varint" - } - ] - ], - "packet_take_item_entity":[ - "container", - [ - { - "name":"target", - "type":"varint" - }, - { - "name":"entity_id", - "type":"varint" - } - ] - ], - "packet_move_entity":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"position", - "type":"playerlocation" - } - ] - ], - "packet_move_player":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - }, - { - "name":"pitch", - "type":"lf32" - }, - { - "name":"head_yaw", - "type":"lf32" - }, - { - "name":"yaw", - "type":"lf32" - }, - { - "name":"mode", - "type":"u8" - }, - { - "name":"on_ground", - "type":"bool" - } - ] - ], - "packet_rider_jump":[ - "container", - [ - - ] - ], - "packet_remove_block":[ - "container", - [ - { - "name":"coordinates", - "type":"blockcoordinates" - } - ] - ], - "packet_update_block":[ - "container", - [ - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"block_id", - "type":"varint" - }, - { - "name":"block_meta_and_priority", - "type":"varint" - } - ] - ], - "packet_add_painting":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"runtime_entity_id", - "type":"varint" - }, - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"direction", - "type":"varint" - }, - { - "name":"title", - "type":"string" - } - ] - ], - "packet_explode":[ - "container", - [ - { - "name":"position", - "type":"vector3" - }, - { - "name":"radius", - "type":"lf32" - }, - { - "name":"records", - "type":"records" - } - ] - ], - "packet_level_sound_event":[ - "container", - [ - { - "name":"sound_id", - "type":"u8" - }, - { - "name":"position", - "type":"vector3" - }, - { - "name":"volume", - "type":"varint" - }, - { - "name":"pitch", - "type":"varint" - }, - { - "name":"unknown1", - "type":"bool" - }, - { - "name":"unknown2", - "type":"bool" - } - ] - ], - "packet_level_event":[ - "container", - [ - { - "name":"event_id", - "type":"varint" - }, - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - }, - { - "name":"data", - "type":"varint" - } - ] - ], - "packet_block_event":[ - "container", - [ - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"case_1", - "type":"varint" - }, - { - "name":"case_2", - "type":"varint" - } - ] - ], - "packet_entity_event":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"event_id", - "type":"u8" - }, - { - "name":"unknown", - "type":"varint" - } - ] - ], - "packet_mob_effect":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"event_id", - "type":"u8" - }, - { - "name":"effect_id", - "type":"varint" - }, - { - "name":"amplifier", - "type":"varint" - }, - { - "name":"particles", - "type":"bool" - }, - { - "name":"duration", - "type":"varint" - } - ] - ], - "packet_update_attributes":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"attributes", - "type":"player_attributes" - } - ] - ], - "packet_mob_equipment":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"item", - "type":"varint" - }, - { - "name":"slot", - "type":"u8" - }, - { - "name":"selected_slot", - "type":"u8" - }, - { - "name":"unknown", - "type":"u8" - } - ] - ], - "packet_mob_armor_equipment":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"helmet", - "type":"slot" - }, - { - "name":"chestplate", - "type":"slot" - }, - { - "name":"leggings", - "type":"slot" - }, - { - "name":"boots", - "type":"slot" - } - ] - ], - "packet_interact":[ - "container", - [ - { - "name":"action_id", - "type":"u8" - }, - { - "name":"target_entity_id", - "type":"varint" - } - ] - ], - "packet_use_item":[ - "container", - [ - { - "name":"blockcoordinates", - "type":"blockcoordinates" - }, - { - "name":"unknown", - "type":"varint" - }, - { - "name":"face", - "type":"varint" - }, - { - "name":"facecoordinates", - "type":"vector3" - }, - { - "name":"playerposition", - "type":"vector3" - }, - { - "name":"slot", - "type":"varint" - }, - { - "name":"item", - "type":"slot" - } - ] - ], - "packet_player_action":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"action_id", - "type":"varint" - }, - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"face", - "type":"varint" - } - ] - ], - "packet_player_fall":[ - "container", - [ - - ] - ], - "packet_hurt_armor":[ - "container", - [ - { - "name":"health", - "type":"varint" - } - ] - ], - "packet_set_entity_data":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"metadata", - "type":"metadatadictionary" - } - ] - ], - "packet_set_entity_motion":[ - "container", - [ - { - "name":"entity_id", - "type":"varint" - }, - { - "name":"velocity", - "type":"vector3" - } - ] - ], - "packet_set_entity_link":[ - "container", - [ - { - "name":"rider_id", - "type":"varint" - }, - { - "name":"ridden_id", - "type":"varint" - }, - { - "name":"link_type", - "type":"u8" - } - ] - ], - "packet_set_health":[ - "container", - [ - { - "name":"health", - "type":"varint" - } - ] - ], - "packet_set_spawn_position":[ - "container", - [ - { - "name":"unknown_1", - "type":"varint" - }, - { - "name":"coordinates", - "type":"blockcoordinates" - } - ] - ], - "packet_animate":[ - "container", - [ - { - "name":"action_id", - "type":"varint" - }, - { - "name":"entity_id", - "type":"varint" - } - ] - ], - "packet_respawn":[ - "container", - [ - { - "name":"x", - "type":"lf32" - }, - { - "name":"y", - "type":"lf32" - }, - { - "name":"z", - "type":"lf32" - } - ] - ], - "packet_drop_item":[ - "container", - [ - { - "name":"itemtype", - "type":"u8" - }, - { - "name":"item", - "type":"slot" - } - ] - ], - "packet_inventory_action":[ - "container", - [ - { - "name":"unknown", - "type":"varint" - }, - { - "name":"item", - "type":"slot" - } - ] - ], - "packet_container_open":[ - "container", - [ - { - "name":"window_id", - "type":"u8" - }, - { - "name":"type", - "type":"u8" - }, - { - "name":"slot_count", - "type":"varint" - }, - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"unown_entity_id", - "type":"varint" - } - ] - ], - "packet_container_close":[ - "container", - [ - { - "name":"window_id", - "type":"u8" - } - ] - ], - "packet_container_set_slot":[ - "container", - [ - { - "name":"window_id", - "type":"u8" - }, - { - "name":"slot", - "type":"varint" - }, - { - "name":"hotbarslot", - "type":"varint" - }, - { - "name":"item", - "type":"slot" - }, - { - "name":"unknown2", - "type":"u8" - } - ] - ], - "packet_container_set_data":[ - "container", - [ - { - "name":"window_id", - "type":"u8" - }, - { - "name":"property", - "type":"varint" - }, - { - "name":"value", - "type":"varint" - } - ] - ], - "packet_container_set_content":[ - "container", - [ - { - "name":"windowId", - "type":"i8" - }, - { - "name":"slotData", - "type":"itemstacks" - }, - { - "name":"hotbarData", - "type":[ - "switch", - { - "compareTo":"windowId", - "fields":{ - "0":[ - "array", - { - "countType":"i16", - "type":[ - "container", - [ - { - "name":"slot", - "type":"i32" - } - ] - ] - } - ] - }, - "default":"i16" - } - ] - } - ] - ], - "packet_crafting_data":[ - "container", - [ - { - "name":"recipes", - "type":[ + ], + "vector3": [ "container", [ - { - "name":"entryType", - "type":"i32" - }, - { - "name":"recipe", - "type":[ - "array", - { - "countType":"i32", - "type":[ - "switch", - { - "compareTo":"entryType", - "fields":{ - "0":"shapelessRecipe", - "1":"shapedRecipe", - "2":"furnaceRecipe", - "3":"furnaceRecipeData", - "4":"enchantList" - }, - "default":"void" - } - ] - } - ] - } + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + } ] - ] - }, - { - "name":"cleanRecipes", - "type":"i8" - } - ] - ], - "packet_crafting_event":[ - "container", - [ - { - "name":"window_id", - "type":"u8" - }, - { - "name":"recipe_type", - "type":"varint" - }, - { - "name":"recipe_id", - "type":"uuid" - }, - { - "name":"input", - "type":"itemstacks" - }, - { - "name":"result", - "type":"itemstacks" - } - ] - ], - "packet_adventure_settings":[ - "container", - [ - { - "name":"flags", - "type":"varint" - }, - { - "name":"user_permission", - "type":"varint" - } - ] - ], - "packet_block_entity_data":[ - "container", - [ - { - "name":"coordinates", - "type":"blockcoordinates" - }, - { - "name":"nbtData", - "type":[ - "buffer", - { - "countType":"varint" - } - ] - } - ] - ], - "packet_player_input":[ - "container", - [ - { - "name":"motion_x", - "type":"lf32" - }, - { - "name":"motion_z", - "type":"lf32" - }, - { - "name":"flag1", - "type":"bool" - }, - { - "name":"flag2", - "type":"bool" - } - ] - ], - "packet_full_chunk_data":[ - "container", - [ - { - "name":"chunk_x", - "type":"varint" - }, - { - "name":"chunk_z", - "type":"varint" - }, - { - "name":"chunk_data", - "type":[ - "buffer", - { - "countType":"varint", - "type":"i8" - } - ] - } - ] - ], - "packet_set_commands_enabled":[ - "container", - [ - { - "name":"enabled", - "type":"bool" - } - ] - ], - "packet_set_difficulty":[ - "container", - [ - { - "name":"difficulty", - "type":"varint" - } - ] - ], - "packet_change_dimension":[ - "container", - [ - { - "name":"dimension", - "type":"varint" - }, - { - "name":"position", - "type":"vector3" - }, - { - "name":"unknown", - "type":"bool" - } - ] - ], - "packet_set_player_game_type":[ - "container", - [ - { - "name":"unknown", - "type":"varint" - } - ] - ], - "packet_player_list":[ - "container", - [ - { - "name":"type", - "type":"i8" - }, - { - "name":"entries", - "type":[ + ], + "vector2": [ + "container", + [ + { + "name": "x", + "type": "f32" + }, + { + "name": "y", + "type": "f32" + } + ] + ], + "playerlocation": [ "array", { - "countType":"i32", - "type":[ - "switch", - { - "compareTo":"type", - "fields":{ - "0":[ - "container", - [ + "countType": "i16", + "type": [ + "container", + [ { - "name":"clientUuid", - "type":"uuid" + "name": "x", + "type": "lf32" }, { - "name":"entityId", - "type":"i64" + "name": "y", + "type": "lf32" }, { - "name":"displayName", - "type":"string" + "name": "z", + "type": "lf32" }, { - "name":"skin", - "type":"skin" + "name": "yaw", + "type": "f32" + }, + { + "name": "pitch", + "type": "f32" + }, + { + "name": "headYaw", + "type": "f32" + } + ] + ] + } + ], + "encapsulated_packet": [ + "container", + [ + { + "name": "name", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0xfe": "mcpe" + } + } + ] + }, + { + "name": "params", + "type": [ + "switch", + { + "compareTo": "name", + "fields": { + "mcpe": "mcpe_packet" + } } - ] - ], - "1":[ - "container", - [ - { - "name":"clientUuid", - "type":"uuid" - } - ] ] - } } - ] - } - ] - } - ] - ], - "packet_event":[ - "container", - [ - - ] - ], - "packet_spawn_experience_orb":[ - "container", - [ - { - "name":"position", - "type":"vector3" - }, - { - "name":"count", - "type":"varint" - } - ] - ], - "packet_request_chunk_radius":[ - "container", - [ - { - "name":"chunk_radius", - "type":"varint" - } - ] - ], - "packet_chunk_radius_update":[ - "container", - [ - { - "name":"chunk_radius", - "type":"varint" - } - ] - ], - "packet_item_frame_drop_item":[ - "container", - [ - { - "name":"coordinates", - "type":"blockcoordinatesk" - }, - { - "name":"item", - "type":"slot" - } - ] - ], - "packet_replace_selected_item":[ - "container", - [ - - ] - ], - "packet_game_rules_changed":[ - "container", - [ - { - "name":"rules", - "type":"rules" - } - ] - ], - "packet_camera":[ - "container", - [ - - ] - ], - "packet_add_item":[ - "container", - [ - - ] - ], - "packet_boss_event":[ - "container", - [ - - ] - ], - "packet_available_commands":[ - "container", - [ - { - "name":"commands", - "type":"string" - }, - { - "name":"unknown", - "type":"string" - } - ] - ], - "packet_command_step":[ - "container", - [ - { - "name":"command_name", - "type":"string" - }, - { - "name":"command_overload", - "type":"string" - }, - { - "name":"unknown_1", - "type":"varint" - }, - { - "name":"unknown_2", - "type":"varint" - }, - { - "name":"is_output", - "type":"bool" - }, - { - "name":"unknown_5", - "type":"varint" - }, - { - "name":"command_input_json", - "type":"string" - }, - { - "name":"command_output_json", - "type":"string" - }, - { - "name":"unknown_7", - "type":"u8" - }, - { - "name":"unknown_8", - "type":"u8" - }, - { - "name":"entity_id", - "type":"varint" - } - ] - ], - "packet_resource_pack_data_info":[ - "container", - [ - { - "name":"package_id", - "type":"string" - }, - { - "name":"unknown1", - "type":"u32" - }, - { - "name":"unknown2", - "type":"u32" - }, - { - "name":"unknown3", - "type":"u64" - }, - { - "name":"unknown4", - "type":"string" - } - ] - ], - "packet_resource_pack_chunk_data":[ - "container", - [ - { - "name":"package_id", - "type":"string" - }, - { - "name":"unknown1", - "type":"u32" - }, - { - "name":"unknown3", - "type":"u64" - }, - { - "name":"length", - "type":"u32" - }, - { - "name":"payload", - "type":[ - "buffer", - { - "countType":"varint", - "type":"i8" - } - ] - } - ] - ], - "packet_resource_pack_chunk_request":[ - "container", - [ - { - "name":"package_id", - "type":"string" - }, - { - "name":"chunk_index", - "type":"i32" - } - ] - ] - } -} \ No newline at end of file + ] + ], + "mcpe_packet": [ + "container", + [ + { + "name": "name", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0x01": "game_login", + "0x02": "play_status", + "0x03": "server_to_client_handshake", + "0x04": "client_to_server_handshake", + "0x05": "disconnect", + "0x06": "resource_packs_info", + "0x07": "resource_pack_stack", + "0x08": "resource_pack_client_response", + "0x09": "text", + "0x0a": "set_time", + "0x0b": "start_game", + "0x0c": "add_player", + "0x0d": "add_entity", + "0x0e": "remove_entity", + "0x0f": "add_item_entity", + "0x10": "add_hanging_entity", + "0x11": "take_item_entity", + "0x12": "move_entity", + "0x13": "move_player", + "0x14": "rider_jump", + "0x15": "remove_block", + "0x16": "update_block", + "0x17": "add_painting", + "0x18": "explode", + "0x19": "level_sound_event", + "0x1a": "level_event", + "0x1b": "block_event", + "0x1c": "entity_event", + "0x1d": "mob_effect", + "0x1e": "update_attributes", + "0x1f": "mob_equipment", + "0x20": "mob_armor_equipment", + "0x21": "interact", + "0x22": "block_pick_request", + "0x23": "use_item", + "0x24": "player_action", + "0x25": "entity_fall", + "0x26": "hurt_armor", + "0x27": "set_entity_data", + "0x28": "set_entity_motion", + "0x29": "set_entity_link", + "0x2a": "set_health", + "0x2b": "set_spawn_position", + "0x2c": "animate", + "0x2d": "respawn", + "0x2e": "drop_item", + "0x2f": "inventory_action", + "0x30": "container_open", + "0x31": "container_close", + "0x32": "container_set_slot", + "0x33": "container_set_data", + "0x34": "container_set_content", + "0x35": "crafting_data", + "0x36": "crafting_event", + "0x37": "adventure_settings", + "0x38": "block_entity_data", + "0x39": "player_input", + "0x3a": "full_chunk_data", + "0x3b": "set_commands_enabled", + "0x3c": "set_difficulty", + "0x3d": "change_dimension", + "0x3e": "set_player_game_type", + "0x3f": "player_list", + "0x40": "simple_event", + "0x41": "event", + "0x42": "spawn_experience_orb", + "0x43": "clientbound_map_item_data_", + "0x44": "map_info_request", + "0x45": "request_chunk_radius", + "0x46": "chunk_radius_update", + "0x47": "item_frame_drop_item", + "0x48": "replace_selected_item", + "0x49": "game_rules_changed", + "0x4a": "camera", + "0x4b": "add_item", + "0x4c": "boss_event", + "0x4d": "show_credits", + "0x4e": "available_commands", + "0x4f": "command_step", + "0x50": "command_block_update", + "0x51": "update_trade", + "0x52": "update_equip", + "0x53": "resource_pack_data_info", + "0x54": "resource_pack_chunk_data", + "0x55": "resource_pack_chunk_request", + "0x56": "transfer", + "0x57": "play_sound", + "0x58": "stop_sound", + "0x59": "set_title", + "0x5a": "add_behavior_tree_packet", + "0x5b": "structure_block_update_packet" + } + } + ] + }, + { + "name": "params", + "type": [ + "switch", + { + "compareTo": "name", + "fields": { + "game_login": "packet_game_login", + "play_status": "packet_play_status", + "server_to_client_handshake": "packet_server_to_client_handshake", + "client_to_server_handshake": "packet_client_to_server_handshake", + "disconnect": "packet_disconnect", + "resource_packs_info": "packet_resource_packs_info", + "resource_pack_stack": "packet_resource_pack_stack", + "resource_pack_client_response": "packet_resource_pack_client_response", + "text": "packet_text", + "set_time": "packet_set_time", + "start_game": "packet_start_game", + "add_player": "packet_add_player", + "add_entity": "packet_add_entity", + "remove_entity": "packet_remove_entity", + "add_item_entity": "packet_add_item_entity", + "add_hanging_entity": "packet_add_hanging_entity", + "take_item_entity": "packet_take_item_entity", + "move_entity": "packet_move_entity", + "move_player": "packet_move_player", + "rider_jump": "packet_rider_jump", + "remove_block": "packet_remove_block", + "update_block": "packet_update_block", + "add_painting": "packet_add_painting", + "explode": "packet_explode", + "level_sound_event": "packet_level_sound_event", + "level_event": "packet_level_event", + "block_event": "packet_block_event", + "entity_event": "packet_entity_event", + "mob_effect": "packet_mob_effect", + "update_attributes": "packet_update_attributes", + "mob_equipment": "packet_mob_equipment", + "mob_armor_equipment": "packet_mob_armor_equipment", + "interact": "packet_interact", + "block_pick_request": "packet_block_pick_request", + "use_item": "packet_use_item", + "player_action": "packet_player_action", + "entity_fall": "packet_entity_fall", + "hurt_armor": "packet_hurt_armor", + "set_entity_data": "packet_set_entity_data", + "set_entity_motion": "packet_set_entity_motion", + "set_entity_link": "packet_set_entity_link", + "set_health": "packet_set_health", + "set_spawn_position": "packet_set_spawn_position", + "animate": "packet_animate", + "respawn": "packet_respawn", + "drop_item": "packet_drop_item", + "inventory_action": "packet_inventory_action", + "container_open": "packet_container_open", + "container_close": "packet_container_close", + "container_set_slot": "packet_container_set_slot", + "container_set_data": "packet_container_set_data", + "container_set_content": "packet_container_set_content", + "crafting_data": "packet_crafting_data", + "crafting_event": "packet_crafting_event", + "adventure_settings": "packet_adventure_settings", + "block_entity_data": "packet_block_entity_data", + "player_input": "packet_player_input", + "full_chunk_data": "packet_full_chunk_data", + "set_commands_enabled": "packet_set_commands_enabled", + "set_difficulty": "packet_set_difficulty", + "change_dimension": "packet_change_dimension", + "set_player_game_type": "packet_set_player_game_type", + "player_list": "packet_player_list", + "simple_event": "packet_simple_event", + "event": "packet_event", + "spawn_experience_orb": "packet_spawn_experience_orb", + "clientbound_map_item_data_": "packet_clientbound_map_item_data_", + "map_info_request": "packet_map_info_request", + "request_chunk_radius": "packet_request_chunk_radius", + "chunk_radius_update": "packet_chunk_radius_update", + "item_frame_drop_item": "packet_item_frame_drop_item", + "replace_selected_item": "packet_replace_selected_item", + "game_rules_changed": "packet_game_rules_changed", + "camera": "packet_camera", + "add_item": "packet_add_item", + "boss_event": "packet_boss_event", + "show_credits": "packet_show_credits", + "available_commands": "packet_available_commands", + "command_step": "packet_command_step", + "command_block_update": "packet_command_block_update", + "update_trade": "packet_update_trade", + "update_equip": "packet_update_equip", + "resource_pack_data_info": "packet_resource_pack_data_info", + "resource_pack_chunk_data": "packet_resource_pack_chunk_data", + "resource_pack_chunk_request": "packet_resource_pack_chunk_request", + "transfer": "packet_transfer", + "play_sound": "packet_play_sound", + "stop_sound": "packet_stop_sound", + "set_title": "packet_set_title", + "add_behavior_tree_packet": "packet_add_behavior_tree_packet", + "structure_block_update_packet": "packet_structure_block_update_packet" + } + } + ] + } + ] + ], + "packet_game_login": [ + "container", + [ + { + "name": "protocol", + "type": "i32" + }, + { + "name": "edition", + "type": "i8" + }, + { + "name": "body", + "type": [ + "buffer", + { + "countType": "varint" + } + ] + } + ] + ], + "packet_play_status": [ + "container", + [ + { + "name": "status", + "type": "i32" + } + ] + ], + "packet_server_to_client_handshake": [ + "container", + [ + { + "name": "server_public_key", + "type": "string" + }, + { + "name": "token_length", + "type": "u32" + }, + { + "name": "token", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] + } + ] + ], + "packet_client_to_server_handshake": [ + "container", + [] + ], + "packet_disconnect": [ + "container", + [ + { + "name": "hide_disconnect_reason", + "type": "bool" + }, + { + "name": "message", + "type": "string" + } + ] + ], + "packet_resource_packs_info": [ + "container", + [ + { + "name": "must_accept", + "type": "bool" + }, + { + "name": "behahaviorpackinfos", + "type": "varint" + }, + { + "name": "resourcepackinfos", + "type": "varint" + } + ] + ], + "packet_resource_pack_stack": [ + "container", + [ + { + "name": "must_accept", + "type": "bool" + }, + { + "name": "behaviorpackidversions", + "type": "varint" + }, + { + "name": "resourcepackidversions", + "type": "varint" + } + ] + ], + "packet_resource_pack_client_response": [ + "container", + [ + { + "name": "response_status", + "type": "u8" + }, + { + "name": "resourcepackids", + "type": "resourcepackids" + } + ] + ], + "packet_text": [ + "container", + [ + { + "name": "type", + "type": "i8" + }, + { + "name": "source", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "1": "string", + "3": "string" + }, + "default": "void" + } + ] + }, + { + "name": "message", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "0": "string", + "1": "string", + "2": "string", + "3": "string", + "4": "string", + "5": "string" + }, + "default": "void" + } + ] + } + ] + ], + "packet_set_time": [ + "container", + [ + { + "name": "time", + "type": "varint" + } + ] + ], + "packet_start_game": [ + "container", + [ + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "player_gamemode", + "type": "varint" + }, + { + "name": "spawn", + "type": "vector3" + }, + { + "name": "unknown_1", + "type": "vector2" + }, + { + "name": "seed", + "type": "varint" + }, + { + "name": "dimension", + "type": "varint" + }, + { + "name": "generator", + "type": "varint" + }, + { + "name": "gamemode", + "type": "varint" + }, + { + "name": "difficulty", + "type": "varint" + }, + { + "name": "x", + "type": "varint" + }, + { + "name": "y", + "type": "varint" + }, + { + "name": "z", + "type": "varint" + }, + { + "name": "has_achievements_disabled", + "type": "bool" + }, + { + "name": "day_cycle_stop_time", + "type": "varint" + }, + { + "name": "edu_mode", + "type": "bool" + }, + { + "name": "rain_level", + "type": "lf32" + }, + { + "name": "lightnig_level", + "type": "lf32" + }, + { + "name": "enable_commands", + "type": "bool" + }, + { + "name": "is_texturepacks_required", + "type": "bool" + }, + { + "name": "gamerules", + "type": "gamerules" + }, + { + "name": "level_id", + "type": "string" + }, + { + "name": "world_name", + "type": "string" + }, + { + "name": "premium_world_template_id", + "type": "string" + }, + { + "name": "unknown0", + "type": "bool" + }, + { + "name": "current_tick", + "type": "i64" + } + ] + ], + "packet_add_player": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "username", + "type": "string" + }, + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "speed_x", + "type": "lf32" + }, + { + "name": "speed_y", + "type": "lf32" + }, + { + "name": "speed_z", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "head_yaw", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "item", + "type": "varint" + }, + { + "name": "metadata", + "type": "varint" + } + ] + ], + "packet_add_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "entity_type", + "type": "varint" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "speed_x", + "type": "lf32" + }, + { + "name": "speed_y", + "type": "lf32" + }, + { + "name": "speed_z", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "attributes", + "type": "varint" + }, + { + "name": "metadata", + "type": "varint" + }, + { + "name": "links", + "type": "links" + } + ] + ], + "packet_remove_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "varint" + } + ] + ], + "packet_add_item_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "item", + "type": "varint" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "speed_x", + "type": "lf32" + }, + { + "name": "speed_y", + "type": "lf32" + }, + { + "name": "speed_z", + "type": "lf32" + }, + { + "name": "metadata", + "type": "varint" + } + ] + ], + "packet_add_hanging_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "unknown", + "type": "varint" + } + ] + ], + "packet_take_item_entity": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "target", + "type": "varint" + } + ] + ], + "packet_move_entity": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "position", + "type": "playerlocation" + }, + { + "name": "on_ground", + "type": "bool" + }, + { + "name": "teleport", + "type": "bool" + } + ] + ], + "packet_move_player": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "head_yaw", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "mode", + "type": "u8" + }, + { + "name": "on_ground", + "type": "bool" + }, + { + "name": "other_runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_rider_jump": [ + "container", + [ + { + "name": "unknown", + "type": "varint" + } + ] + ], + "packet_remove_block": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + } + ] + ], + "packet_update_block": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "block_id", + "type": "varint" + }, + { + "name": "block_meta_and_priority", + "type": "varint" + } + ] + ], + "packet_add_painting": [ + "container", + [ + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "direction", + "type": "varint" + }, + { + "name": "title", + "type": "string" + } + ] + ], + "packet_explode": [ + "container", + [ + { + "name": "position", + "type": "vector3" + }, + { + "name": "radius", + "type": "varint" + }, + { + "name": "records", + "type": "varint" + } + ] + ], + "packet_level_sound_event": [ + "container", + [ + { + "name": "sound_id", + "type": "u8" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "extra_data", + "type": "varint" + }, + { + "name": "pitch", + "type": "varint" + }, + { + "name": "unknown1", + "type": "bool" + }, + { + "name": "disable_relative_volume", + "type": "bool" + } + ] + ], + "packet_level_event": [ + "container", + [ + { + "name": "event_id", + "type": "varint" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "data", + "type": "varint" + } + ] + ], + "packet_block_event": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "case_1", + "type": "varint" + }, + { + "name": "case_2", + "type": "varint" + } + ] + ], + "packet_entity_event": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "event_id", + "type": "u8" + }, + { + "name": "unknown", + "type": "varint" + } + ] + ], + "packet_mob_effect": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "event_id", + "type": "u8" + }, + { + "name": "effect_id", + "type": "varint" + }, + { + "name": "amplifier", + "type": "varint" + }, + { + "name": "particles", + "type": "bool" + }, + { + "name": "duration", + "type": "varint" + } + ] + ], + "packet_update_attributes": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "attributes", + "type": "varint" + } + ] + ], + "packet_mob_equipment": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "item", + "type": "varint" + }, + { + "name": "slot", + "type": "u8" + }, + { + "name": "selected_slot", + "type": "u8" + }, + { + "name": "unknown", + "type": "u8" + } + ] + ], + "packet_mob_armor_equipment": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "helmet", + "type": "varint" + }, + { + "name": "chestplate", + "type": "varint" + }, + { + "name": "leggings", + "type": "varint" + }, + { + "name": "boots", + "type": "varint" + } + ] + ], + "packet_interact": [ + "container", + [ + { + "name": "action_id", + "type": "u8" + }, + { + "name": "target_runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_block_pick_request": [ + "container", + [ + { + "name": "x", + "type": "varint" + }, + { + "name": "y", + "type": "varint" + }, + { + "name": "z", + "type": "varint" + }, + { + "name": "selected_slot", + "type": "u8" + } + ] + ], + "packet_use_item": [ + "container", + [ + { + "name": "blockcoordinates", + "type": "varint" + }, + { + "name": "block_id", + "type": "varint" + }, + { + "name": "face", + "type": "varint" + }, + { + "name": "facecoordinates", + "type": "vector3" + }, + { + "name": "playerposition", + "type": "vector3" + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "item", + "type": "varint" + } + ] + ], + "packet_player_action": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "action_id", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "face", + "type": "varint" + } + ] + ], + "packet_entity_fall": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "fall_distance", + "type": "lf32" + }, + { + "name": "unknown", + "type": "bool" + } + ] + ], + "packet_hurt_armor": [ + "container", + [ + { + "name": "health", + "type": "varint" + } + ] + ], + "packet_set_entity_data": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "metadata", + "type": "varint" + } + ] + ], + "packet_set_entity_motion": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "velocity", + "type": "vector3" + } + ] + ], + "packet_set_entity_link": [ + "container", + [ + { + "name": "rider_id", + "type": "varint" + }, + { + "name": "ridden_id", + "type": "varint" + }, + { + "name": "link_type", + "type": "u8" + } + ] + ], + "packet_set_health": [ + "container", + [ + { + "name": "health", + "type": "varint" + } + ] + ], + "packet_set_spawn_position": [ + "container", + [ + { + "name": "spawn_type", + "type": "varint" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "forced", + "type": "bool" + } + ] + ], + "packet_animate": [ + "container", + [ + { + "name": "action_id", + "type": "varint" + }, + { + "name": "runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_respawn": [ + "container", + [ + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + } + ] + ], + "packet_drop_item": [ + "container", + [ + { + "name": "itemtype", + "type": "u8" + }, + { + "name": "item", + "type": "varint" + } + ] + ], + "packet_inventory_action": [ + "container", + [ + { + "name": "action_id", + "type": "varint" + }, + { + "name": "item", + "type": "varint" + }, + { + "name": "enchantment_id", + "type": "varint" + }, + { + "name": "enchantment_level", + "type": "varint" + } + ] + ], + "packet_container_open": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "type", + "type": "u8" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "unknown_runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_container_close": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + } + ] + ], + "packet_container_set_slot": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "hotbarslot", + "type": "varint" + }, + { + "name": "item", + "type": "varint" + }, + { + "name": "selected_slot", + "type": "u8" + } + ] + ], + "packet_container_set_data": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "property", + "type": "varint" + }, + { + "name": "value", + "type": "varint" + } + ] + ], + "packet_container_set_content": [ + "container", + [ + { + "name": "window_id", + "type": "varint" + }, + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "slot_data", + "type": "varint" + }, + { + "name": "hotbar_data", + "type": "varint" + } + ] + ], + "packet_crafting_data": [ + "container", + [ + { + "name": "recipes", + "type": "varint" + } + ] + ], + "packet_crafting_event": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "recipe_type", + "type": "varint" + }, + { + "name": "recipe_id", + "type": "string" + }, + { + "name": "input", + "type": "varint" + }, + { + "name": "result", + "type": "varint" + } + ] + ], + "packet_adventure_settings": [ + "container", + [ + { + "name": "flags", + "type": "varint" + }, + { + "name": "user_permission", + "type": "varint" + } + ] + ], + "packet_block_entity_data": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "namedtag", + "type": "varint" + } + ] + ], + "packet_player_input": [ + "container", + [ + { + "name": "motion_x", + "type": "lf32" + }, + { + "name": "motion_z", + "type": "lf32" + }, + { + "name": "flag1", + "type": "bool" + }, + { + "name": "flag2", + "type": "bool" + } + ] + ], + "packet_full_chunk_data": [ + "container", + [ + { + "name": "chunk_x", + "type": "varint" + }, + { + "name": "chunk_z", + "type": "varint" + }, + { + "name": "chunk_data", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] + } + ] + ], + "packet_set_commands_enabled": [ + "container", + [ + { + "name": "enabled", + "type": "bool" + } + ] + ], + "packet_set_difficulty": [ + "container", + [ + { + "name": "difficulty", + "type": "varint" + } + ] + ], + "packet_change_dimension": [ + "container", + [ + { + "name": "dimension", + "type": "varint" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "unknown", + "type": "bool" + } + ] + ], + "packet_set_player_game_type": [ + "container", + [ + { + "name": "gamemode", + "type": "varint" + } + ] + ], + "packet_player_list": [ + "container", + [ + { + "name": "records", + "type": "varint" + } + ] + ], + "packet_simple_event": [ + "container", + [] + ], + "packet_event": [ + "container", + [] + ], + "packet_spawn_experience_orb": [ + "container", + [ + { + "name": "position", + "type": "vector3" + }, + { + "name": "count", + "type": "varint" + } + ] + ], + "packet_clientbound_map_item_data_": [ + "container", + [ + { + "name": "mapinfo", + "type": "varint" + } + ] + ], + "packet_map_info_request": [ + "container", + [ + { + "name": "map_id", + "type": "varint" + } + ] + ], + "packet_request_chunk_radius": [ + "container", + [ + { + "name": "chunk_radius", + "type": "varint" + } + ] + ], + "packet_chunk_radius_update": [ + "container", + [ + { + "name": "chunk_radius", + "type": "varint" + } + ] + ], + "packet_item_frame_drop_item": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + } + ] + ], + "packet_replace_selected_item": [ + "container", + [ + { + "name": "item", + "type": "varint" + } + ] + ], + "packet_game_rules_changed": [ + "container", + [ + { + "name": "rules", + "type": "gamerules" + } + ] + ], + "packet_camera": [ + "container", + [] + ], + "packet_add_item": [ + "container", + [ + { + "name": "item", + "type": "varint" + } + ] + ], + "packet_boss_event": [ + "container", + [ + { + "name": "boss_entity_id", + "type": "varint" + }, + { + "name": "event_type", + "type": "varint" + } + ] + ], + "packet_show_credits": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "status", + "type": "varint" + } + ] + ], + "packet_available_commands": [ + "container", + [ + { + "name": "commands", + "type": "string" + }, + { + "name": "unknown", + "type": "string" + } + ] + ], + "packet_command_step": [ + "container", + [ + { + "name": "command_name", + "type": "string" + }, + { + "name": "command_overload", + "type": "string" + }, + { + "name": "unknown_1", + "type": "varint" + }, + { + "name": "current_step_", + "type": "varint" + }, + { + "name": "is_output", + "type": "bool" + }, + { + "name": "client_id", + "type": "varint" + }, + { + "name": "command_input_json", + "type": "string" + }, + { + "name": "command_output_json", + "type": "string" + }, + { + "name": "unknown_7", + "type": "u8" + }, + { + "name": "unknown_8", + "type": "u8" + }, + { + "name": "entity_id_self", + "type": "varint" + } + ] + ], + "packet_command_block_update": [ + "container", + [] + ], + "packet_update_trade": [ + "container", + [] + ], + "packet_update_equip": [ + "container", + [] + ], + "packet_resource_pack_data_info": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "max_chunk_size_", + "type": "u32" + }, + { + "name": "chunk_count_", + "type": "u32" + }, + { + "name": "compressed_package_size_", + "type": "u64" + }, + { + "name": "hash_", + "type": "string" + } + ] + ], + "packet_resource_pack_chunk_data": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "chunk_index", + "type": "u32" + }, + { + "name": "progress", + "type": "u64" + }, + { + "name": "length", + "type": "u32" + }, + { + "name": "payload", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] + } + ] + ], + "packet_resource_pack_chunk_request": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "chunk_index", + "type": "u32" + } + ] + ], + "packet_transfer": [ + "container", + [ + { + "name": "server_address", + "type": "string" + }, + { + "name": "port", + "type": "ushort" + } + ] + ], + "packet_play_sound": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "volume", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + } + ] + ], + "packet_stop_sound": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "stop_all", + "type": "bool" + } + ] + ], + "packet_set_title": [ + "container", + [ + { + "name": "type", + "type": "varint" + }, + { + "name": "text", + "type": "string" + }, + { + "name": "fade_in_time", + "type": "varint" + }, + { + "name": "stay_time", + "type": "varint" + }, + { + "name": "fade_out_time", + "type": "varint" + } + ] + ], + "packet_add_behavior_tree_packet": [ + "container", + [] + ], + "packet_structure_block_update_packet": [ + "container", + [] + ] + } +} From 8d735acbf90ba96b88b7133a532b639809a1fa6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Fri, 23 Jun 2017 08:03:29 +0200 Subject: [PATCH 066/106] Read error for params.mcpe.name : 120 is not in the mappings value --- data/protocol.json | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index a0c118d..1128943 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -429,7 +429,7 @@ }, { "name": "resourcepackids", - "type": "resourcepackids" + "type": "varint" } ] ], @@ -1624,7 +1624,20 @@ ], "packet_event": [ "container", - [] + [ + { + "name": "entity_id_self", + "type": "varint" + }, + { + "name": "unk1", + "type": "varint" + }, + { + "name": "unk2", + "type": "u8" + } + ] ], "packet_spawn_experience_orb": [ "container", From bb13b9c719be333f13fef775e893e768c7b17e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Fri, 23 Jun 2017 19:56:52 +0200 Subject: [PATCH 067/106] Fix indention. --- src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 008d666..b02489a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ module.exports = { - createSerializer: require("./transforms/serializer").createSerializer, - createDeserializer: require("./transforms/serializer").createDeserializer, - createProtocol: require('./transforms/serializer').createProtocol, - createServer: require("./createServer"), - createClient: require("./createClient") + createSerializer: require("./transforms/serializer").createSerializer, + createDeserializer: require("./transforms/serializer").createDeserializer, + createProtocol: require('./transforms/serializer').createProtocol, + createServer: require("./createServer"), + createClient: require("./createClient") }; From 894f2c949e3c713e058534915c4493bd8432ee87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sat, 1 Jul 2017 02:12:50 +0200 Subject: [PATCH 068/106] Updated link to convertor. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54f647e..a3edda2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ pocket-minecraft-protocol [![NPM version](https://img.shields.io/npm/v/pocket-minecraft-protocol.svg)](http://npmjs.com/package/pocket-minecraft-protocol) [![Join the chat at https://gitter.im/mhsjlw/pocket-minecraft-protocol](https://badges.gitter.im/mhsjlw/pocket-minecraft-protocol.svg)](https://gitter.im/mhsjlw/pocket-minecraft-protocol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -Parse and serialize Minecraft PE packets (use [this](https://gist.github.com/filfat/eb6cd08e1e789b5924f7f733babc4a25) to generate the protocol data). +Parse and serialize Minecraft PE packets (use [this](https://github.com/filfat/MiNET-protocol-converter) to generate the protocol data). ## Features From 7038f7a0f0b697c5b7930828546bc151746e9d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 22 Apr 2018 18:47:47 +0200 Subject: [PATCH 069/106] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f73a761..90c1141 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lodash.merge": "^4.4.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.3", - "raknet": "git+https://github.com/filfat/node-raknet.git", + "raknet": "git+https://github.com/mhsjlw/node-raknet.git#master", "uuid-1345": "^0.99.6" }, "devDependencies": { From 9c4dec74ca81701aaa221a28664bc04069f145a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Fri, 12 Jul 2019 02:55:50 +0200 Subject: [PATCH 070/106] Update protocol.json --- data/protocol.json | 1234 +++++++++++++++++++++++++++++++++----------- 1 file changed, 935 insertions(+), 299 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index 1128943..ffb2876 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -45,7 +45,7 @@ "playerlocation": [ "array", { - "countType": "i16", + "countType": "li16", "type": [ "container", [ @@ -131,26 +131,25 @@ "0x0d": "add_entity", "0x0e": "remove_entity", "0x0f": "add_item_entity", - "0x10": "add_hanging_entity", "0x11": "take_item_entity", "0x12": "move_entity", "0x13": "move_player", "0x14": "rider_jump", - "0x15": "remove_block", - "0x16": "update_block", - "0x17": "add_painting", - "0x18": "explode", - "0x19": "level_sound_event", - "0x1a": "level_event", - "0x1b": "block_event", - "0x1c": "entity_event", - "0x1d": "mob_effect", - "0x1e": "update_attributes", + "0x15": "update_block", + "0x16": "add_painting", + "0x17": "explode", + "0x18": "level_sound_event_old", + "0x19": "level_event", + "0x1a": "block_event", + "0x1b": "entity_event", + "0x1c": "mob_effect", + "0x1d": "update_attributes", + "0x1e": "inventory_transaction", "0x1f": "mob_equipment", "0x20": "mob_armor_equipment", "0x21": "interact", "0x22": "block_pick_request", - "0x23": "use_item", + "0x23": "entity_pick_request", "0x24": "player_action", "0x25": "entity_fall", "0x26": "hurt_armor", @@ -161,15 +160,15 @@ "0x2b": "set_spawn_position", "0x2c": "animate", "0x2d": "respawn", - "0x2e": "drop_item", - "0x2f": "inventory_action", - "0x30": "container_open", - "0x31": "container_close", - "0x32": "container_set_slot", + "0x2e": "container_open", + "0x2f": "container_close", + "0x30": "player_hotbar", + "0x31": "inventory_content", + "0x32": "inventory_slot", "0x33": "container_set_data", - "0x34": "container_set_content", - "0x35": "crafting_data", - "0x36": "crafting_event", + "0x34": "crafting_data", + "0x35": "crafting_event", + "0x36": "gui_data_pick_item", "0x37": "adventure_settings", "0x38": "block_entity_data", "0x39": "player_input", @@ -180,33 +179,64 @@ "0x3e": "set_player_game_type", "0x3f": "player_list", "0x40": "simple_event", - "0x41": "event", + "0x41": "telemetry_event", "0x42": "spawn_experience_orb", "0x43": "clientbound_map_item_data_", "0x44": "map_info_request", "0x45": "request_chunk_radius", "0x46": "chunk_radius_update", "0x47": "item_frame_drop_item", - "0x48": "replace_selected_item", - "0x49": "game_rules_changed", - "0x4a": "camera", - "0x4b": "add_item", - "0x4c": "boss_event", - "0x4d": "show_credits", - "0x4e": "available_commands", - "0x4f": "command_step", - "0x50": "command_block_update", - "0x51": "update_trade", - "0x52": "update_equip", - "0x53": "resource_pack_data_info", - "0x54": "resource_pack_chunk_data", - "0x55": "resource_pack_chunk_request", - "0x56": "transfer", - "0x57": "play_sound", - "0x58": "stop_sound", - "0x59": "set_title", - "0x5a": "add_behavior_tree_packet", - "0x5b": "structure_block_update_packet" + "0x48": "game_rules_changed", + "0x49": "camera", + "0x4a": "boss_event", + "0x4b": "show_credits", + "0x4c": "available_commands", + "0x4d": "command_request", + "0x4e": "command_block_update", + "0x4f": "command_output", + "0x50": "update_trade", + "0x51": "update_equipment", + "0x52": "resource_pack_data_info", + "0x53": "resource_pack_chunk_data", + "0x54": "resource_pack_chunk_request", + "0x55": "transfer", + "0x56": "play_sound", + "0x57": "stop_sound", + "0x58": "set_title", + "0x59": "add_behavior_tree", + "0x5a": "structure_block_update", + "0x5b": "show_store_offer", + "0x5c": "purchase_receipt", + "0x5d": "player_skin", + "0x5e": "sub_client_login", + "0x5f": "initiate_web_socket_connection", + "0x60": "set_last_hurt_by", + "0x61": "book_edit", + "0x62": "npc_request", + "0x63": "photo_transfer", + "0x64": "modal_form_request", + "0x65": "modal_form_response", + "0x66": "server_settings_request", + "0x67": "server_settings_response", + "0x68": "show_profile", + "0x69": "set_default_game_type", + "0x6a": "remove_objective", + "0x6b": "set_display_objective", + "0x6c": "set_score", + "0x6d": "lab_table", + "0x6e": "update_block_synced", + "0x6f": "move_entity_delta", + "0x70": "set_scoreboard_identity_packet", + "0x71": "set_local_player_as_initialized_packet", + "0x72": "update_soft_enum_packet", + "0x73": "network_stack_latency_packet", + "0x75": "script_custom_event_packet", + "0x76": "spawn_particle_effect", + "0x77": "available_entity_identifiers", + "0x78": "level_sound_event_v2", + "0x79": "network_chunk_publisher_update", + "0x7a": "biome_definition_list", + "0x7b": "level_sound_event" } } ] @@ -233,26 +263,25 @@ "add_entity": "packet_add_entity", "remove_entity": "packet_remove_entity", "add_item_entity": "packet_add_item_entity", - "add_hanging_entity": "packet_add_hanging_entity", "take_item_entity": "packet_take_item_entity", "move_entity": "packet_move_entity", "move_player": "packet_move_player", "rider_jump": "packet_rider_jump", - "remove_block": "packet_remove_block", "update_block": "packet_update_block", "add_painting": "packet_add_painting", "explode": "packet_explode", - "level_sound_event": "packet_level_sound_event", + "level_sound_event_old": "packet_level_sound_event_old", "level_event": "packet_level_event", "block_event": "packet_block_event", "entity_event": "packet_entity_event", "mob_effect": "packet_mob_effect", "update_attributes": "packet_update_attributes", + "inventory_transaction": "packet_inventory_transaction", "mob_equipment": "packet_mob_equipment", "mob_armor_equipment": "packet_mob_armor_equipment", "interact": "packet_interact", "block_pick_request": "packet_block_pick_request", - "use_item": "packet_use_item", + "entity_pick_request": "packet_entity_pick_request", "player_action": "packet_player_action", "entity_fall": "packet_entity_fall", "hurt_armor": "packet_hurt_armor", @@ -263,15 +292,15 @@ "set_spawn_position": "packet_set_spawn_position", "animate": "packet_animate", "respawn": "packet_respawn", - "drop_item": "packet_drop_item", - "inventory_action": "packet_inventory_action", "container_open": "packet_container_open", "container_close": "packet_container_close", - "container_set_slot": "packet_container_set_slot", + "player_hotbar": "packet_player_hotbar", + "inventory_content": "packet_inventory_content", + "inventory_slot": "packet_inventory_slot", "container_set_data": "packet_container_set_data", - "container_set_content": "packet_container_set_content", "crafting_data": "packet_crafting_data", "crafting_event": "packet_crafting_event", + "gui_data_pick_item": "packet_gui_data_pick_item", "adventure_settings": "packet_adventure_settings", "block_entity_data": "packet_block_entity_data", "player_input": "packet_player_input", @@ -282,24 +311,23 @@ "set_player_game_type": "packet_set_player_game_type", "player_list": "packet_player_list", "simple_event": "packet_simple_event", - "event": "packet_event", + "telemetry_event": "packet_telemetry_event", "spawn_experience_orb": "packet_spawn_experience_orb", "clientbound_map_item_data_": "packet_clientbound_map_item_data_", "map_info_request": "packet_map_info_request", "request_chunk_radius": "packet_request_chunk_radius", "chunk_radius_update": "packet_chunk_radius_update", "item_frame_drop_item": "packet_item_frame_drop_item", - "replace_selected_item": "packet_replace_selected_item", "game_rules_changed": "packet_game_rules_changed", "camera": "packet_camera", - "add_item": "packet_add_item", "boss_event": "packet_boss_event", "show_credits": "packet_show_credits", "available_commands": "packet_available_commands", - "command_step": "packet_command_step", + "command_request": "packet_command_request", "command_block_update": "packet_command_block_update", + "command_output": "packet_command_output", "update_trade": "packet_update_trade", - "update_equip": "packet_update_equip", + "update_equipment": "packet_update_equipment", "resource_pack_data_info": "packet_resource_pack_data_info", "resource_pack_chunk_data": "packet_resource_pack_chunk_data", "resource_pack_chunk_request": "packet_resource_pack_chunk_request", @@ -307,8 +335,40 @@ "play_sound": "packet_play_sound", "stop_sound": "packet_stop_sound", "set_title": "packet_set_title", - "add_behavior_tree_packet": "packet_add_behavior_tree_packet", - "structure_block_update_packet": "packet_structure_block_update_packet" + "add_behavior_tree": "packet_add_behavior_tree", + "structure_block_update": "packet_structure_block_update", + "show_store_offer": "packet_show_store_offer", + "purchase_receipt": "packet_purchase_receipt", + "player_skin": "packet_player_skin", + "sub_client_login": "packet_sub_client_login", + "initiate_web_socket_connection": "packet_initiate_web_socket_connection", + "set_last_hurt_by": "packet_set_last_hurt_by", + "book_edit": "packet_book_edit", + "npc_request": "packet_npc_request", + "photo_transfer": "packet_photo_transfer", + "modal_form_request": "packet_modal_form_request", + "modal_form_response": "packet_modal_form_response", + "server_settings_request": "packet_server_settings_request", + "server_settings_response": "packet_server_settings_response", + "show_profile": "packet_show_profile", + "set_default_game_type": "packet_set_default_game_type", + "remove_objective": "packet_remove_objective", + "set_display_objective": "packet_set_display_objective", + "set_score": "packet_set_score", + "lab_table": "packet_lab_table", + "update_block_synced": "packet_update_block_synced", + "move_entity_delta": "packet_move_entity_delta", + "set_scoreboard_identity_packet": "packet_set_scoreboard_identity_packet", + "set_local_player_as_initialized_packet": "packet_set_local_player_as_initialized_packet", + "update_soft_enum_packet": "packet_update_soft_enum_packet", + "network_stack_latency_packet": "packet_network_stack_latency_packet", + "script_custom_event_packet": "packet_script_custom_event_packet", + "spawn_particle_effect": "packet_spawn_particle_effect", + "available_entity_identifiers": "packet_available_entity_identifiers", + "level_sound_event_v2": "packet_level_sound_event_v2", + "network_chunk_publisher_update": "packet_network_chunk_publisher_update", + "biome_definition_list": "packet_biome_definition_list", + "level_sound_event": "packet_level_sound_event" } } ] @@ -349,23 +409,9 @@ "packet_server_to_client_handshake": [ "container", [ - { - "name": "server_public_key", - "type": "string" - }, - { - "name": "token_length", - "type": "u32" - }, { "name": "token", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] + "type": "string" } ] ], @@ -393,6 +439,10 @@ "name": "must_accept", "type": "bool" }, + { + "name": "has_scripts", + "type": "bool" + }, { "name": "behahaviorpackinfos", "type": "varint" @@ -417,6 +467,10 @@ { "name": "resourcepackidversions", "type": "varint" + }, + { + "name": "is_experimental", + "type": "bool" } ] ], @@ -550,14 +604,38 @@ "name": "edu_mode", "type": "bool" }, + { + "name": "has_edu_features_enabled", + "type": "bool" + }, { "name": "rain_level", "type": "lf32" }, { - "name": "lightnig_level", + "name": "lightning_level", "type": "lf32" }, + { + "name": "has_confirmed_platform_locked_content", + "type": "bool" + }, + { + "name": "is_multiplayer", + "type": "bool" + }, + { + "name": "broadcast_to_lan", + "type": "bool" + }, + { + "name": "xbox_live_broadcast_mode", + "type": "varint" + }, + { + "name": "platform_broadcast_mode", + "type": "varint" + }, { "name": "enable_commands", "type": "bool" @@ -570,6 +648,46 @@ "name": "gamerules", "type": "gamerules" }, + { + "name": "bonus_chest", + "type": "bool" + }, + { + "name": "map_enabled", + "type": "bool" + }, + { + "name": "permission_level", + "type": "varint" + }, + { + "name": "server_chunk_tick_range", + "type": "i32" + }, + { + "name": "has_locked_behavior_pack", + "type": "bool" + }, + { + "name": "has_locked_resource_pack", + "type": "bool" + }, + { + "name": "is_from_locked_world_template", + "type": "bool" + }, + { + "name": "use_msa_gamertags_only", + "type": "bool" + }, + { + "name": "is_from_world_template", + "type": "bool" + }, + { + "name": "is_world_template_option_locked", + "type": "bool" + }, { "name": "level_id", "type": "string" @@ -583,12 +701,28 @@ "type": "string" }, { - "name": "unknown0", + "name": "is_trial", "type": "bool" }, { "name": "current_tick", "type": "i64" + }, + { + "name": "enchantment_seed", + "type": "varint" + }, + { + "name": "blockstates", + "type": "blockstates" + }, + { + "name": "multiplayer_correlation_id", + "type": "string" + }, + { + "name": "unknown2", + "type": "u8" } ] ], @@ -611,6 +745,10 @@ "name": "runtime_entity_id", "type": "varint" }, + { + "name": "platform_chat_id", + "type": "string" + }, { "name": "x", "type": "lf32" @@ -640,11 +778,11 @@ "type": "lf32" }, { - "name": "head_yaw", + "name": "yaw", "type": "lf32" }, { - "name": "yaw", + "name": "head_yaw", "type": "lf32" }, { @@ -654,6 +792,38 @@ { "name": "metadata", "type": "varint" + }, + { + "name": "flags", + "type": "varint" + }, + { + "name": "command_permission", + "type": "varint" + }, + { + "name": "action_permissions", + "type": "varint" + }, + { + "name": "permission_level", + "type": "varint" + }, + { + "name": "custom_stored_permissions", + "type": "varint" + }, + { + "name": "user_id", + "type": "i64" + }, + { + "name": "links", + "type": "links" + }, + { + "name": "device_id", + "type": "string" } ] ], @@ -670,7 +840,7 @@ }, { "name": "entity_type", - "type": "varint" + "type": "string" }, { "name": "x", @@ -704,6 +874,10 @@ "name": "yaw", "type": "lf32" }, + { + "name": "head_yaw", + "type": "lf32" + }, { "name": "attributes", "type": "varint" @@ -769,27 +943,10 @@ { "name": "metadata", "type": "varint" - } - ] - ], - "packet_add_hanging_entity": [ - "container", - [ - { - "name": "entity_id_self", - "type": "varint" }, { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "coordinates", - "type": "varint" - }, - { - "name": "unknown", - "type": "varint" + "name": "is_from_fishing", + "type": "bool" } ] ], @@ -813,17 +970,13 @@ "name": "runtime_entity_id", "type": "varint" }, + { + "name": "flags", + "type": "u8" + }, { "name": "position", "type": "playerlocation" - }, - { - "name": "on_ground", - "type": "bool" - }, - { - "name": "teleport", - "type": "bool" } ] ], @@ -851,11 +1004,11 @@ "type": "lf32" }, { - "name": "head_yaw", + "name": "yaw", "type": "lf32" }, { - "name": "yaw", + "name": "head_yaw", "type": "lf32" }, { @@ -881,15 +1034,6 @@ } ] ], - "packet_remove_block": [ - "container", - [ - { - "name": "coordinates", - "type": "varint" - } - ] - ], "packet_update_block": [ "container", [ @@ -898,11 +1042,15 @@ "type": "varint" }, { - "name": "block_id", + "name": "block_runtime_id", "type": "varint" }, { - "name": "block_meta_and_priority", + "name": "block_priority", + "type": "varint" + }, + { + "name": "storage", "type": "varint" } ] @@ -949,7 +1097,7 @@ } ] ], - "packet_level_sound_event": [ + "packet_level_sound_event_old": [ "container", [ { @@ -961,19 +1109,19 @@ "type": "vector3" }, { - "name": "extra_data", + "name": "block_id", "type": "varint" }, { - "name": "pitch", + "name": "entity_type", "type": "varint" }, { - "name": "unknown1", + "name": "is_baby_mob", "type": "bool" }, { - "name": "disable_relative_volume", + "name": "is_global", "type": "bool" } ] @@ -1024,7 +1172,7 @@ "type": "u8" }, { - "name": "unknown", + "name": "data", "type": "varint" } ] @@ -1071,6 +1219,15 @@ } ] ], + "packet_inventory_transaction": [ + "container", + [ + { + "name": "transaction", + "type": "transaction" + } + ] + ], "packet_mob_equipment": [ "container", [ @@ -1091,7 +1248,7 @@ "type": "u8" }, { - "name": "unknown", + "name": "windows_id", "type": "u8" } ] @@ -1149,42 +1306,26 @@ "name": "z", "type": "varint" }, + { + "name": "add_user_data", + "type": "bool" + }, { "name": "selected_slot", "type": "u8" } ] ], - "packet_use_item": [ + "packet_entity_pick_request": [ "container", [ { - "name": "blockcoordinates", - "type": "varint" + "name": "runtime_entity_id", + "type": "u64" }, { - "name": "block_id", - "type": "varint" - }, - { - "name": "face", - "type": "varint" - }, - { - "name": "facecoordinates", - "type": "vector3" - }, - { - "name": "playerposition", - "type": "vector3" - }, - { - "name": "slot", - "type": "varint" - }, - { - "name": "item", - "type": "varint" + "name": "selected_slot", + "type": "u8" } ] ], @@ -1221,7 +1362,7 @@ "type": "lf32" }, { - "name": "unknown", + "name": "is_in_void", "type": "bool" } ] @@ -1264,17 +1405,21 @@ "packet_set_entity_link": [ "container", [ - { - "name": "rider_id", - "type": "varint" - }, { "name": "ridden_id", "type": "varint" }, + { + "name": "rider_id", + "type": "varint" + }, { "name": "link_type", "type": "u8" + }, + { + "name": "unknown", + "type": "u8" } ] ], @@ -1334,40 +1479,6 @@ } ] ], - "packet_drop_item": [ - "container", - [ - { - "name": "itemtype", - "type": "u8" - }, - { - "name": "item", - "type": "varint" - } - ] - ], - "packet_inventory_action": [ - "container", - [ - { - "name": "action_id", - "type": "varint" - }, - { - "name": "item", - "type": "varint" - }, - { - "name": "enchantment_id", - "type": "varint" - }, - { - "name": "enchantment_level", - "type": "varint" - } - ] - ], "packet_container_open": [ "container", [ @@ -1384,7 +1495,7 @@ "type": "varint" }, { - "name": "unknown_runtime_entity_id", + "name": "runtime_entity_id", "type": "varint" } ] @@ -1398,28 +1509,50 @@ } ] ], - "packet_container_set_slot": [ + "packet_player_hotbar": [ "container", [ + { + "name": "selected_slot", + "type": "varint" + }, { "name": "window_id", "type": "u8" }, + { + "name": "select_slot_", + "type": "bool" + } + ] + ], + "packet_inventory_content": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + }, + { + "name": "input", + "type": "varint" + } + ] + ], + "packet_inventory_slot": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + }, { "name": "slot", "type": "varint" }, - { - "name": "hotbarslot", - "type": "varint" - }, { "name": "item", "type": "varint" - }, - { - "name": "selected_slot", - "type": "u8" } ] ], @@ -1440,27 +1573,6 @@ } ] ], - "packet_container_set_content": [ - "container", - [ - { - "name": "window_id", - "type": "varint" - }, - { - "name": "entity_id_self", - "type": "varint" - }, - { - "name": "slot_data", - "type": "varint" - }, - { - "name": "hotbar_data", - "type": "varint" - } - ] - ], "packet_crafting_data": [ "container", [ @@ -1495,6 +1607,10 @@ } ] ], + "packet_gui_data_pick_item": [ + "container", + [] + ], "packet_adventure_settings": [ "container", [ @@ -1503,8 +1619,24 @@ "type": "varint" }, { - "name": "user_permission", + "name": "command_permission", "type": "varint" + }, + { + "name": "action_permissions", + "type": "varint" + }, + { + "name": "permission_level", + "type": "varint" + }, + { + "name": "custom_stored_permissions", + "type": "varint" + }, + { + "name": "user_id", + "type": "i64" } ] ], @@ -1533,11 +1665,11 @@ "type": "lf32" }, { - "name": "flag1", + "name": "jumping", "type": "bool" }, { - "name": "flag2", + "name": "sneaking", "type": "bool" } ] @@ -1595,7 +1727,7 @@ "type": "vector3" }, { - "name": "unknown", + "name": "respawn", "type": "bool" } ] @@ -1620,9 +1752,14 @@ ], "packet_simple_event": [ "container", - [] + [ + { + "name": "event_type", + "type": "ushort" + } + ] ], - "packet_event": [ + "packet_telemetry_event": [ "container", [ { @@ -1697,15 +1834,6 @@ } ] ], - "packet_replace_selected_item": [ - "container", - [ - { - "name": "item", - "type": "varint" - } - ] - ], "packet_game_rules_changed": [ "container", [ @@ -1716,14 +1844,14 @@ ] ], "packet_camera": [ - "container", - [] - ], - "packet_add_item": [ "container", [ { - "name": "item", + "name": "unknown1", + "type": "varint" + }, + { + "name": "unknown2", "type": "varint" } ] @@ -1755,78 +1883,116 @@ ] ], "packet_available_commands": [ + "container", + [] + ], + "packet_command_request": [ "container", [ { - "name": "commands", + "name": "command", + "type": "string" + }, + { + "name": "command_type", + "type": "varint" + }, + { + "name": "unknown_uuid", + "type": "string" + }, + { + "name": "request_id", "type": "string" }, { "name": "unknown", - "type": "string" - } - ] - ], - "packet_command_step": [ - "container", - [ - { - "name": "command_name", - "type": "string" - }, - { - "name": "command_overload", - "type": "string" - }, - { - "name": "unknown_1", - "type": "varint" - }, - { - "name": "current_step_", - "type": "varint" - }, - { - "name": "is_output", "type": "bool" - }, - { - "name": "client_id", - "type": "varint" - }, - { - "name": "command_input_json", - "type": "string" - }, - { - "name": "command_output_json", - "type": "string" - }, - { - "name": "unknown_7", - "type": "u8" - }, - { - "name": "unknown_8", - "type": "u8" - }, - { - "name": "entity_id_self", - "type": "varint" } ] ], "packet_command_block_update": [ + "container", + [ + { + "name": "is_block", + "type": "bool" + } + ] + ], + "packet_command_output": [ "container", [] ], "packet_update_trade": [ "container", - [] + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "window_type", + "type": "u8" + }, + { + "name": "unknown0", + "type": "varint" + }, + { + "name": "unknown1", + "type": "varint" + }, + { + "name": "unknown2", + "type": "varint" + }, + { + "name": "is_willing", + "type": "bool" + }, + { + "name": "trader_entity_id", + "type": "varint" + }, + { + "name": "player_entity_id", + "type": "varint" + }, + { + "name": "display_name", + "type": "string" + }, + { + "name": "namedtag", + "type": "varint" + } + ] ], - "packet_update_equip": [ + "packet_update_equipment": [ "container", - [] + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "window_type", + "type": "u8" + }, + { + "name": "unknown", + "type": "u8" + }, + { + "name": "entity_id", + "type": "varint" + }, + { + "name": "namedtag", + "type": "varint" + } + ] ], "packet_resource_pack_data_info": [ "container", @@ -1836,20 +2002,26 @@ "type": "string" }, { - "name": "max_chunk_size_", + "name": "max_chunk_size", "type": "u32" }, { - "name": "chunk_count_", + "name": "chunk_count", "type": "u32" }, { - "name": "compressed_package_size_", + "name": "compressed_package_size", "type": "u64" }, { - "name": "hash_", - "type": "string" + "name": "hash", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] } ] ], @@ -1969,13 +2141,477 @@ } ] ], - "packet_add_behavior_tree_packet": [ + "packet_add_behavior_tree": [ + "container", + [ + { + "name": "behaviortree", + "type": "string" + } + ] + ], + "packet_structure_block_update": [ "container", [] ], - "packet_structure_block_update_packet": [ + "packet_show_store_offer": [ + "container", + [ + { + "name": "unknown0", + "type": "string" + }, + { + "name": "unknown1", + "type": "bool" + } + ] + ], + "packet_purchase_receipt": [ "container", [] + ], + "packet_player_skin": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "skin_id", + "type": "string" + }, + { + "name": "skin_name", + "type": "string" + }, + { + "name": "old_skin_name", + "type": "string" + }, + { + "name": "skin_data", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] + }, + { + "name": "cape_data", + "type": [ + "buffer", + { + "countType": "varint", + "type": "i8" + } + ] + }, + { + "name": "geometry_model", + "type": "string" + }, + { + "name": "geometry_data", + "type": "string" + } + ] + ], + "packet_sub_client_login": [ + "container", + [] + ], + "packet_initiate_web_socket_connection": [ + "container", + [ + { + "name": "server", + "type": "string" + } + ] + ], + "packet_set_last_hurt_by": [ + "container", + [ + { + "name": "unknown", + "type": "varint" + } + ] + ], + "packet_book_edit": [ + "container", + [] + ], + "packet_npc_request": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "unknown0", + "type": "u8" + }, + { + "name": "unknown1", + "type": "string" + }, + { + "name": "unknown2", + "type": "u8" + } + ] + ], + "packet_photo_transfer": [ + "container", + [ + { + "name": "file_name", + "type": "string" + }, + { + "name": "image_data", + "type": "string" + }, + { + "name": "unknown2", + "type": "string" + } + ] + ], + "packet_modal_form_request": [ + "container", + [ + { + "name": "form_id", + "type": "varint" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "packet_modal_form_response": [ + "container", + [ + { + "name": "form_id", + "type": "varint" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "packet_server_settings_request": [ + "container", + [] + ], + "packet_server_settings_response": [ + "container", + [ + { + "name": "form_id", + "type": "varint" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "packet_show_profile": [ + "container", + [ + { + "name": "xuid", + "type": "string" + } + ] + ], + "packet_set_default_game_type": [ + "container", + [ + { + "name": "gamemode", + "type": "varint" + } + ] + ], + "packet_remove_objective": [ + "container", + [ + { + "name": "objective_name", + "type": "string" + } + ] + ], + "packet_set_display_objective": [ + "container", + [ + { + "name": "display_slot", + "type": "string" + }, + { + "name": "objective_name", + "type": "string" + }, + { + "name": "display_name", + "type": "string" + }, + { + "name": "criteria_name", + "type": "string" + }, + { + "name": "sort_order", + "type": "varint" + } + ] + ], + "packet_set_score": [ + "container", + [ + { + "name": "entries", + "type": "scoreentries" + } + ] + ], + "packet_lab_table": [ + "container", + [ + { + "name": "useless_byte", + "type": "u8" + }, + { + "name": "lab_table_x", + "type": "varint" + }, + { + "name": "lab_table_y", + "type": "varint" + }, + { + "name": "lab_table_z", + "type": "varint" + }, + { + "name": "reaction_type", + "type": "u8" + } + ] + ], + "packet_update_block_synced": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "block_runtime_id", + "type": "varint" + }, + { + "name": "block_priority", + "type": "varint" + }, + { + "name": "data_layer_id", + "type": "varint" + }, + { + "name": "unknown0", + "type": "varint" + }, + { + "name": "unknown1", + "type": "varint" + } + ] + ], + "packet_move_entity_delta": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "flags", + "type": "u8" + } + ] + ], + "packet_set_scoreboard_identity_packet": [ + "container", + [ + { + "name": "entries", + "type": "scoreboardidentityentries" + } + ] + ], + "packet_set_local_player_as_initialized_packet": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_update_soft_enum_packet": [ + "container", + [] + ], + "packet_network_stack_latency_packet": [ + "container", + [ + { + "name": "timestamp", + "type": "i64" + }, + { + "name": "need_response", + "type": "bool" + } + ] + ], + "packet_script_custom_event_packet": [ + "container", + [ + { + "name": "event_name", + "type": "string" + }, + { + "name": "event_data", + "type": "string" + } + ] + ], + "packet_spawn_particle_effect": [ + "container", + [ + { + "name": "dimension_id", + "type": "u8" + }, + { + "name": "entity_id", + "type": "varint" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "particle_name", + "type": "string" + } + ] + ], + "packet_available_entity_identifiers": [ + "container", + [ + { + "name": "namedtag", + "type": "varint" + } + ] + ], + "packet_level_sound_event_v2": [ + "container", + [ + { + "name": "sound_id", + "type": "u8" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "block_id", + "type": "varint" + }, + { + "name": "entity_type", + "type": "string" + }, + { + "name": "is_baby_mob", + "type": "bool" + }, + { + "name": "is_global", + "type": "bool" + } + ] + ], + "packet_network_chunk_publisher_update": [ + "container", + [ + { + "name": "coordinates", + "type": "varint" + }, + { + "name": "radius", + "type": "varint" + } + ] + ], + "packet_biome_definition_list": [ + "container", + [ + { + "name": "namedtag", + "type": "varint" + } + ] + ], + "packet_level_sound_event": [ + "container", + [ + { + "name": "sound_id", + "type": "varint" + }, + { + "name": "position", + "type": "vector3" + }, + { + "name": "block_id", + "type": "varint" + }, + { + "name": "entity_type", + "type": "string" + }, + { + "name": "is_baby_mob", + "type": "bool" + }, + { + "name": "is_global", + "type": "bool" + } + ] ] } } From b7e39dec84b883db348425a6e4f53028a0ac8b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 14 Jul 2019 17:21:20 +0200 Subject: [PATCH 071/106] Add babel for esnext support. --- .babelrc | 7 + .eslintrc | 41 ++ AUTHORS.md | 3 + HISTORY.md | 4 + index.js | 13 + package.json | 10 +- src/createClient.js | 36 +- src/createServer.js | 62 +- yarn.lock | 1393 +++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 1512 insertions(+), 57 deletions(-) create mode 100644 .babelrc create mode 100644 .eslintrc create mode 100644 AUTHORS.md create mode 100644 yarn.lock diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..f475336 --- /dev/null +++ b/.babelrc @@ -0,0 +1,7 @@ + +{ + "presets": [ + "@babel/preset-env", + "@babel/preset-typescript" + ] +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..bb70c93 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,41 @@ +{ + "parser": "babel-eslint", + + "extends": [ + "eslint:recommended" + ], + + "plugins": [ + "@typescript-eslint", + "import" + ], + + "env": { + "es6": true, + "browser": true, + "node": true, + "jasmine": true + }, + + "parserOptions": { + "ecmaFeatures": { + "jsx": true, + "modules": true + } + }, + + "rules": { + "consistent-return": 2, + "no-mixed-operators": 0, + "no-useless-constructor": 0, + "standard/computed-property-even-spacing": 0, + "import/first": 0, + "no-unused-vars": 2, + "no-console": 2, + + "indent": ["error", 4, {"SwitchCase": 1}], + "semi": ["error", "always"], + "brace-style": ["error", "1tbs", { "allowSingleLine": true }], + "radix": ["off"] + } +} diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 0000000..61487ad --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,3 @@ +mhsjlw @mhsjlw +Romain Beaumont @rom1504 +Filiph Sandström @filfat diff --git a/HISTORY.md b/HISTORY.md index 33fcd28..f8583b2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 2.4.0 +* Update to version 1.12.0 +* Add option to provide protocol.json + ## 2.2.3 * fix the use item packet diff --git a/index.js b/index.js index 220c3fa..b4287e3 100644 --- a/index.js +++ b/index.js @@ -1 +1,14 @@ +'use strict'; + +const path = require('path'); +const register = require('@babel/register').default; +register({ + extends: path.resolve(__dirname, '.babelrc'), + ignore: [/node_modules/], + extensions: [ + ".js", + ".ts" + ] +}); + module.exports = require('./src/index.js'); diff --git a/package.json b/package.json index 90c1141..41167fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pocket-minecraft-protocol", - "version": "2.3.0", + "version": "2.4.0", "description": "Parse and serialize Minecraft Pocket Edition packets", "main": "index.js", "scripts": { @@ -11,12 +11,12 @@ "pocket-edition", "protocol" ], - "author": "mhsjlw ", - "contributors": [ - "rom1504" - ], "license": "MIT", "dependencies": { + "@babel/core": "^7.5.4", + "@babel/preset-env": "^7.5.4", + "@babel/preset-typescript": "^7.3.3", + "@babel/register": "^7.4.4", "asn1": "^0.2.3", "bn.js": "^4.11.4", "jwt-simple": "^0.5.0", diff --git a/src/createClient.js b/src/createClient.js index 55d8f08..4e87d1c 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -5,9 +5,9 @@ const fs = require('fs'); const path = require('path'); const zlib = require('zlib'); const ProtoDef = require('protodef').ProtoDef; -const batchProto=new ProtoDef(); +const batchProto = new ProtoDef(); batchProto.addTypes(require("./datatypes/minecraft")); -batchProto.addType("insideBatch",["endOfArray",{"type":["buffer",{"countType":"i32"}]}]); +batchProto.addType("insideBatch", ["endOfArray", { "type": ["buffer", { "countType": "i32" }] }]); function createClient(options) { return null; //FIXME @@ -18,43 +18,43 @@ function createClient(options) { assert.ok(options.username, 'username is required'); - options.customPackets=require('../data/protocol'); - options.customTypes=require('./datatypes/minecraft'); + options.customPackets = require('../data/protocol'); + options.customTypes = require('./datatypes/minecraft'); - var client=raknet.createClient(options); + var client = raknet.createClient(options); client.username = options.username; - client.on('mcpe',packet => client.emit(packet.name,packet.params)) - client.writeMCPE=(name,packet) => { - client.writeEncapsulated('mcpe',{ - name:name, - params:packet + client.on('mcpe', packet => client.emit(packet.name, packet.params)) + client.writeMCPE = (name, packet) => { + client.writeEncapsulated('mcpe', { + name: name, + params: packet }); }; - client.on('login', function() { + client.on('login', function () { client.writeMCPE('game_login', { username: client.username, protocol: 70, protocol2: 70, - clientId: [ -1, -697896776 ], + clientId: [-1, -697896776], clientUuid: '86372ed8-d055-b23a-9171-5e3ac594d766', - serverAddress: client.host+":"+client.port, - clientSecret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g,''),'hex'), + serverAddress: client.host + ":" + client.port, + clientSecret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g, ''), 'hex'), skin: { skinType: 'Standard_Steve', - texture: fs.readFileSync(path.join(__dirname,'texture')) + texture: fs.readFileSync(path.join(__dirname, 'texture')) } } ); }); - client.on('batch', function(packet) { + client.on('batch', function (packet) { var buf = zlib.inflateSync(packet.payload); - var packets=batchProto.parsePacketBuffer("insideBatch",buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]),packet]))); + var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; + packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); }); return client; diff --git a/src/createServer.js b/src/createServer.js index 65c0a37..f83fb28 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -1,20 +1,11 @@ -'use strict'; -let raknet = require('raknet'), - zlib = require('zlib'), - ProtoDef = require('protodef').ProtoDef, - Parser = require('protodef').Parser, - Serializer = require('protodef').Serializer, - jwt = require('jwt-simple'); -var debug = require('debug')('raknet'); +import raknet from 'raknet'; +import zlib from 'zlib'; +import jwt from 'jwt-simple'; +import { ProtoDef, Parser, Serializer } from 'protodef'; + +let debug = require('debug')('raknet'); let batchProto = new ProtoDef(); -batchProto.addTypes(require('./datatypes/minecraft')); -batchProto.addType('insideBatch', ['endOfArray', { - 'type': ['buffer', { - 'countType': 'varint', - }] -}]); - const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; // createServer (object, boolean) @@ -24,33 +15,36 @@ const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7 // encryption: enable/disable encryption function createServer(options, encryption) { options = options || {}; - const port = options.port != null ? - options.port : - options['server-port'] != null ? - options['server-port'] : - 19132; + + const port = options.port || options['server-port'] || 19132; const host = options.host || '0.0.0.0'; - options.customPackets = require('../data/protocol'); - options.customTypes = require('./datatypes/minecraft'); - let server = raknet.createServer(options); + options.customPackets = (options.protocol ? options.protocol.packets : null) || require('../data/protocol'); + options.customTypes = (options.protocol ? options.protocol.types : null) || require('./datatypes/minecraft'); + batchProto.addTypes(options.customTypes); + batchProto.addType('insideBatch', ['endOfArray', { + 'type': ['buffer', { + 'countType': 'varint', + }] + }]); + + let server = raknet.createServer(options); server.name = options.name || 'Minecraft Server'; server.motd = options.motd || 'A Minecraft server'; //FIXME server.maxPlayers = options['max-players'] || 20; //FIXME server.playerCount = 0; //FIXME - - server.on('connection', function(client) { + server.on('connection', (client) => { client.receiveCounter = 0; client.sendCounter = 0; client.encryptionEnabled = encryption ? true : false; let proto = new ProtoDef(); - proto.addTypes(require('./datatypes/minecraft')); - proto.addTypes(require('../data/protocol').types); + proto.addTypes(options.customTypes); + proto.addTypes(options.customPackets.types); client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); - + client.on('mcpe', packet => { client.emit(packet.name, packet.params); client.emit('debug', packet.name); @@ -66,7 +60,7 @@ function createServer(options, encryption) { // // string: packet name // object: packet data - client.writeMCPE = function (name, params) { + client.writeMCPE = (name, params) => { if (client.encryptionEnabled) { client.mcpePacketSerializer.write({ name, params }); } else { @@ -79,7 +73,7 @@ function createServer(options, encryption) { // Send data to the client // // array: packets to send - client.writeBatch = function (packets) { + client.writeBatch = (packets) => { const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packet)))); @@ -94,12 +88,12 @@ function createServer(options, encryption) { // // string: packet name // object: packet data - client.writeAll = function (name, data) { + client.writeAll = (name, data) => { return; //TODO server._writeAll(name, data); }; - client.on('game_login', function (packet) { + client.on('game_login', (packet) => { try { let dataProto = new ProtoDef(); dataProto.addType('data_chain', ['container', [{ @@ -120,7 +114,7 @@ function createServer(options, encryption) { chain = null, decode = null, data = null; - + body.data.chain = JSON.parse(body.data.chain); chain = body.data.chain.chain[0]; @@ -136,7 +130,7 @@ function createServer(options, encryption) { skinId: data.SkinId }) } catch (err) { - console.log(err); + console.error(err); return null; } }); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..f81af3d --- /dev/null +++ b/yarn.lock @@ -0,0 +1,1393 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/code-frame@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" + integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== + dependencies: + "@babel/highlight" "^7.0.0" + +"@babel/core@^7.5.4": + version "7.5.4" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.5.4.tgz#4c32df7ad5a58e9ea27ad025c11276324e0b4ddd" + integrity sha512-+DaeBEpYq6b2+ZmHx3tHspC+ZRflrvLqwfv8E3hNr5LVQoyBnL8RPKSBCg+rK2W2My9PWlujBiqd0ZPsR9Q6zQ== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.5.0" + "@babel/helpers" "^7.5.4" + "@babel/parser" "^7.5.0" + "@babel/template" "^7.4.4" + "@babel/traverse" "^7.5.0" + "@babel/types" "^7.5.0" + convert-source-map "^1.1.0" + debug "^4.1.0" + json5 "^2.1.0" + lodash "^4.17.11" + resolve "^1.3.2" + semver "^5.4.1" + source-map "^0.5.0" + +"@babel/generator@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.5.0.tgz#f20e4b7a91750ee8b63656073d843d2a736dca4a" + integrity sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA== + dependencies: + "@babel/types" "^7.5.0" + jsesc "^2.5.1" + lodash "^4.17.11" + source-map "^0.5.0" + trim-right "^1.0.1" + +"@babel/helper-annotate-as-pure@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" + integrity sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.1.0.tgz#6b69628dfe4087798e0c4ed98e3d4a6b2fbd2f5f" + integrity sha512-qNSR4jrmJ8M1VMM9tibvyRAHXQs2PmaksQF7c1CGJNipfe3D8p+wgNwgso/P2A2r2mdgBWAXljNWR0QRZAMW8w== + dependencies: + "@babel/helper-explode-assignable-expression" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-call-delegate@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-call-delegate/-/helper-call-delegate-7.4.4.tgz#87c1f8ca19ad552a736a7a27b1c1fcf8b1ff1f43" + integrity sha512-l79boDFJ8S1c5hvQvG+rc+wHw6IuH7YldmRKsYtpbawsxURu/paVy57FZMomGK22/JckepaikOkY0MoAmdyOlQ== + dependencies: + "@babel/helper-hoist-variables" "^7.4.4" + "@babel/traverse" "^7.4.4" + "@babel/types" "^7.4.4" + +"@babel/helper-create-class-features-plugin@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.5.0.tgz#02edb97f512d44ba23b3227f1bf2ed43454edac5" + integrity sha512-EAoMc3hE5vE5LNhMqDOwB1usHvmRjCDAnH8CD4PVkX9/Yr3W/tcz8xE8QvdZxfsFBDICwZnF2UTHIqslRpvxmA== + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-member-expression-to-functions" "^7.0.0" + "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-replace-supers" "^7.4.4" + "@babel/helper-split-export-declaration" "^7.4.4" + +"@babel/helper-define-map@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.4.4.tgz#6969d1f570b46bdc900d1eba8e5d59c48ba2c12a" + integrity sha512-IX3Ln8gLhZpSuqHJSnTNBWGDE9kdkTEWl21A/K7PQ00tseBwbqCHTvNLHSBd9M0R5rER4h5Rsvj9vw0R5SieBg== + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/types" "^7.4.4" + lodash "^4.17.11" + +"@babel/helper-explode-assignable-expression@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.1.0.tgz#537fa13f6f1674df745b0c00ec8fe4e99681c8f6" + integrity sha512-NRQpfHrJ1msCHtKjbzs9YcMmJZOg6mQMmGRB+hbamEdG5PNpaSm95275VD92DvJKuyl0s2sFiDmMZ+EnnvufqA== + dependencies: + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-function-name@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" + integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== + dependencies: + "@babel/helper-get-function-arity" "^7.0.0" + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-get-function-arity@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" + integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-hoist-variables@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz#0298b5f25c8c09c53102d52ac4a98f773eb2850a" + integrity sha512-VYk2/H/BnYbZDDg39hr3t2kKyifAm1W6zHRfhx8jGjIHpQEBv9dry7oQ2f3+J703TLu69nYdxsovl0XYfcnK4w== + dependencies: + "@babel/types" "^7.4.4" + +"@babel/helper-member-expression-to-functions@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.0.0.tgz#8cd14b0a0df7ff00f009e7d7a436945f47c7a16f" + integrity sha512-avo+lm/QmZlv27Zsi0xEor2fKcqWG56D5ae9dzklpIaY7cQMK5N8VSpaNVPPagiqmy7LrEjK1IWdGMOqPu5csg== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-module-imports@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d" + integrity sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-module-transforms@^7.1.0", "@babel/helper-module-transforms@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.4.4.tgz#96115ea42a2f139e619e98ed46df6019b94414b8" + integrity sha512-3Z1yp8TVQf+B4ynN7WoHPKS8EkdTbgAEy0nU0rs/1Kw4pDgmvYH3rz3aI11KgxKCba2cn7N+tqzV1mY2HMN96w== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-simple-access" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.4.4" + "@babel/template" "^7.4.4" + "@babel/types" "^7.4.4" + lodash "^4.17.11" + +"@babel/helper-optimise-call-expression@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz#a2920c5702b073c15de51106200aa8cad20497d5" + integrity sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-plugin-utils@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" + integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA== + +"@babel/helper-regex@^7.0.0", "@babel/helper-regex@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.4.4.tgz#a47e02bc91fb259d2e6727c2a30013e3ac13c4a2" + integrity sha512-Y5nuB/kESmR3tKjU8Nkn1wMGEx1tjJX076HBMeL3XLQCu6vA/YRzuTW0bbb+qRnXvQGn+d6Rx953yffl8vEy7Q== + dependencies: + lodash "^4.17.11" + +"@babel/helper-remap-async-to-generator@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz#361d80821b6f38da75bd3f0785ece20a88c5fe7f" + integrity sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.0.0" + "@babel/helper-wrap-function" "^7.1.0" + "@babel/template" "^7.1.0" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-replace-supers@^7.1.0", "@babel/helper-replace-supers@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.4.4.tgz#aee41783ebe4f2d3ab3ae775e1cc6f1a90cefa27" + integrity sha512-04xGEnd+s01nY1l15EuMS1rfKktNF+1CkKmHoErDppjAAZL+IUBZpzT748x262HF7fibaQPhbvWUl5HeSt1EXg== + dependencies: + "@babel/helper-member-expression-to-functions" "^7.0.0" + "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/traverse" "^7.4.4" + "@babel/types" "^7.4.4" + +"@babel/helper-simple-access@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz#65eeb954c8c245beaa4e859da6188f39d71e585c" + integrity sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w== + dependencies: + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-split-export-declaration@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz#ff94894a340be78f53f06af038b205c49d993677" + integrity sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q== + dependencies: + "@babel/types" "^7.4.4" + +"@babel/helper-wrap-function@^7.1.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz#c4e0012445769e2815b55296ead43a958549f6fa" + integrity sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ== + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/template" "^7.1.0" + "@babel/traverse" "^7.1.0" + "@babel/types" "^7.2.0" + +"@babel/helpers@^7.5.4": + version "7.5.4" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.5.4.tgz#2f00608aa10d460bde0ccf665d6dcf8477357cf0" + integrity sha512-6LJ6xwUEJP51w0sIgKyfvFMJvIb9mWAfohJp0+m6eHJigkFdcH8duZ1sfhn0ltJRzwUIT/yqqhdSfRpCpL7oow== + dependencies: + "@babel/template" "^7.4.4" + "@babel/traverse" "^7.5.0" + "@babel/types" "^7.5.0" + +"@babel/highlight@^7.0.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540" + integrity sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ== + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^4.0.0" + +"@babel/parser@^7.4.4", "@babel/parser@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.5.0.tgz#3e0713dff89ad6ae37faec3b29dcfc5c979770b7" + integrity sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA== + +"@babel/plugin-proposal-async-generator-functions@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e" + integrity sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/plugin-syntax-async-generators" "^7.2.0" + +"@babel/plugin-proposal-dynamic-import@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz#e532202db4838723691b10a67b8ce509e397c506" + integrity sha512-x/iMjggsKTFHYC6g11PL7Qy58IK8H5zqfm9e6hu4z1iH2IRyAp9u9dL80zA6R76yFovETFLKz2VJIC2iIPBuFw== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-dynamic-import" "^7.2.0" + +"@babel/plugin-proposal-json-strings@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz#568ecc446c6148ae6b267f02551130891e29f317" + integrity sha512-MAFV1CA/YVmYwZG0fBQyXhmj0BHCB5egZHCKWIFVv/XCxAeVGIHfos3SwDck4LvCllENIAg7xMKOG5kH0dzyUg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-json-strings" "^7.2.0" + +"@babel/plugin-proposal-object-rest-spread@^7.5.4": + version "7.5.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.4.tgz#250de35d867ce8260a31b1fdac6c4fc1baa99331" + integrity sha512-KCx0z3y7y8ipZUMAEEJOyNi11lMb/FOPUjjB113tfowgw0c16EGYos7worCKBcUAh2oG+OBnoUhsnTSoLpV9uA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-object-rest-spread" "^7.2.0" + +"@babel/plugin-proposal-optional-catch-binding@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.2.0.tgz#135d81edb68a081e55e56ec48541ece8065c38f5" + integrity sha512-mgYj3jCcxug6KUcX4OBoOJz3CMrwRfQELPQ5560F70YQUBZB7uac9fqaWamKR1iWUzGiK2t0ygzjTScZnVz75g== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" + +"@babel/plugin-proposal-unicode-property-regex@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.4.tgz#501ffd9826c0b91da22690720722ac7cb1ca9c78" + integrity sha512-j1NwnOqMG9mFUOH58JTFsA/+ZYzQLUZ/drqWUqxCYLGeu2JFZL8YrNC9hBxKmWtAuOCHPcRpgv7fhap09Fb4kA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-regex" "^7.4.4" + regexpu-core "^4.5.4" + +"@babel/plugin-syntax-async-generators@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz#69e1f0db34c6f5a0cf7e2b3323bf159a76c8cb7f" + integrity sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-syntax-dynamic-import@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.2.0.tgz#69c159ffaf4998122161ad8ebc5e6d1f55df8612" + integrity sha512-mVxuJ0YroI/h/tbFTPGZR8cv6ai+STMKNBq0f8hFxsxWjl94qqhsb+wXbpNMDPU3cfR1TIsVFzU3nXyZMqyK4w== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-syntax-json-strings@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz#72bd13f6ffe1d25938129d2a186b11fd62951470" + integrity sha512-5UGYnMSLRE1dqqZwug+1LISpA403HzlSfsg6P9VXU6TBjcSHeNlw4DxDx7LgpF+iKZoOG/+uzqoRHTdcUpiZNg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-syntax-object-rest-spread@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz#3b7a3e733510c57e820b9142a6579ac8b0dfad2e" + integrity sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-syntax-optional-catch-binding@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz#a94013d6eda8908dfe6a477e7f9eda85656ecf5c" + integrity sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-syntax-typescript@^7.2.0": + version "7.3.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz#a7cc3f66119a9f7ebe2de5383cce193473d65991" + integrity sha512-dGwbSMA1YhVS8+31CnPR7LB4pcbrzcV99wQzby4uAfrkZPYZlQ7ImwdpzLqi6Z6IL02b8IAL379CaMwo0x5Lag== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-arrow-functions@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.2.0.tgz#9aeafbe4d6ffc6563bf8f8372091628f00779550" + integrity sha512-ER77Cax1+8/8jCB9fo4Ud161OZzWN5qawi4GusDuRLcDbDG+bIGYY20zb2dfAFdTRGzrfq2xZPvF0R64EHnimg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-async-to-generator@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.5.0.tgz#89a3848a0166623b5bc481164b5936ab947e887e" + integrity sha512-mqvkzwIGkq0bEF1zLRRiTdjfomZJDV33AH3oQzHVGkI2VzEmXLpKKOBvEVaFZBJdN0XTyH38s9j/Kiqr68dggg== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-remap-async-to-generator" "^7.1.0" + +"@babel/plugin-transform-block-scoped-functions@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.2.0.tgz#5d3cc11e8d5ddd752aa64c9148d0db6cb79fd190" + integrity sha512-ntQPR6q1/NKuphly49+QiQiTN0O63uOwjdD6dhIjSWBI5xlrbUFh720TIpzBhpnrLfv2tNH/BXvLIab1+BAI0w== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-block-scoping@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.4.4.tgz#c13279fabf6b916661531841a23c4b7dae29646d" + integrity sha512-jkTUyWZcTrwxu5DD4rWz6rDB5Cjdmgz6z7M7RLXOJyCUkFBawssDGcGh8M/0FTSB87avyJI1HsTwUXp9nKA1PA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + lodash "^4.17.11" + +"@babel/plugin-transform-classes@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.4.4.tgz#0ce4094cdafd709721076d3b9c38ad31ca715eb6" + integrity sha512-/e44eFLImEGIpL9qPxSRat13I5QNRgBLu2hOQJCF7VLy/otSM/sypV1+XaIw5+502RX/+6YaSAPmldk+nhHDPw== + dependencies: + "@babel/helper-annotate-as-pure" "^7.0.0" + "@babel/helper-define-map" "^7.4.4" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-replace-supers" "^7.4.4" + "@babel/helper-split-export-declaration" "^7.4.4" + globals "^11.1.0" + +"@babel/plugin-transform-computed-properties@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.2.0.tgz#83a7df6a658865b1c8f641d510c6f3af220216da" + integrity sha512-kP/drqTxY6Xt3NNpKiMomfgkNn4o7+vKxK2DDKcBG9sHj51vHqMBGy8wbDS/J4lMxnqs153/T3+DmCEAkC5cpA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-destructuring@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.5.0.tgz#f6c09fdfe3f94516ff074fe877db7bc9ef05855a" + integrity sha512-YbYgbd3TryYYLGyC7ZR+Tq8H/+bCmwoaxHfJHupom5ECstzbRLTch6gOQbhEY9Z4hiCNHEURgq06ykFv9JZ/QQ== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-dotall-regex@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.4.4.tgz#361a148bc951444312c69446d76ed1ea8e4450c3" + integrity sha512-P05YEhRc2h53lZDjRPk/OektxCVevFzZs2Gfjd545Wde3k+yFDbXORgl2e0xpbq8mLcKJ7Idss4fAg0zORN/zg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-regex" "^7.4.4" + regexpu-core "^4.5.4" + +"@babel/plugin-transform-duplicate-keys@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.5.0.tgz#c5dbf5106bf84cdf691222c0974c12b1df931853" + integrity sha512-igcziksHizyQPlX9gfSjHkE2wmoCH3evvD2qR5w29/Dk0SMKE/eOI7f1HhBdNhR/zxJDqrgpoDTq5YSLH/XMsQ== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-exponentiation-operator@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.2.0.tgz#a63868289e5b4007f7054d46491af51435766008" + integrity sha512-umh4hR6N7mu4Elq9GG8TOu9M0bakvlsREEC+ialrQN6ABS4oDQ69qJv1VtR3uxlKMCQMCvzk7vr17RHKcjx68A== + dependencies: + "@babel/helper-builder-binary-assignment-operator-visitor" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-for-of@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.4.4.tgz#0267fc735e24c808ba173866c6c4d1440fc3c556" + integrity sha512-9T/5Dlr14Z9TIEXLXkt8T1DU7F24cbhwhMNUziN3hB1AXoZcdzPcTiKGRn/6iOymDqtTKWnr/BtRKN9JwbKtdQ== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-function-name@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.4.4.tgz#e1436116abb0610c2259094848754ac5230922ad" + integrity sha512-iU9pv7U+2jC9ANQkKeNF6DrPy4GBa4NWQtl6dHB4Pb3izX2JOEvDTFarlNsBj/63ZEzNNIAMs3Qw4fNCcSOXJA== + dependencies: + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-literals@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.2.0.tgz#690353e81f9267dad4fd8cfd77eafa86aba53ea1" + integrity sha512-2ThDhm4lI4oV7fVQ6pNNK+sx+c/GM5/SaML0w/r4ZB7sAneD/piDJtwdKlNckXeyGK7wlwg2E2w33C/Hh+VFCg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-member-expression-literals@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.2.0.tgz#fa10aa5c58a2cb6afcf2c9ffa8cb4d8b3d489a2d" + integrity sha512-HiU3zKkSU6scTidmnFJ0bMX8hz5ixC93b4MHMiYebmk2lUVNGOboPsqQvx5LzooihijUoLR/v7Nc1rbBtnc7FA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-modules-amd@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.5.0.tgz#ef00435d46da0a5961aa728a1d2ecff063e4fb91" + integrity sha512-n20UsQMKnWrltocZZm24cRURxQnWIvsABPJlw/fvoy9c6AgHZzoelAIzajDHAQrDpuKFFPPcFGd7ChsYuIUMpg== + dependencies: + "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + babel-plugin-dynamic-import-node "^2.3.0" + +"@babel/plugin-transform-modules-commonjs@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.5.0.tgz#425127e6045231360858eeaa47a71d75eded7a74" + integrity sha512-xmHq0B+ytyrWJvQTc5OWAC4ii6Dhr0s22STOoydokG51JjWhyYo5mRPXoi+ZmtHQhZZwuXNN+GG5jy5UZZJxIQ== + dependencies: + "@babel/helper-module-transforms" "^7.4.4" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-simple-access" "^7.1.0" + babel-plugin-dynamic-import-node "^2.3.0" + +"@babel/plugin-transform-modules-systemjs@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.5.0.tgz#e75266a13ef94202db2a0620977756f51d52d249" + integrity sha512-Q2m56tyoQWmuNGxEtUyeEkm6qJYFqs4c+XyXH5RAuYxObRNz9Zgj/1g2GMnjYp2EUyEy7YTrxliGCXzecl/vJg== + dependencies: + "@babel/helper-hoist-variables" "^7.4.4" + "@babel/helper-plugin-utils" "^7.0.0" + babel-plugin-dynamic-import-node "^2.3.0" + +"@babel/plugin-transform-modules-umd@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.2.0.tgz#7678ce75169f0877b8eb2235538c074268dd01ae" + integrity sha512-BV3bw6MyUH1iIsGhXlOK6sXhmSarZjtJ/vMiD9dNmpY8QXFFQTj+6v92pcfy1iqa8DeAfJFwoxcrS/TUZda6sw== + dependencies: + "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-named-capturing-groups-regex@^7.4.5": + version "7.4.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.4.5.tgz#9d269fd28a370258199b4294736813a60bbdd106" + integrity sha512-z7+2IsWafTBbjNsOxU/Iv5CvTJlr5w4+HGu1HovKYTtgJ362f7kBcQglkfmlspKKZ3bgrbSGvLfNx++ZJgCWsg== + dependencies: + regexp-tree "^0.1.6" + +"@babel/plugin-transform-new-target@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.4.4.tgz#18d120438b0cc9ee95a47f2c72bc9768fbed60a5" + integrity sha512-r1z3T2DNGQwwe2vPGZMBNjioT2scgWzK9BCnDEh+46z8EEwXBq24uRzd65I7pjtugzPSj921aM15RpESgzsSuA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-object-super@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.2.0.tgz#b35d4c10f56bab5d650047dad0f1d8e8814b6598" + integrity sha512-VMyhPYZISFZAqAPVkiYb7dUe2AsVi2/wCT5+wZdsNO31FojQJa9ns40hzZ6U9f50Jlq4w6qwzdBB2uwqZ00ebg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-replace-supers" "^7.1.0" + +"@babel/plugin-transform-parameters@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.4.4.tgz#7556cf03f318bd2719fe4c922d2d808be5571e16" + integrity sha512-oMh5DUO1V63nZcu/ZVLQFqiihBGo4OpxJxR1otF50GMeCLiRx5nUdtokd+u9SuVJrvvuIh9OosRFPP4pIPnwmw== + dependencies: + "@babel/helper-call-delegate" "^7.4.4" + "@babel/helper-get-function-arity" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-property-literals@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.2.0.tgz#03e33f653f5b25c4eb572c98b9485055b389e905" + integrity sha512-9q7Dbk4RhgcLp8ebduOpCbtjh7C0itoLYHXd9ueASKAG/is5PQtMR5VJGka9NKqGhYEGn5ITahd4h9QeBMylWQ== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-regenerator@^7.4.5": + version "7.4.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.5.tgz#629dc82512c55cee01341fb27bdfcb210354680f" + integrity sha512-gBKRh5qAaCWntnd09S8QC7r3auLCqq5DI6O0DlfoyDjslSBVqBibrMdsqO+Uhmx3+BlOmE/Kw1HFxmGbv0N9dA== + dependencies: + regenerator-transform "^0.14.0" + +"@babel/plugin-transform-reserved-words@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.2.0.tgz#4792af87c998a49367597d07fedf02636d2e1634" + integrity sha512-fz43fqW8E1tAB3DKF19/vxbpib1fuyCwSPE418ge5ZxILnBhWyhtPgz8eh1RCGGJlwvksHkyxMxh0eenFi+kFw== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-shorthand-properties@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0" + integrity sha512-QP4eUM83ha9zmYtpbnyjTLAGKQritA5XW/iG9cjtuOI8s1RuL/3V6a3DeSHfKutJQ+ayUfeZJPcnCYEQzaPQqg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-spread@^7.2.0": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.2.2.tgz#3103a9abe22f742b6d406ecd3cd49b774919b406" + integrity sha512-KWfky/58vubwtS0hLqEnrWJjsMGaOeSBn90Ezn5Jeg9Z8KKHmELbP1yGylMlm5N6TPKeY9A2+UaSYLdxahg01w== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-sticky-regex@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.2.0.tgz#a1e454b5995560a9c1e0d537dfc15061fd2687e1" + integrity sha512-KKYCoGaRAf+ckH8gEL3JHUaFVyNHKe3ASNsZ+AlktgHevvxGigoIttrEJb8iKN03Q7Eazlv1s6cx2B2cQ3Jabw== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-regex" "^7.0.0" + +"@babel/plugin-transform-template-literals@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.4.4.tgz#9d28fea7bbce637fb7612a0750989d8321d4bcb0" + integrity sha512-mQrEC4TWkhLN0z8ygIvEL9ZEToPhG5K7KDW3pzGqOfIGZ28Jb0POUkeWcoz8HnHvhFy6dwAT1j8OzqN8s804+g== + dependencies: + "@babel/helper-annotate-as-pure" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-typeof-symbol@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.2.0.tgz#117d2bcec2fbf64b4b59d1f9819894682d29f2b2" + integrity sha512-2LNhETWYxiYysBtrBTqL8+La0jIoQQnIScUJc74OYvUGRmkskNY4EzLCnjHBzdmb38wqtTaixpo1NctEcvMDZw== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + +"@babel/plugin-transform-typescript@^7.3.2": + version "7.5.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.5.2.tgz#ea7da440d29b8ccdb1bd02e18f6cfdc7ce6c16f5" + integrity sha512-r4zJOMbKY5puETm8+cIpaa0RQZG/sSASW1u0pj8qYklcERgVIbxVbP2wyJA7zI1//h7lEagQmXi9IL9iI5rfsA== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.5.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-syntax-typescript" "^7.2.0" + +"@babel/plugin-transform-unicode-regex@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.4.4.tgz#ab4634bb4f14d36728bf5978322b35587787970f" + integrity sha512-il+/XdNw01i93+M9J9u4T7/e/Ue/vWfNZE4IRUQjplu2Mqb/AFTDimkw2tdEdSH50wuQXZAbXSql0UphQke+vA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/helper-regex" "^7.4.4" + regexpu-core "^4.5.4" + +"@babel/preset-env@^7.5.4": + version "7.5.4" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.5.4.tgz#64bc15041a3cbb0798930319917e70fcca57713d" + integrity sha512-hFnFnouyRNiH1rL8YkX1ANCNAUVC8Djwdqfev8i1415tnAG+7hlA5zhZ0Q/3Q5gkop4HioIPbCEWAalqcbxRoQ== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-proposal-async-generator-functions" "^7.2.0" + "@babel/plugin-proposal-dynamic-import" "^7.5.0" + "@babel/plugin-proposal-json-strings" "^7.2.0" + "@babel/plugin-proposal-object-rest-spread" "^7.5.4" + "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" + "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" + "@babel/plugin-syntax-async-generators" "^7.2.0" + "@babel/plugin-syntax-dynamic-import" "^7.2.0" + "@babel/plugin-syntax-json-strings" "^7.2.0" + "@babel/plugin-syntax-object-rest-spread" "^7.2.0" + "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" + "@babel/plugin-transform-arrow-functions" "^7.2.0" + "@babel/plugin-transform-async-to-generator" "^7.5.0" + "@babel/plugin-transform-block-scoped-functions" "^7.2.0" + "@babel/plugin-transform-block-scoping" "^7.4.4" + "@babel/plugin-transform-classes" "^7.4.4" + "@babel/plugin-transform-computed-properties" "^7.2.0" + "@babel/plugin-transform-destructuring" "^7.5.0" + "@babel/plugin-transform-dotall-regex" "^7.4.4" + "@babel/plugin-transform-duplicate-keys" "^7.5.0" + "@babel/plugin-transform-exponentiation-operator" "^7.2.0" + "@babel/plugin-transform-for-of" "^7.4.4" + "@babel/plugin-transform-function-name" "^7.4.4" + "@babel/plugin-transform-literals" "^7.2.0" + "@babel/plugin-transform-member-expression-literals" "^7.2.0" + "@babel/plugin-transform-modules-amd" "^7.5.0" + "@babel/plugin-transform-modules-commonjs" "^7.5.0" + "@babel/plugin-transform-modules-systemjs" "^7.5.0" + "@babel/plugin-transform-modules-umd" "^7.2.0" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.4.5" + "@babel/plugin-transform-new-target" "^7.4.4" + "@babel/plugin-transform-object-super" "^7.2.0" + "@babel/plugin-transform-parameters" "^7.4.4" + "@babel/plugin-transform-property-literals" "^7.2.0" + "@babel/plugin-transform-regenerator" "^7.4.5" + "@babel/plugin-transform-reserved-words" "^7.2.0" + "@babel/plugin-transform-shorthand-properties" "^7.2.0" + "@babel/plugin-transform-spread" "^7.2.0" + "@babel/plugin-transform-sticky-regex" "^7.2.0" + "@babel/plugin-transform-template-literals" "^7.4.4" + "@babel/plugin-transform-typeof-symbol" "^7.2.0" + "@babel/plugin-transform-unicode-regex" "^7.4.4" + "@babel/types" "^7.5.0" + browserslist "^4.6.0" + core-js-compat "^3.1.1" + invariant "^2.2.2" + js-levenshtein "^1.1.3" + semver "^5.5.0" + +"@babel/preset-typescript@^7.3.3": + version "7.3.3" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.3.3.tgz#88669911053fa16b2b276ea2ede2ca603b3f307a" + integrity sha512-mzMVuIP4lqtn4du2ynEfdO0+RYcslwrZiJHXu4MGaC1ctJiW2fyaeDrtjJGs7R/KebZ1sgowcIoWf4uRpEfKEg== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-typescript" "^7.3.2" + +"@babel/register@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.4.4.tgz#370a68ba36f08f015a8b35d4864176c6b65d7a23" + integrity sha512-sn51H88GRa00+ZoMqCVgOphmswG4b7mhf9VOB0LUBAieykq2GnRFerlN+JQkO/ntT7wz4jaHNSRPg9IdMPEUkA== + dependencies: + core-js "^3.0.0" + find-cache-dir "^2.0.0" + lodash "^4.17.11" + mkdirp "^0.5.1" + pirates "^4.0.0" + source-map-support "^0.5.9" + +"@babel/template@^7.1.0", "@babel/template@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237" + integrity sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/parser" "^7.4.4" + "@babel/types" "^7.4.4" + +"@babel/traverse@^7.1.0", "@babel/traverse@^7.4.4", "@babel/traverse@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.5.0.tgz#4216d6586854ef5c3c4592dab56ec7eb78485485" + integrity sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.5.0" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.4.4" + "@babel/parser" "^7.5.0" + "@babel/types" "^7.5.0" + debug "^4.1.0" + globals "^11.1.0" + lodash "^4.17.11" + +"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.4.4", "@babel/types@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.5.0.tgz#e47d43840c2e7f9105bc4d3a2c371b4d0c7832ab" + integrity sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ== + dependencies: + esutils "^2.0.2" + lodash "^4.17.11" + to-fast-properties "^2.0.0" + +ajv@^6.5.4: + version "6.10.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" + integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw== + dependencies: + fast-deep-equal "^2.0.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +asn1@^0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== + dependencies: + safer-buffer "~2.1.0" + +babel-plugin-dynamic-import-node@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz#f00f507bdaa3c3e3ff6e7e5e98d90a7acab96f7f" + integrity sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ== + dependencies: + object.assign "^4.1.0" + +bn.js@^4.11.4: + version "4.11.8" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" + integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== + +browserslist@^4.6.0, browserslist@^4.6.2: + version "4.6.6" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.6.6.tgz#6e4bf467cde520bc9dbdf3747dafa03531cec453" + integrity sha512-D2Nk3W9JL9Fp/gIcWei8LrERCS+eXu9AM5cfXA8WEZ84lFks+ARnZ0q/R69m2SV3Wjma83QDDPxsNKXUwdIsyA== + dependencies: + caniuse-lite "^1.0.30000984" + electron-to-chromium "^1.3.191" + node-releases "^1.1.25" + +buffer-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" + integrity sha1-WWFrSYME1Var1GaWayLu2j7KX74= + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + +caniuse-lite@^1.0.30000984: + version "1.0.30000984" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000984.tgz#dc96c3c469e9bcfc6ad5bdd24c77ec918ea76fe0" + integrity sha512-n5tKOjMaZ1fksIpQbjERuqCyfgec/m9pferkFQbLmWtqLUdmt12hNhjSwsmPdqeiG2NkITOQhr1VYIwWSAceiA== + +chalk@^2.0.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +commander@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" + integrity sha1-+mihT2qUXVTbvlDYzbMyDp47GgY= + +commander@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" + integrity sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM= + +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" + integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= + +convert-source-map@^1.1.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" + integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A== + dependencies: + safe-buffer "~5.1.1" + +core-js-compat@^3.1.1: + version "3.1.4" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.1.4.tgz#e4d0c40fbd01e65b1d457980fe4112d4358a7408" + integrity sha512-Z5zbO9f1d0YrJdoaQhphVAnKPimX92D6z8lCGphH89MNRxlL1prI9ExJPqVwP0/kgkQCv8c4GJGT8X16yUncOg== + dependencies: + browserslist "^4.6.2" + core-js-pure "3.1.4" + semver "^6.1.1" + +core-js-pure@3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.1.4.tgz#5fa17dc77002a169a3566cc48dc774d2e13e3769" + integrity sha512-uJ4Z7iPNwiu1foygbcZYJsJs1jiXrTTCvxfLDXNhI/I+NHbSIEyr548y4fcsCEyWY0XgfAG/qqaunJ1SThHenA== + +core-js@^3.0.0: + version "3.1.4" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.1.4.tgz#3a2837fc48e582e1ae25907afcd6cf03b0cc7a07" + integrity sha512-YNZN8lt82XIMLnLirj9MhKDFZHalwzzrL9YLt6eb0T5D0EDl4IQ90IGkua8mHbnxNrkj1d8hbdizMc0Qmg1WnQ== + +debug@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + integrity sha1-+HBX6ZWxofauaklgZkE3vFbwOdo= + dependencies: + ms "0.7.1" + +debug@^3.1.0: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +debug@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + +define-properties@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" + integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + dependencies: + object-keys "^1.0.12" + +diff@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + integrity sha1-fyjS657nsVqX79ic5j3P2qPMur8= + +electron-to-chromium@^1.3.191: + version "1.3.191" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.191.tgz#c451b422cd8b2eab84dedabab5abcae1eaefb6f0" + integrity sha512-jasjtY5RUy/TOyiUYM2fb4BDaPZfm6CXRFeJDMfFsXYADGxUN49RBqtgB7EL2RmJXeIRUk9lM1U6A5yk2YJMPQ== + +escape-string-regexp@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" + integrity sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE= + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= + +fast-deep-equal@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" + integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= + +find-cache-dir@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" + integrity sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ== + dependencies: + commondir "^1.0.1" + make-dir "^2.0.0" + pkg-dir "^3.0.0" + +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + +glob@3.2.11: + version "3.2.11" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" + integrity sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0= + dependencies: + inherits "2" + minimatch "0.3" + +globals@^11.1.0: + version "11.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + integrity sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8= + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" + integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= + +inherits@2, inherits@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +invariant@^2.2.2: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + +jade@0.26.3: + version "0.26.3" + resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" + integrity sha1-jxDXl32NefL2/4YqgbBRPMslaGw= + dependencies: + commander "0.6.1" + mkdirp "0.3.0" + +js-levenshtein@^1.1.3: + version "1.1.6" + resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d" + integrity sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g== + +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +jsesc@^2.5.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" + integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0= + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json5@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850" + integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ== + dependencies: + minimist "^1.2.0" + +jwt-simple@^0.5.0: + version "0.5.6" + resolved "https://registry.yarnpkg.com/jwt-simple/-/jwt-simple-0.5.6.tgz#3357adec55b26547114157be66748995b75b333a" + integrity sha512-40aUybvhH9t2h71ncA1/1SbtTNCVZHgsTsTgqPUxGWDmUDrXyDf2wMNQKEbdBjbf4AI+fQhbECNTV6lWxQKUzg== + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= + +lodash.merge@^4.4.0, lodash.merge@^4.6.1: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +lodash.reduce@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" + integrity sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs= + +lodash@^4.17.11: + version "4.17.14" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba" + integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw== + +loose-envify@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + +lru-cache@2: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + integrity sha1-bUUk6LlV+V1PW1iFHOId1y+06VI= + +macaddress@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.9.tgz#3579b8b9acd5b96b4553abf0f394185a86813cb3" + integrity sha512-k4F1JUof6cQXxNFzx3thLby4oJzXTXQueAOOts944Vqizn+Rjc2QNFenT9FJSLU1CH3PmrHRSyZs2E+Cqw+P2w== + +make-dir@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" + integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== + dependencies: + pify "^4.0.1" + semver "^5.6.0" + +minimatch@0.3: + version "0.3.0" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" + integrity sha1-J12O2qxPG7MyZHIInnlJyDlGmd0= + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= + +minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + +mkdirp@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" + integrity sha1-G79asbqCevI1dRQ0kEJkVfSB/h4= + +mkdirp@0.5.1, mkdirp@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= + dependencies: + minimist "0.0.8" + +mocha@^2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58" + integrity sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg= + dependencies: + commander "2.3.0" + debug "2.2.0" + diff "1.4.0" + escape-string-regexp "1.0.2" + glob "3.2.11" + growl "1.9.2" + jade "0.26.3" + mkdirp "0.5.1" + supports-color "1.2.0" + to-iso-string "0.0.2" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + integrity sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg= + +ms@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +node-modules-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" + integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= + +node-releases@^1.1.25: + version "1.1.25" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.25.tgz#0c2d7dbc7fed30fbe02a9ee3007b8c90bf0133d3" + integrity sha512-fI5BXuk83lKEoZDdH3gRhtsNgh05/wZacuXkgbiYkceE7+QIMXOg98n9ZV7mz27B+kFHnqHcUpscZZlGRSmTpQ== + dependencies: + semver "^5.3.0" + +object-keys@^1.0.11, object-keys@^1.0.12: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object.assign@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + +p-limit@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" + integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + +pify@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" + integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== + +pirates@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.1.tgz#643a92caf894566f91b2b986d2c66950a8e2fb87" + integrity sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA== + dependencies: + node-modules-regexp "^1.0.0" + +pkg-dir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" + integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== + dependencies: + find-up "^3.0.0" + +prismarine-nbt@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prismarine-nbt/-/prismarine-nbt-1.2.1.tgz#4b0e50e538a4676ee259ae0588120360ab39110d" + integrity sha512-E2bBd2XzmcynT67zrkucgrC2MIgjmUtUathJ9sfjTswT+ou+7kbHbbLHO3nHLb6TKGiWFH79OfUmBTHJFULpbw== + dependencies: + protodef "^1.2.1" + +private@^0.1.6: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== + +protodef-validator@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/protodef-validator/-/protodef-validator-1.2.2.tgz#68fae789170e60c5a0a72686f56daee8f791f659" + integrity sha512-EnfcF1v/FGPtkwQr6SAbCM+9IoMCXlhtUVQKgeavUXoJ4FLNk3dZ0jIg/KDnTmaVgvDdHXhg1foH/qTae9vfhw== + dependencies: + ajv "^6.5.4" + +protodef@^1.2.1, protodef@^1.2.3, protodef@^1.6.6: + version "1.6.9" + resolved "https://registry.yarnpkg.com/protodef/-/protodef-1.6.9.tgz#3e913264757e1cf8489589552ec04263a44401f2" + integrity sha512-evAmLjdHgQ3B+wYyCgEijQxSBW049psaXCQlvg6PeJGhgTGEcMrn3M7idHbYvpGNKVIqwnIx8dpFpz1CJNm1wQ== + dependencies: + lodash.get "^4.4.2" + lodash.reduce "^4.6.0" + protodef-validator "^1.2.2" + readable-stream "^3.0.3" + +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +"raknet@git+https://github.com/mhsjlw/node-raknet.git#master": + version "1.8.0" + resolved "git+https://github.com/mhsjlw/node-raknet.git#c017e4625e87a25e5fef1bb2fbb01e3fc5f91b00" + dependencies: + debug "^3.1.0" + lodash.merge "^4.6.1" + protodef "^1.6.6" + split-buffer "^1.0.0" + +readable-stream@^3.0.3: + version "3.4.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc" + integrity sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +regenerate-unicode-properties@^8.0.2: + version "8.1.0" + resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" + integrity sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA== + dependencies: + regenerate "^1.4.0" + +regenerate@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" + integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg== + +regenerator-transform@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.0.tgz#2ca9aaf7a2c239dd32e4761218425b8c7a86ecaf" + integrity sha512-rtOelq4Cawlbmq9xuMR5gdFmv7ku/sFoB7sRiywx7aq53bc52b4j6zvH7Te1Vt/X2YveDKnCGUbioieU7FEL3w== + dependencies: + private "^0.1.6" + +regexp-tree@^0.1.6: + version "0.1.11" + resolved "https://registry.yarnpkg.com/regexp-tree/-/regexp-tree-0.1.11.tgz#c9c7f00fcf722e0a56c7390983a7a63dd6c272f3" + integrity sha512-7/l/DgapVVDzZobwMCCgMlqiqyLFJ0cduo/j+3BcDJIB+yJdsYCfKuI3l/04NV+H/rfNRdPIDbXNZHM9XvQatg== + +regexpu-core@^4.5.4: + version "4.5.4" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.5.4.tgz#080d9d02289aa87fe1667a4f5136bc98a6aebaae" + integrity sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ== + dependencies: + regenerate "^1.4.0" + regenerate-unicode-properties "^8.0.2" + regjsgen "^0.5.0" + regjsparser "^0.6.0" + unicode-match-property-ecmascript "^1.0.4" + unicode-match-property-value-ecmascript "^1.1.0" + +regjsgen@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.0.tgz#a7634dc08f89209c2049adda3525711fb97265dd" + integrity sha512-RnIrLhrXCX5ow/E5/Mh2O4e/oa1/jW0eaBKTSy3LaCj+M3Bqvm97GWDp2yUtzIs4LEn65zR2yiYGFqb2ApnzDA== + +regjsparser@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.0.tgz#f1e6ae8b7da2bae96c99399b868cd6c933a2ba9c" + integrity sha512-RQ7YyokLiQBomUJuUG8iGVvkgOLxwyZM8k6d3q5SAXpg4r5TZJZigKFvC6PpD+qQ98bCDC5YelPeA3EucDoNeQ== + dependencies: + jsesc "~0.5.0" + +resolve@^1.3.2: + version "1.11.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" + integrity sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw== + dependencies: + path-parse "^1.0.6" + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: + version "5.7.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" + integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== + +semver@^6.1.1: + version "6.2.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db" + integrity sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A== + +sigmund@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA= + +source-map-support@^0.5.9: + version "0.5.12" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" + integrity sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.5.0: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +split-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/split-buffer/-/split-buffer-1.0.0.tgz#b7e8e0ab51345158b72c1f6dbef2406d51f1d027" + integrity sha1-t+jgq1E0UVi3LB9tvvJAbVHx0Cc= + +string_decoder@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.2.0.tgz#fe86e738b19544afe70469243b2a1ee9240eae8d" + integrity sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w== + dependencies: + safe-buffer "~5.1.0" + +supports-color@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" + integrity sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4= + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= + +to-iso-string@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" + integrity sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE= + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + +unicode-canonical-property-names-ecmascript@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" + integrity sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ== + +unicode-match-property-ecmascript@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz#8ed2a32569961bce9227d09cd3ffbb8fed5f020c" + integrity sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg== + dependencies: + unicode-canonical-property-names-ecmascript "^1.0.4" + unicode-property-aliases-ecmascript "^1.0.4" + +unicode-match-property-value-ecmascript@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz#5b4b426e08d13a80365e0d657ac7a6c1ec46a277" + integrity sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g== + +unicode-property-aliases-ecmascript@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz#a9cc6cc7ce63a0a3023fc99e341b94431d405a57" + integrity sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw== + +uri-js@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" + integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + dependencies: + punycode "^2.1.0" + +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +uuid-1345@^0.99.6: + version "0.99.7" + resolved "https://registry.yarnpkg.com/uuid-1345/-/uuid-1345-0.99.7.tgz#e52845074352feaae72ce7b31ae1f53b486ceea1" + integrity sha512-A70cwvqH95zULri1/t00/r6Bd97hKpNvS9SoSLP9Bupn95sX/01JkOuH9YjJrmNul7ZAjyX3Y3ZMlDrCjuoNPQ== + dependencies: + macaddress "^0.2.9" From 06c77c3668003bd159555e9ead15786a8005fe8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 14 Jul 2019 17:53:52 +0200 Subject: [PATCH 072/106] Manually fix packets for 1.12 --- data/protocol.json | 206 ++++++++++---------------------------- examples/server_simple.js | 2 +- src/createServer.js | 3 - 3 files changed, 54 insertions(+), 157 deletions(-) diff --git a/data/protocol.json b/data/protocol.json index ffb2876..f3affcd 100644 --- a/data/protocol.json +++ b/data/protocol.json @@ -552,14 +552,21 @@ "name": "player_gamemode", "type": "varint" }, + { "name": "spawn", "type": "vector3" }, + { - "name": "unknown_1", - "type": "vector2" + "name": "pitch", + "type": "lf32" }, + { + "name": "yaw", + "type": "lf32" + }, + { "name": "seed", "type": "varint" @@ -580,6 +587,7 @@ "name": "difficulty", "type": "varint" }, + { "name": "x", "type": "varint" @@ -592,12 +600,13 @@ "name": "z", "type": "varint" }, + { "name": "has_achievements_disabled", "type": "bool" }, { - "name": "day_cycle_stop_time", + "name": "time", "type": "varint" }, { @@ -644,10 +653,12 @@ "name": "is_texturepacks_required", "type": "bool" }, + { - "name": "gamerules", - "type": "gamerules" + "name": "u8", + "type": "u8" }, + { "name": "bonus_chest", "type": "bool" @@ -660,10 +671,12 @@ "name": "permission_level", "type": "varint" }, + { "name": "server_chunk_tick_range", "type": "i32" }, + { "name": "has_locked_behavior_pack", "type": "bool" @@ -672,6 +685,7 @@ "name": "has_locked_resource_pack", "type": "bool" }, + { "name": "is_from_locked_world_template", "type": "bool" @@ -688,6 +702,11 @@ "name": "is_world_template_option_locked", "type": "bool" }, + { + "name": "use_v1_villagers", + "type": "bool" + }, + { "name": "level_id", "type": "string" @@ -712,17 +731,18 @@ "name": "enchantment_seed", "type": "varint" }, + { "name": "blockstates", - "type": "blockstates" + "type": "u8" + }, + { + "name": "itemtable", + "type": "u8" }, { "name": "multiplayer_correlation_id", "type": "string" - }, - { - "name": "unknown2", - "type": "u8" } ] ], @@ -737,6 +757,7 @@ "name": "username", "type": "string" }, + { "name": "entity_id_self", "type": "varint" @@ -749,30 +770,16 @@ "name": "platform_chat_id", "type": "string" }, + { - "name": "x", - "type": "lf32" + "name": "position", + "type": "vector3" }, { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "speed_x", - "type": "lf32" - }, - { - "name": "speed_y", - "type": "lf32" - }, - { - "name": "speed_z", - "type": "lf32" + "name": "motion", + "type": "vector3" }, + { "name": "pitch", "type": "lf32" @@ -785,14 +792,16 @@ "name": "head_yaw", "type": "lf32" }, + { "name": "item", - "type": "varint" + "type": "u8" }, { "name": "metadata", - "type": "varint" + "type": "u8" }, + { "name": "flags", "type": "varint" @@ -813,13 +822,14 @@ "name": "custom_stored_permissions", "type": "varint" }, + { "name": "user_id", "type": "i64" }, { "name": "links", - "type": "links" + "type": "u8" }, { "name": "device_id", @@ -833,62 +843,6 @@ { "name": "entity_id_self", "type": "varint" - }, - { - "name": "runtime_entity_id", - "type": "varint" - }, - { - "name": "entity_type", - "type": "string" - }, - { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" - }, - { - "name": "speed_x", - "type": "lf32" - }, - { - "name": "speed_y", - "type": "lf32" - }, - { - "name": "speed_z", - "type": "lf32" - }, - { - "name": "pitch", - "type": "lf32" - }, - { - "name": "yaw", - "type": "lf32" - }, - { - "name": "head_yaw", - "type": "lf32" - }, - { - "name": "attributes", - "type": "varint" - }, - { - "name": "metadata", - "type": "varint" - }, - { - "name": "links", - "type": "links" } ] ], @@ -1222,9 +1176,13 @@ "packet_inventory_transaction": [ "container", [ + { + "name": "transaction_type", + "type": "varint" + }, { "name": "transaction", - "type": "transaction" + "type": "varint" } ] ], @@ -1684,16 +1642,6 @@ { "name": "chunk_z", "type": "varint" - }, - { - "name": "chunk_data", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] } ] ], @@ -1755,7 +1703,7 @@ [ { "name": "event_type", - "type": "ushort" + "type": "u8" } ] ], @@ -1839,7 +1787,7 @@ [ { "name": "rules", - "type": "gamerules" + "type": "u8" } ] ], @@ -2012,16 +1960,6 @@ { "name": "compressed_package_size", "type": "u64" - }, - { - "name": "hash", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] } ] ], @@ -2043,16 +1981,6 @@ { "name": "length", "type": "u32" - }, - { - "name": "payload", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] } ] ], @@ -2078,7 +2006,7 @@ }, { "name": "port", - "type": "ushort" + "type": "u8" } ] ], @@ -2189,34 +2117,6 @@ { "name": "old_skin_name", "type": "string" - }, - { - "name": "skin_data", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] - }, - { - "name": "cape_data", - "type": [ - "buffer", - { - "countType": "varint", - "type": "i8" - } - ] - }, - { - "name": "geometry_model", - "type": "string" - }, - { - "name": "geometry_data", - "type": "string" } ] ], @@ -2384,7 +2284,7 @@ [ { "name": "entries", - "type": "scoreentries" + "type": "u8" } ] ], @@ -2460,7 +2360,7 @@ [ { "name": "entries", - "type": "scoreboardidentityentries" + "type": "u8" } ] ], diff --git a/examples/server_simple.js b/examples/server_simple.js index 1cf2e15..846666e 100644 --- a/examples/server_simple.js +++ b/examples/server_simple.js @@ -22,7 +22,7 @@ server.on('connection', function(client) { }); client.on('error', err => { - console.log(err.stack); + console.error(err); }); client.on('end', () => { diff --git a/src/createServer.js b/src/createServer.js index f83fb28..cbca2d9 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -3,8 +3,6 @@ import zlib from 'zlib'; import jwt from 'jwt-simple'; import { ProtoDef, Parser, Serializer } from 'protodef'; -let debug = require('debug')('raknet'); - let batchProto = new ProtoDef(); const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; @@ -89,7 +87,6 @@ function createServer(options, encryption) { // string: packet name // object: packet data client.writeAll = (name, data) => { - return; //TODO server._writeAll(name, data); }; From c75a661a480a5dd685d527268aefb97a942f6fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Sun, 14 Jul 2019 18:22:34 +0200 Subject: [PATCH 073/106] Build package before commit. --- dist/createClient.js | 70 ++ dist/createServer.js | 147 ++++ dist/datatypes/minecraft.js | 139 ++++ dist/index.js | 9 + dist/transforms/serializer.js | 32 + index.js | 13 +- package.json | 10 +- yarn.lock | 1299 ++++++++++++++++++++++++++++++++- 8 files changed, 1699 insertions(+), 20 deletions(-) create mode 100644 dist/createClient.js create mode 100644 dist/createServer.js create mode 100644 dist/datatypes/minecraft.js create mode 100644 dist/index.js create mode 100644 dist/transforms/serializer.js diff --git a/dist/createClient.js b/dist/createClient.js new file mode 100644 index 0000000..13d4cd8 --- /dev/null +++ b/dist/createClient.js @@ -0,0 +1,70 @@ +'use strict'; + +var assert = require('assert'); + +var raknet = require('raknet'); + +var fs = require('fs'); + +var path = require('path'); + +var zlib = require('zlib'); + +var ProtoDef = require('protodef').ProtoDef; + +var batchProto = new ProtoDef(); +batchProto.addTypes(require("./datatypes/minecraft")); +batchProto.addType("insideBatch", ["endOfArray", { + "type": ["buffer", { + "countType": "i32" + }] +}]); + +function createClient(options) { + return null; //FIXME + + assert.ok(options, 'options is required'); + var port = options.port || 19132; + var host = options.host || 'localhost'; + assert.ok(options.username, 'username is required'); + options.customPackets = require('../data/protocol'); + options.customTypes = require('./datatypes/minecraft'); + var client = raknet.createClient(options); + client.username = options.username; + client.on('mcpe', function (packet) { + return client.emit(packet.name, packet.params); + }); + + client.writeMCPE = function (name, packet) { + client.writeEncapsulated('mcpe', { + name: name, + params: packet + }); + }; + + client.on('login', function () { + client.writeMCPE('game_login', { + username: client.username, + protocol: 70, + protocol2: 70, + clientId: [-1, -697896776], + clientUuid: '86372ed8-d055-b23a-9171-5e3ac594d766', + serverAddress: client.host + ":" + client.port, + clientSecret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g, ''), 'hex'), + skin: { + skinType: 'Standard_Steve', + texture: fs.readFileSync(path.join(__dirname, 'texture')) + } + }); + }); + client.on('batch', function (packet) { + var buf = zlib.inflateSync(packet.payload); + var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; + packets.forEach(function (packet) { + return client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet])); + }); + }); + return client; +} + +module.exports = createClient; \ No newline at end of file diff --git a/dist/createServer.js b/dist/createServer.js new file mode 100644 index 0000000..e808cc9 --- /dev/null +++ b/dist/createServer.js @@ -0,0 +1,147 @@ +"use strict"; + +var _raknet = _interopRequireDefault(require("raknet")); + +var _zlib = _interopRequireDefault(require("zlib")); + +var _jwtSimple = _interopRequireDefault(require("jwt-simple")); + +var _protodef = require("protodef"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + +var batchProto = new _protodef.ProtoDef(); +var PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; // createServer (object, boolean) +// +// Create & launch a MCPE raknet-based server. +// object: raknet options +// encryption: enable/disable encryption + +function createServer(options, encryption) { + options = options || {}; + var port = options.port || options['server-port'] || 19132; + var host = options.host || '0.0.0.0'; + options.customPackets = (options.protocol ? options.protocol.packets : null) || require('../data/protocol'); + options.customTypes = (options.protocol ? options.protocol.types : null) || require('./datatypes/minecraft'); + batchProto.addTypes(options.customTypes); + batchProto.addType('insideBatch', ['endOfArray', { + 'type': ['buffer', { + 'countType': 'varint' + }] + }]); + + var server = _raknet["default"].createServer(options); + + server.name = options.name || 'Minecraft Server'; + server.motd = options.motd || 'A Minecraft server'; //FIXME + + server.maxPlayers = options['max-players'] || 20; //FIXME + + server.playerCount = 0; //FIXME + + server.on('connection', function (client) { + client.receiveCounter = 0; + client.sendCounter = 0; + client.encryptionEnabled = encryption ? true : false; + var proto = new _protodef.ProtoDef(); + proto.addTypes(options.customTypes); + proto.addTypes(options.customPackets.types); + client.mcpePacketSerializer = new _protodef.Serializer(proto, 'mcpe_packet'); + client.on('mcpe', function (packet) { + client.emit(packet.name, packet.params); + client.emit('debug', packet.name); + }); + client.on('batch', function (packets) { + var buf = _zlib["default"].inflateSync(packets.payload); + + var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; + packets.forEach(function (packet) { + return client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet])); + }); + }); // client.writePacket (string, object) + // Send data to the client + // + // string: packet name + // object: packet data + + client.writeMCPE = function (name, params) { + if (client.encryptionEnabled) { + client.mcpePacketSerializer.write({ + name: name, + params: params + }); + } else { + client.writeEncapsulated('mcpe', { + name: name, + params: params + }); + } + }; + + client.writePacket = client.writeMCPE; // client.writeData (array) + // Send data to the client + // + // array: packets to send + + client.writeBatch = function (packets) { + var payload = _zlib["default"].deflateSync(batchProto.createPacketBuffer('insideBatch', packets.map(function (packet) { + return client.mcpePacketSerializer.createPacketBuffer(packet); + }))); + + client.writePacket('batch', { + payload: payload + }); + }; + + client.writeData = client.writeBatch; // client.writeAll (string, object) + // Send data to the client + // + // string: packet name + // object: packet data + + client.writeAll = function (name, data) { + server._writeAll(name, data); + }; + + client.on('game_login', function (packet) { + try { + var dataProto = new _protodef.ProtoDef(); + dataProto.addType('data_chain', ['container', [{ + 'name': 'chain', + 'type': ['pstring', { + 'countType': 'li32' + }] + }, { + 'name': 'clientData', + 'type': ['pstring', { + 'countType': 'li32' + }] + }]]); //FIXME: Xbox & Non-Xbox support + + console.log(packet); + var body = dataProto.parsePacketBuffer('data_chain', _zlib["default"].inflateSync(packet.body)), + chain = null, + decode = null, + data = null; + body.data.chain = JSON.parse(body.data.chain); + chain = body.data.chain.chain[0]; + decode = _jwtSimple["default"].decode(chain, PUBLIC_KEY, 'ES384'); + data = _jwtSimple["default"].decode(body.data.clientData, decode.identityPublicKey, 'ES384'); + client.emit('mcpe_login', { + protocol: packet.protocol, + uuid: decode.extraData != null ? decode.extraData.identity : null, + id: decode.extraData != null ? decode.extraData.identityPublicKey : null, + username: decode.extraData != null ? decode.extraData.displayName : null, + skinData: data.SkinData, + skinId: data.SkinId + }); + } catch (err) { + console.error(err); + return null; + } + }); + }); + return server; +} + +module.exports = createServer; \ No newline at end of file diff --git a/dist/datatypes/minecraft.js b/dist/datatypes/minecraft.js new file mode 100644 index 0000000..9a1fcb8 --- /dev/null +++ b/dist/datatypes/minecraft.js @@ -0,0 +1,139 @@ +'use strict'; + +var nbt = require('prismarine-nbt'); + +var UUID = require('uuid-1345'); + +function readUUID(buffer, offset) { + if (offset + 16 > buffer.length) throw new PartialReadError(); + return { + value: UUID.stringify(buffer.slice(offset, 16 + offset)), + size: 16 + }; +} + +function writeUUID(value, buffer, offset) { + var buf = UUID.parse(value); + buf.copy(buffer, offset); + return offset + 16; +} + +function readNbt(buffer, offset) { + return nbt.protoLE.read(buffer, offset, "nbt"); +} + +function writeNbt(value, buffer, offset) { + return nbt.protoLE.write(value, buffer, offset, "nbt"); +} + +function sizeOfNbt(value) { + return nbt.protoLE.sizeOf(value, "nbt"); +} + +function readEntityMetadata(buffer, offset, _ref) { + var type = _ref.type; + var endVal = _ref.endVal; + var cursor = offset; + var metadata = []; + var item = undefined; + + while (true) { + if (offset + 1 > buffer.length) throw new PartialReadError(); + item = buffer.readUInt8(cursor); + + if (item === endVal) { + return { + value: metadata, + size: cursor + 1 - offset + }; + } + + var results = this.read(buffer, cursor, type, {}); + metadata.push(results.value); + cursor += results.size; + } +} + +function writeEntityMetadata(value, buffer, offset, _ref2) { + var type = _ref2.type; + var endVal = _ref2.endVal; + var self = this; + value.forEach(function (item) { + offset = self.write(item, buffer, offset, type, {}); + }); + buffer.writeUInt8(endVal, offset); + return offset + 1; +} + +function sizeOfEntityMetadata(value, _ref3) { + var type = _ref3.type; + var size = 1; + + for (var i = 0; i < value.length; ++i) { + size += this.sizeOf(value[i], type, {}); + } + + return size; +} + +function readIpAddress(buffer, offset) { + var address = buffer[offset] + '.' + buffer[offset + 1] + '.' + buffer[offset + 2] + '.' + buffer[offset + 3]; + return { + size: 4, + value: address + }; +} + +function writeIpAddress(value, buffer, offset) { + var address = value.split('.'); + address.forEach(function (b) { + buffer[offset] = parseInt(b); + offset++; + }); + return offset; +} + +function readEndOfArray(buffer, offset, typeArgs) { + var type = typeArgs.type; + var cursor = offset; + var elements = []; + + while (cursor < buffer.length) { + var results = this.read(buffer, cursor, type, {}); + elements.push(results.value); + cursor += results.size; + } + + return { + value: elements, + size: cursor - offset + }; +} + +function writeEndOfArray(value, buffer, offset, typeArgs) { + var type = typeArgs.type; + var self = this; + value.forEach(function (item) { + offset = self.write(item, buffer, offset, type, {}); + }); + return offset; +} + +function sizeOfEndOfArray(value, typeArgs) { + var type = typeArgs.type; + var size = 0; + + for (var i = 0; i < value.length; ++i) { + size += this.sizeOf(value[i], type, {}); + } + + return size; +} + +module.exports = { + 'uuid': [readUUID, writeUUID, 16], + 'nbt': [readNbt, writeNbt, sizeOfNbt], + 'entityMetadataLoop': [readEntityMetadata, writeEntityMetadata, sizeOfEntityMetadata], + 'ipAddress': [readIpAddress, writeIpAddress, 4], + 'endOfArray': [readEndOfArray, writeEndOfArray, sizeOfEndOfArray] +}; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..9db82d4 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,9 @@ +"use strict"; + +module.exports = { + createSerializer: require("./transforms/serializer").createSerializer, + createDeserializer: require("./transforms/serializer").createDeserializer, + createProtocol: require('./transforms/serializer').createProtocol, + createServer: require("./createServer"), + createClient: require("./createClient") +}; \ No newline at end of file diff --git a/dist/transforms/serializer.js b/dist/transforms/serializer.js new file mode 100644 index 0000000..a1b0965 --- /dev/null +++ b/dist/transforms/serializer.js @@ -0,0 +1,32 @@ +'use strict'; + +var ProtoDef = require('protodef').ProtoDef; + +var Serializer = require('protodef').Serializer; + +var Parser = require('protodef').Parser; + +var protocol = require('../../data/protocol.json').types; + +function createProtocol() { + var proto = new ProtoDef(); + proto.addTypes(require('../datatypes/minecraft')); + proto.addTypes(protocol); + return proto; +} + +function createSerializer() { + var proto = createProtocol(); + return new Serializer(proto, 'packet'); +} + +function createDeserializer() { + var proto = createProtocol(); + return new Parser(proto, 'packet'); +} + +module.exports = { + createDeserializer: createDeserializer, + createSerializer: createSerializer, + createProtocol: createProtocol +}; \ No newline at end of file diff --git a/index.js b/index.js index b4287e3..b3da4d2 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,3 @@ 'use strict'; -const path = require('path'); -const register = require('@babel/register').default; -register({ - extends: path.resolve(__dirname, '.babelrc'), - ignore: [/node_modules/], - extensions: [ - ".js", - ".ts" - ] -}); - -module.exports = require('./src/index.js'); +module.exports = require('./dist/index.js'); diff --git a/package.json b/package.json index 41167fd..480db34 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Parse and serialize Minecraft Pocket Edition packets", "main": "index.js", "scripts": { + "build": "babel src --out-dir dist", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ @@ -27,8 +28,10 @@ "uuid-1345": "^0.99.6" }, "devDependencies": { + "@babel/cli": "^7.5.0", "buffer-equal": "^1.0.0", - "mocha": "^2.5.3" + "mocha": "^2.5.3", + "pre-commit": "^1.2.2" }, "repository": { "type": "git", @@ -37,5 +40,8 @@ "bugs": { "url": "https://github.com/mhsjlw/pocket-minecraft-protocol/issues" }, - "homepage": "https://github.com/mhsjlw/pocket-minecraft-protocol#readme" + "homepage": "https://github.com/mhsjlw/pocket-minecraft-protocol#readme", + "pre-commit": [ + "build" + ] } diff --git a/yarn.lock b/yarn.lock index f81af3d..a2e8df3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,23 @@ # yarn lockfile v1 +"@babel/cli@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.5.0.tgz#f403c930692e28ecfa3bf02a9e7562b474f38271" + integrity sha512-qNH55fWbKrEsCwID+Qc/3JDPnsSGpIIiMDbppnR8Z6PxLAqMQCFNqBctkIkBrMH49Nx+qqVTrHRWUR+ho2k+qQ== + dependencies: + commander "^2.8.1" + convert-source-map "^1.1.0" + fs-readdir-recursive "^1.1.0" + glob "^7.0.0" + lodash "^4.17.11" + mkdirp "^0.5.1" + output-file-sync "^2.0.0" + slash "^2.0.0" + source-map "^0.5.0" + optionalDependencies: + chokidar "^2.0.4" + "@babel/code-frame@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" @@ -686,6 +703,11 @@ lodash "^4.17.11" to-fast-properties "^2.0.0" +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== + ajv@^6.5.4: version "6.10.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" @@ -696,6 +718,16 @@ ajv@^6.5.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -703,6 +735,47 @@ ansi-styles@^3.2.1: dependencies: color-convert "^1.9.0" +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== + +are-we-there-yet@~1.1.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" + integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w== + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= + asn1@^0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" @@ -710,6 +783,21 @@ asn1@^0.2.3: dependencies: safer-buffer "~2.1.0" +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= + +async-each@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf" + integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ== + +atob@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + babel-plugin-dynamic-import-node@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz#f00f507bdaa3c3e3ff6e7e5e98d90a7acab96f7f" @@ -717,11 +805,58 @@ babel-plugin-dynamic-import-node@^2.3.0: dependencies: object.assign "^4.1.0" +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +binary-extensions@^1.0.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65" + integrity sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw== + bn.js@^4.11.4: version "4.11.8" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^2.3.1, braces@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + browserslist@^4.6.0, browserslist@^4.6.2: version "4.6.6" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.6.6.tgz#6e4bf467cde520bc9dbdf3747dafa03531cec453" @@ -741,6 +876,21 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + caniuse-lite@^1.0.30000984: version "1.0.30000984" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000984.tgz#dc96c3c469e9bcfc6ad5bdd24c77ec918ea76fe0" @@ -755,6 +905,53 @@ chalk@^2.0.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chokidar@^2.0.4: + version "2.1.6" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.6.tgz#b6cad653a929e244ce8a834244164d241fa954c5" + integrity sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.2.1" + upath "^1.1.1" + optionalDependencies: + fsevents "^1.2.7" + +chownr@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.2.tgz#a18f1e0b269c8a6a5d3c86eb298beb14c3dd7bf6" + integrity sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A== + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -777,11 +974,41 @@ commander@2.3.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" integrity sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM= +commander@^2.8.1: + version "2.20.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" + integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== + commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= +component-emitter@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +concat-stream@^1.4.7: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= + convert-source-map@^1.1.0: version "1.6.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" @@ -789,6 +1016,11 @@ convert-source-map@^1.1.0: dependencies: safe-buffer "~5.1.1" +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= + core-js-compat@^3.1.1: version "3.1.4" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.1.4.tgz#e4d0c40fbd01e65b1d457980fe4112d4358a7408" @@ -808,6 +1040,20 @@ core-js@^3.0.0: resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.1.4.tgz#3a2837fc48e582e1ae25907afcd6cf03b0cc7a07" integrity sha512-YNZN8lt82XIMLnLirj9MhKDFZHalwzzrL9YLt6eb0T5D0EDl4IQ90IGkua8mHbnxNrkj1d8hbdizMc0Qmg1WnQ== +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + +cross-spawn@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= + dependencies: + lru-cache "^4.0.1" + shebang-command "^1.2.0" + which "^1.2.9" + debug@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -815,7 +1061,14 @@ debug@2.2.0: dependencies: ms "0.7.1" -debug@^3.1.0: +debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@^3.1.0, debug@^3.2.6: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== @@ -829,6 +1082,16 @@ debug@^4.1.0: dependencies: ms "^2.1.1" +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + define-properties@^1.1.2: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -836,6 +1099,38 @@ define-properties@^1.1.2: dependencies: object-keys "^1.0.12" +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= + +detect-libc@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= + diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" @@ -861,6 +1156,48 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" @@ -871,6 +1208,16 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + find-cache-dir@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" @@ -887,11 +1234,75 @@ find-up@^3.0.0: dependencies: locate-path "^3.0.0" +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= + dependencies: + map-cache "^0.2.2" + +fs-minipass@^1.2.5: + version "1.2.6" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.6.tgz#2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07" + integrity sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ== + dependencies: + minipass "^2.2.1" + +fs-readdir-recursive@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" + integrity sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@^1.2.7: + version "1.2.9" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.9.tgz#3f5ed66583ccd6f400b5a00db6f7e861363e388f" + integrity sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw== + dependencies: + nan "^2.12.1" + node-pre-gyp "^0.12.0" + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= + +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" + integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + glob@3.2.11: version "3.2.11" resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" @@ -900,11 +1311,28 @@ glob@3.2.11: inherits "2" minimatch "0.3" +glob@^7.0.0, glob@^7.1.3: + version "7.1.4" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" + integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + globals@^11.1.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== +graceful-fs@^4.1.11: + version "4.2.0" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b" + integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg== + growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" @@ -920,11 +1348,74 @@ has-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= -inherits@2, inherits@^2.0.3: +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +iconv-lite@^0.4.4: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ignore-walk@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" + integrity sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ== + dependencies: + minimatch "^3.0.4" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.3, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== +ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + invariant@^2.2.2: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -932,6 +1423,153 @@ invariant@^2.2.2: dependencies: loose-envify "^1.0.0" +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + integrity sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg= + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.0, is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= + dependencies: + is-extglob "^2.1.0" + +is-glob@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= + dependencies: + kind-of "^3.0.2" + +is-plain-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= + +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + jade@0.26.3: version "0.26.3" resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" @@ -977,6 +1615,30 @@ jwt-simple@^0.5.0: resolved "https://registry.yarnpkg.com/jwt-simple/-/jwt-simple-0.5.6.tgz#3357adec55b26547114157be66748995b75b333a" integrity sha512-40aUybvhH9t2h71ncA1/1SbtTNCVZHgsTsTgqPUxGWDmUDrXyDf2wMNQKEbdBjbf4AI+fQhbECNTV6lWxQKUzg== +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" + integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -1017,6 +1679,14 @@ lru-cache@2: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" integrity sha1-bUUk6LlV+V1PW1iFHOId1y+06VI= +lru-cache@^4.0.1: + version "4.1.5" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" + integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + macaddress@^0.2.9: version "0.2.9" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.9.tgz#3579b8b9acd5b96b4553abf0f394185a86813cb3" @@ -1030,6 +1700,37 @@ make-dir@^2.0.0: pify "^4.0.1" semver "^5.6.0" +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= + dependencies: + object-visit "^1.0.0" + +micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + minimatch@0.3: version "0.3.0" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" @@ -1038,6 +1739,13 @@ minimatch@0.3: lru-cache "2" sigmund "~1.0.0" +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -1048,12 +1756,35 @@ minimist@^1.2.0: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= +minipass@^2.2.1, minipass@^2.3.5: + version "2.3.5" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" + integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA== + dependencies: + safe-buffer "^5.1.2" + yallist "^3.0.0" + +minizlib@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614" + integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA== + dependencies: + minipass "^2.2.1" + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + mkdirp@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" integrity sha1-G79asbqCevI1dRQ0kEJkVfSB/h4= -mkdirp@0.5.1, mkdirp@^0.5.1: +mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= @@ -1081,16 +1812,68 @@ ms@0.7.1: resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" integrity sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg= +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +nan@^2.12.1: + version "2.14.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" + integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +needle@^2.2.1: + version "2.4.0" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.4.0.tgz#6833e74975c444642590e15a750288c5f939b57c" + integrity sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg== + dependencies: + debug "^3.2.6" + iconv-lite "^0.4.4" + sax "^1.2.4" + node-modules-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= +node-pre-gyp@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz#39ba4bb1439da030295f899e3b520b7785766149" + integrity sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A== + dependencies: + detect-libc "^1.0.2" + mkdirp "^0.5.1" + needle "^2.2.1" + nopt "^4.0.1" + npm-packlist "^1.1.6" + npmlog "^4.0.2" + rc "^1.2.7" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^4" + node-releases@^1.1.25: version "1.1.25" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.25.tgz#0c2d7dbc7fed30fbe02a9ee3007b8c90bf0133d3" @@ -1098,11 +1881,80 @@ node-releases@^1.1.25: dependencies: semver "^5.3.0" +nopt@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00= + dependencies: + abbrev "1" + osenv "^0.1.4" + +normalize-path@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= + dependencies: + remove-trailing-separator "^1.0.1" + +normalize-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +npm-bundled@^1.0.1: + version "1.0.6" + resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd" + integrity sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g== + +npm-packlist@^1.1.6: + version "1.4.4" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.4.tgz#866224233850ac534b63d1a6e76050092b5d2f44" + integrity sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw== + dependencies: + ignore-walk "^3.0.1" + npm-bundled "^1.0.1" + +npmlog@^4.0.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= + +object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + object-keys@^1.0.11, object-keys@^1.0.12: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= + dependencies: + isobject "^3.0.0" + object.assign@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" @@ -1113,6 +1965,52 @@ object.assign@^4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= + dependencies: + isobject "^3.0.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= + +os-shim@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917" + integrity sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc= + +os-tmpdir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + +osenv@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" + integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +output-file-sync@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-2.0.1.tgz#f53118282f5f553c2799541792b723a4c71430c0" + integrity sha512-mDho4qm7WgIXIGf4eYU1RHN2UU5tPfVYVSRwDJw0uTmj35DQUt/eNp19N7v6T3SrR0ESTEf2up2CGO73qI35zQ== + dependencies: + graceful-fs "^4.1.11" + is-plain-obj "^1.1.0" + mkdirp "^0.5.1" + p-limit@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" @@ -1132,11 +2030,26 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= + +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= + path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" @@ -1161,6 +2074,20 @@ pkg-dir@^3.0.0: dependencies: find-up "^3.0.0" +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= + +pre-commit@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/pre-commit/-/pre-commit-1.2.2.tgz#dbcee0ee9de7235e57f79c56d7ce94641a69eec6" + integrity sha1-287g7p3nI15X95xW186UZBpp7sY= + dependencies: + cross-spawn "^5.0.1" + spawn-sync "^1.0.15" + which "1.2.x" + prismarine-nbt@^1.0.0: version "1.2.1" resolved "https://registry.yarnpkg.com/prismarine-nbt/-/prismarine-nbt-1.2.1.tgz#4b0e50e538a4676ee259ae0588120360ab39110d" @@ -1173,6 +2100,11 @@ private@^0.1.6: resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + protodef-validator@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/protodef-validator/-/protodef-validator-1.2.2.tgz#68fae789170e60c5a0a72686f56daee8f791f659" @@ -1190,6 +2122,11 @@ protodef@^1.2.1, protodef@^1.2.3, protodef@^1.6.6: protodef-validator "^1.2.2" readable-stream "^3.0.3" +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= + punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -1204,6 +2141,29 @@ punycode@^2.1.0: protodef "^1.6.6" split-buffer "^1.0.0" +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + readable-stream@^3.0.3: version "3.4.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc" @@ -1213,6 +2173,15 @@ readable-stream@^3.0.3: string_decoder "^1.1.1" util-deprecate "^1.0.1" +readdirp@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" + integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ== + dependencies: + graceful-fs "^4.1.11" + micromatch "^3.1.10" + readable-stream "^2.0.2" + regenerate-unicode-properties@^8.0.2: version "8.1.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" @@ -1232,6 +2201,14 @@ regenerator-transform@^0.14.0: dependencies: private "^0.1.6" +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + regexp-tree@^0.1.6: version "0.1.11" resolved "https://registry.yarnpkg.com/regexp-tree/-/regexp-tree-0.1.11.tgz#c9c7f00fcf722e0a56c7390983a7a63dd6c272f3" @@ -1261,6 +2238,26 @@ regjsparser@^0.6.0: dependencies: jsesc "~0.5.0" +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= + +repeat-element@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" + integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= + resolve@^1.3.2: version "1.11.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" @@ -1268,16 +2265,45 @@ resolve@^1.3.2: dependencies: path-parse "^1.0.6" +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +rimraf@^2.6.1: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + +safe-buffer@^5.1.2: + version "5.2.0" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" + integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== + safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safer-buffer@~2.1.0: +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3", safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== +sax@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== + semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: version "5.7.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" @@ -1288,11 +2314,89 @@ semver@^6.1.1: resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db" integrity sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A== +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + sigmund@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA= +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= + +slash@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" + integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +source-map-resolve@^0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259" + integrity sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA== + dependencies: + atob "^2.1.1" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + source-map-support@^0.5.9: version "0.5.12" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" @@ -1301,7 +2405,12 @@ source-map-support@^0.5.9: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.5.0: +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= + +source-map@^0.5.0, source-map@^0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= @@ -1311,11 +2420,51 @@ source-map@^0.6.0: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +spawn-sync@^1.0.15: + version "1.0.15" + resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476" + integrity sha1-sAeZVX63+wyDdsKdROih6mfldHY= + dependencies: + concat-stream "^1.4.7" + os-shim "^0.1.2" + split-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/split-buffer/-/split-buffer-1.0.0.tgz#b7e8e0ab51345158b72c1f6dbef2406d51f1d027" integrity sha1-t+jgq1E0UVi3LB9tvvJAbVHx0Cc= +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2": + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + string_decoder@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.2.0.tgz#fe86e738b19544afe70469243b2a1ee9240eae8d" @@ -1323,6 +2472,32 @@ string_decoder@^1.1.1: dependencies: safe-buffer "~5.1.0" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= + dependencies: + ansi-regex "^3.0.0" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + supports-color@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" @@ -1335,6 +2510,19 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +tar@^4: + version "4.4.10" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.10.tgz#946b2810b9a5e0b26140cf78bea6b0b0d689eba1" + integrity sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA== + dependencies: + chownr "^1.1.1" + fs-minipass "^1.2.5" + minipass "^2.3.5" + minizlib "^1.2.1" + mkdirp "^0.5.0" + safe-buffer "^5.1.2" + yallist "^3.0.3" + to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" @@ -1345,11 +2533,41 @@ to-iso-string@0.0.2: resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" integrity sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE= +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= + unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" @@ -1373,6 +2591,29 @@ unicode-property-aliases-ecmascript@^1.0.4: resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz#a9cc6cc7ce63a0a3023fc99e341b94431d405a57" integrity sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw== +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +upath@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068" + integrity sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q== + uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" @@ -1380,7 +2621,17 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -util-deprecate@^1.0.1: +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -1391,3 +2642,39 @@ uuid-1345@^0.99.6: integrity sha512-A70cwvqH95zULri1/t00/r6Bd97hKpNvS9SoSLP9Bupn95sX/01JkOuH9YjJrmNul7ZAjyX3Y3ZMlDrCjuoNPQ== dependencies: macaddress "^0.2.9" + +which@1.2.x: + version "1.2.14" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" + integrity sha1-mofEN48D6CfOyvGs31bHNsAcFOU= + dependencies: + isexe "^2.0.0" + +which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +wide-align@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= + +yallist@^3.0.0, yallist@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" + integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A== From 902a57c7229de6221ad20c550d50b06e270b5bea Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 29 Jan 2021 00:50:26 -0500 Subject: [PATCH 074/106] working server --- data/newproto.json | 4707 ++++++++++++++++++++++++++++++++++ package.json | 15 +- src/BatchPacket.js | 86 + src/auth/constants.js | 4 + src/auth/encrypt.js | 232 ++ src/auth/encryptTest.js | 88 + src/auth/encryption.js | 102 + src/auth/jwt.js | 104 + src/auth/jwtTest.js | 49 + src/serverTest.js | 226 ++ src/transforms/encryption.js | 108 + 11 files changed, 5716 insertions(+), 5 deletions(-) create mode 100644 data/newproto.json create mode 100644 src/BatchPacket.js create mode 100644 src/auth/constants.js create mode 100644 src/auth/encrypt.js create mode 100644 src/auth/encryptTest.js create mode 100644 src/auth/encryption.js create mode 100644 src/auth/jwt.js create mode 100644 src/auth/jwtTest.js create mode 100644 src/serverTest.js create mode 100644 src/transforms/encryption.js diff --git a/data/newproto.json b/data/newproto.json new file mode 100644 index 0000000..ae404a4 --- /dev/null +++ b/data/newproto.json @@ -0,0 +1,4707 @@ +{ + "types": { + "string": [ + "pstring", + { + "countType": "varint" + } + ], + "ByteArray": [ + "buffer", + { + "countType": "varint" + } + ], + "varint32": "varint", + "varint64": "varint", + "bool": "i8", + "zigzag32": "native", + "zigzag64": "native", + "uuid": "native", + "byterot": "native", + "MapInfo": "native", + "nbt": "native", + "BehaviourPackInfos": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "size", + "type": "lu64" + }, + { + "name": "content_key", + "type": "string" + }, + { + "name": "sub_pack_name", + "type": "string" + }, + { + "name": "content_identity", + "type": "string" + }, + { + "name": "has_scripts", + "type": "bool" + } + ] + ], + "TexturePackInfos": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "size", + "type": "lu64" + }, + { + "name": "content_key", + "type": "string" + }, + { + "name": "sub_pack_name", + "type": "string" + }, + { + "name": "content_identity", + "type": "string" + }, + { + "name": "has_scripts", + "type": "bool" + }, + { + "name": "rtx_enabled", + "type": "bool" + } + ] + ], + "ResourcePackIdVersions": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "name", + "type": "string" + } + ] + ], + "ResourcePackIds": [ + "array", + { + "countType": "varint", + "type": "string" + } + ], + "Experiment": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "enabled", + "type": "bool" + } + ] + ], + "Experiments": [ + "array", + { + "countType": "varint", + "type": "Experiment" + } + ], + "GameRule": [ + "container", + [ + { + "name": "name", + "type": "varint" + }, + { + "name": "type", + "type": "varint" + }, + { + "name": "value", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "1": "bool", + "2": "varint", + "3": "lf32" + } + } + ] + } + ] + ], + "GameRules": [ + "array", + { + "countType": "varint", + "type": "GameRule" + } + ], + "BlockPalette": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "state", + "type": "nbt" + } + ] + ] + } + ], + "Itemstates": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "runtime_id", + "type": "i16" + }, + { + "name": "component_based", + "type": "bool" + } + ] + ] + } + ], + "Item": [ + "container", + [ + { + "name": "network_id", + "type": "zigzag32" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "network_id", + "fields": { + "0": "void" + }, + "default": [ + "container", + [ + { + "name": "auxiliary_value", + "type": "zigzag32" + }, + { + "name": "user_data_marker", + "type": "li16" + }, + { + "name": "nbt", + "type": "nbt" + } + ] + ] + } + ] + } + ] + ], + "vec3i": [ + "container", + [ + { + "name": "x", + "type": "zigzag32" + }, + { + "name": "y", + "type": "zigzag32" + }, + { + "name": "z", + "type": "zigzag32" + } + ] + ], + "vec3u": [ + "container", + [ + { + "name": "x", + "type": "varint" + }, + { + "name": "y", + "type": "varint" + }, + { + "name": "z", + "type": "varint" + } + ] + ], + "vec3f": [ + "container", + [ + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + } + ] + ], + "vec2f": [ + "container", + [ + { + "name": "x", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + } + ] + ], + "MetadataDictionary": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "key", + "type": "varint" + }, + { + "name": "type", + "type": "varint" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "0": [ + "container", + [ + { + "name": "value", + "type": "i8" + } + ] + ], + "1": [ + "container", + [ + { + "name": "value", + "type": "li16" + } + ] + ], + "2": [ + "container", + [ + { + "name": "value", + "type": "zigzag32" + } + ] + ], + "3": [ + "container", + [ + { + "name": "value", + "type": "lf32" + } + ] + ], + "4": [ + "container", + [ + { + "name": "value", + "type": "string" + } + ] + ], + "5": [ + "container", + [ + { + "name": "value", + "type": "nbt" + } + ] + ], + "6": [ + "container", + [ + { + "name": "value", + "type": "vec3i" + } + ] + ], + "7": [ + "container", + [ + { + "name": "value", + "type": "zigzag64" + } + ] + ], + "8": [ + "container", + [ + { + "name": "value", + "type": "li32" + } + ] + ] + } + } + ] + } + ] + ] + } + ], + "Links": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "ridden_entity_id", + "type": "zigzag64" + }, + { + "name": "rider_entity_id", + "type": "zigzag64" + }, + { + "name": "type", + "type": "u8" + }, + { + "name": "immediate", + "type": "bool" + }, + { + "name": "rider_initiated", + "type": "bool" + } + ] + ] + } + ], + "EntityAttributes": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "min", + "type": "lf32" + }, + { + "name": "value", + "type": "lf32" + }, + { + "name": "max", + "type": "lf32" + } + ] + ] + } + ], + "Rotation": [ + "container", + [ + { + "name": "yaw", + "type": "byterot" + }, + { + "name": "pitch", + "type": "byterot" + }, + { + "name": "head_yaw", + "type": "byterot" + } + ] + ], + "BlockCoordinates": [ + "container", + [ + { + "name": "x", + "type": "zigzag32" + }, + { + "name": "y", + "type": "varint" + }, + { + "name": "z", + "type": "zigzag32" + } + ] + ], + "PlayerAttributes": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "min", + "type": "lf32" + }, + { + "name": "max", + "type": "lf32" + }, + { + "name": "current", + "type": "lf32" + }, + { + "name": "default", + "type": "lf32" + }, + { + "name": "name", + "type": "string" + } + ] + ] + } + ], + "Transaction": [ + "container", + [ + { + "name": "legacy_request_id", + "type": "zigzag32" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "legacy_request_id", + "fields": { + "0": "void" + }, + "default": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "container_id", + "type": "u8" + }, + { + "name": "changed_slots", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "slot_id", + "type": "u8" + } + ] + ] + } + ] + } + ] + ] + } + ] + } + ] + }, + { + "name": "transaction_type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "TYPE_NORMAL", + "1": "TYPE_INVENTORY_MISMATCH", + "2": "TYPE_ITEM_USE", + "3": "TYPE_ITEM_USE_ON_ENTITY", + "4": "TYPE_ITEM_RELEASE" + } + } + ] + }, + { + "name": "has_network_ids", + "type": "bool" + }, + { + "name": "inventory_actions", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "source_type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "INV_SOURCE_TYPE_CONTAINER", + "1": "INV_SOURCE_TYPE_GLOBAL", + "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", + "3": "INV_SOURCE_TYPE_CREATIVE", + "100": "INV_SOURCE_TYPE_CRAFT_SLOT", + "99999": "INV_SOURCE_TYPE_CRAFT" + } + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "source_type", + "fields": { + "INV_SOURCE_TYPE_CONTAINER": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_WORLD_INTERACTION": [ + "container", + [ + { + "name": "flags", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CREATIVE": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT_SLOT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ] + } + } + ] + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "old_item", + "type": "Item" + }, + { + "name": "new_item", + "type": "Item" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "has_network_ids", + "fields": { + "true": [ + "container", + [ + { + "name": "new_item_stack_id", + "type": "zigzag32" + } + ] + ], + "false": "void" + } + } + ] + } + ] + ] + } + ] + }, + { + "name": "transactionMap", + "type": [ + "switch", + { + "compareTo": "transaction_type", + "fields": { + "TYPE_NORMAL": "void", + "TYPE_INVENTORY_MISMATCH": "void", + "TYPE_USE_ITEM": [ + "container", + [ + { + "name": "action_type", + "type": "varint" + }, + { + "name": "face", + "type": "varint" + }, + { + "name": "hotbar_slot", + "type": "varint" + }, + { + "name": "item_in_hand", + "type": "Item" + }, + { + "name": "player_pos", + "type": "vec3f" + }, + { + "name": "click_pos", + "type": "vec3f" + }, + { + "name": "block_runtime_id", + "type": "varint" + } + ] + ], + "TYPE_ITEM_USE_ON_ENTITY": [ + "container", + [ + { + "name": "entity_runtime_id", + "type": "varint64" + }, + { + "name": "action_type", + "type": "varint" + }, + { + "name": "hotbar_slot", + "type": "zigzag32" + }, + { + "name": "item_in_hand", + "type": "Item" + }, + { + "name": "player_pos", + "type": "vec3f" + }, + { + "name": "click_pos", + "type": "vec3f" + } + ] + ], + "TYPE_ITEM_RELEASE": [ + "container", + [ + { + "name": "action_type", + "type": "varint" + }, + { + "name": "hotbar_slot", + "type": "zigzag32" + }, + { + "name": "item_in_hand", + "type": "Item" + }, + { + "name": "head_pos", + "type": "vec3f" + } + ] + ] + } + } + ] + } + ] + ], + "ItemStacks": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "network_id", + "type": "zigzag32" + }, + { + "name": "item", + "type": "Item" + } + ] + ] + } + ], + "RecipeIngredient": [ + "container", + [ + { + "name": "network_id", + "type": "zigzag32" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "network_id", + "fields": { + "0": "void" + }, + "default": [ + "container", + [ + { + "name": "network_data", + "type": "zigzag32" + }, + { + "name": "count", + "type": "zigzag32" + } + ] + ] + } + ] + } + ] + ], + "PotionTypeRecipes": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "input_item_id", + "type": "zigzag32" + }, + { + "name": "input_item_meta", + "type": "zigzag32" + }, + { + "name": "ingredient_id", + "type": "zigzag32" + }, + { + "name": "ingredient_meta", + "type": "zigzag32" + }, + { + "name": "output_item_id", + "type": "zigzag32" + }, + { + "name": "output_item_meta", + "type": "zigzag32" + } + ] + ] + } + ], + "PotionContainerChangeRecipes": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "input_item_id", + "type": "zigzag32" + }, + { + "name": "ingredient_id", + "type": "zigzag32" + }, + { + "name": "output_item_id", + "type": "zigzag32" + } + ] + ] + } + ], + "Recipes": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "shapeless", + "1": "shaped", + "2": "furnace", + "3": "furnace_with_metadata", + "4": "multi", + "5": "shapeless", + "6": "shapeless", + "7": "shaped" + } + } + ] + }, + { + "name": "recipe", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "shapeless": [ + "container", + [ + { + "name": "recipe_id", + "type": "string" + }, + { + "name": "input", + "type": [ + "array", + { + "countType": "varint", + "type": "RecipeIngredient" + } + ] + }, + { + "name": "output", + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] + }, + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "block", + "type": "string" + }, + { + "name": "priority", + "type": "zigzag32" + }, + { + "name": "network_id", + "type": "zigzag32" + } + ] + ], + "shaped": [ + "container", + [ + { + "name": "recipe_id", + "type": "string" + }, + { + "name": "width", + "type": "zigzag32" + }, + { + "name": "height", + "type": "zigzag32" + }, + { + "name": "input", + "type": [ + "array", + { + "count": "width", + "type": [ + "array", + { + "count": "height", + "type": "RecipeIngredient" + } + ] + } + ] + }, + { + "name": "output", + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] + }, + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "block", + "type": "string" + }, + { + "name": "priority", + "type": "zigzag32" + }, + { + "name": "network_id", + "type": "zigzag32" + } + ] + ], + "furnace": [ + "container", + [ + { + "name": "input_id", + "type": "zigzag32" + }, + { + "name": "output", + "type": "Item" + }, + { + "name": "block", + "type": "string" + } + ] + ], + "furnace_with_metadata": [ + "container", + [ + { + "name": "input_id", + "type": "zigzag32" + }, + { + "name": "input_meta", + "type": "zigzag32" + }, + { + "name": "output", + "type": "Item" + }, + { + "name": "block", + "type": "string" + } + ] + ], + "multi": [ + "container", + [ + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "network_id", + "type": "zigzag32" + } + ] + ] + } + } + ] + } + ] + ] + } + ], + "SkinImage": [ + "container", + [ + { + "name": "width", + "type": "li32" + }, + { + "name": "height", + "type": "li32" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "Skin": [ + "container", + [ + { + "name": "skin_id", + "type": "string" + }, + { + "name": "skin_resource_pach", + "type": "string" + }, + { + "name": "skin_data", + "type": "SkinImage" + }, + { + "name": "animations", + "type": [ + "array", + { + "countType": "li32", + "type": [ + "container", + [ + { + "name": "skin_image", + "type": "SkinImage" + }, + { + "name": "animation_type", + "type": "li32" + }, + { + "name": "animation_frames", + "type": "lf32" + }, + { + "name": "expression_type", + "type": "lf32" + } + ] + ] + } + ] + }, + { + "name": "cape_data", + "type": "SkinImage" + }, + { + "name": "geometry_data", + "type": "string" + }, + { + "name": "animation_data", + "type": "string" + }, + { + "name": "premium", + "type": "string" + }, + { + "name": "persona", + "type": "bool" + }, + { + "name": "cape_on_classic", + "type": "bool" + }, + { + "name": "cape_id", + "type": "string" + }, + { + "name": "full_skin_id", + "type": "string" + }, + { + "name": "arm_size", + "type": "string" + }, + { + "name": "skin_color", + "type": "string" + }, + { + "name": "personal_pieces", + "type": [ + "array", + { + "countType": "li32", + "type": [ + "container", + [ + { + "name": "piece_id", + "type": "string" + }, + { + "name": "piece_type", + "type": "string" + }, + { + "name": "pack_id", + "type": "string" + }, + { + "name": "is_default_piece", + "type": "bool" + }, + { + "name": "product_id", + "type": "string" + } + ] + ] + } + ] + }, + { + "name": "piece_tint_colors", + "type": [ + "array", + { + "countType": "li32", + "type": [ + "container", + [ + { + "name": "piece_type", + "type": "string" + }, + { + "name": "colors", + "type": [ + "array", + { + "countType": "li32", + "type": "string" + } + ] + } + ] + ] + } + ] + } + ] + ], + "PlayerRecords": [ + "container", + [ + { + "name": "type", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "add", + "1": "remove" + } + } + ] + }, + { + "name": "records_count", + "type": "varint" + }, + { + "name": "records", + "type": [ + "array", + { + "count": "records_count", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "add": [ + "container", + [ + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "entity_unique_id", + "type": "zigzag64" + }, + { + "name": "username", + "type": "string" + }, + { + "name": "xbox_user_id", + "type": "string" + }, + { + "name": "platform_chat_id", + "type": "string" + }, + { + "name": "build_platform", + "type": "li32" + }, + { + "name": "skin_data", + "type": "Skin" + }, + { + "name": "is_teacher", + "type": "bool" + }, + { + "name": "is_host", + "type": "bool" + } + ] + ], + "remove": [ + "container", + [ + { + "name": "uuid", + "type": "uuid" + } + ] + ] + } + } + ] + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "add": [ + "container", + [ + { + "name": "uuid", + "type": "uuid" + } + ] + ] + } + } + ] + }, + { + "name": "verified", + "type": [ + "array", + { + "count": "records_count", + "type": "bool" + } + ] + } + ] + ], + "ScoreEntries": [ + "container", + [ + { + "name": "type", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "change", + "1": "remove" + } + } + ] + }, + { + "name": "entries", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "scoreboard_id", + "type": "li64" + }, + { + "name": "objective_name", + "type": "string" + }, + { + "name": "score", + "type": "li32" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "remove": [ + "container", + [ + { + "name": "entry_type", + "type": [ + "mapper", + { + "type": "i8", + "mappings": { + "1": "player", + "2": "entity", + "3": "fake_player" + } + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "entry_type", + "fields": { + "player": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" + } + ] + ], + "entity": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" + } + ] + ], + "fake_player": [ + "container", + [ + { + "name": "custom_name", + "type": "string" + } + ] + ] + } + } + ] + } + ] + ], + "change": "void" + } + } + ] + } + ] + ] + } + ] + } + ] + ], + "ScoreboardIdentityEntries": [ + "container", + [ + { + "name": "type", + "type": [ + "mapper", + { + "type": "i8", + "mappings": { + "0": "TYPE_REGISTER_IDENTITY", + "1": "TYPE_CLEAR_IDENTITY" + } + } + ] + }, + { + "name": "entries", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "scoreboard_id", + "type": "zigzag64" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "TYPE_REGISTER_IDENTITY": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" + } + ] + ] + }, + "default": "void" + } + ] + } + ] + ] + } + ] + } + ] + ], + "Enchant": [ + "container", + [ + { + "name": "id", + "type": "u8" + }, + { + "name": "level", + "type": "u8" + } + ] + ], + "EnchantOptions": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "cost", + "type": "varint" + }, + { + "name": "slot_flags", + "type": "li32" + }, + { + "name": "equip_enchants", + "type": [ + "array", + { + "countType": "varint", + "type": "Enchant" + } + ] + }, + { + "name": "held_enchants", + "type": [ + "array", + { + "countType": "varint", + "type": "Enchant" + } + ] + }, + { + "name": "self_enchants", + "type": [ + "array", + { + "countType": "varint", + "type": "Enchant" + } + ] + }, + { + "name": "name", + "type": "string" + }, + { + "name": "option_id", + "type": "zigzag32" + } + ] + ] + } + ], + "StackRequestSlotInfo": [ + "container", + [ + { + "name": "container_id", + "type": "u8" + }, + { + "name": "slot_id", + "type": "u8" + }, + { + "name": "stack_id", + "type": "zigzag32" + } + ] + ], + "ItemStackRequests": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "request_id", + "type": "zigzag32" + }, + { + "name": "actions", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "type_id", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "TAKE", + "1": "PLACE", + "2": "SWAP", + "3": "DROP", + "4": "DESTROY", + "5": "CRAFTING_CONSUME_INPUT", + "6": "create", + "7": "LAB_TABLE_COMBINE", + "8": "BEACON_PAYMENT", + "9": "CRAFTING_RECIPE", + "10": "CRAFTING_RECIPE_AUTO", + "11": "CREATIVE_CREATE", + "12": "CRAFTING_NON_IMPLEMENTED_DEPRECATED", + "13": "CRAFTING_RESULTS_DEPRECATED" + } + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type_id", + "fields": { + "TAKE": [ + "container", + [ + { + "name": "count", + "type": "u8" + }, + { + "name": "source", + "type": "StackRequestSlotInfo" + }, + { + "name": "destination", + "type": "StackRequestSlotInfo" + } + ] + ], + "PLACE": [ + "container", + [ + { + "name": "count", + "type": "u8" + }, + { + "name": "source", + "type": "StackRequestSlotInfo" + }, + { + "name": "destination", + "type": "StackRequestSlotInfo" + } + ] + ], + "SWAP": [ + "container", + [ + { + "name": "source", + "type": "StackRequestSlotInfo" + }, + { + "name": "destination", + "type": "StackRequestSlotInfo" + } + ] + ], + "DROP": [ + "container", + [ + { + "name": "count", + "type": "u8" + }, + { + "name": "source", + "type": "StackRequestSlotInfo" + }, + { + "name": "randomly", + "type": "bool" + } + ] + ], + "DESTROY": [ + "container", + [ + { + "name": "count", + "type": "u8" + }, + { + "name": "source", + "type": "StackRequestSlotInfo" + } + ] + ], + "CRAFTING_CONSUME_INPUT": [ + "container", + [ + { + "name": "count", + "type": "u8" + }, + { + "name": "source", + "type": "StackRequestSlotInfo" + } + ] + ], + "create": [ + "container", + [ + { + "name": "result_slot_id", + "type": "u8" + } + ] + ], + "BEACON_PAYMENT": [ + "container", + [ + { + "name": "primary_effect", + "type": "varint" + }, + { + "name": "secondary_effect", + "type": "varint" + } + ] + ], + "CRAFTING_RECIPE": [ + "container", + [ + { + "name": "recipe_network_id", + "type": "varint32" + } + ] + ], + "CRAFTING_RECIPE_AUTO": [ + "container", + [ + { + "name": "recipe_network_id", + "type": "varint32" + } + ] + ], + "CREATIVE_CREATE": [ + "container", + [ + { + "name": "creative_item_network_id", + "type": "varint32" + } + ] + ], + "CRAFTING_NON_IMPLEMENTED_DEPRECATED": "void", + "CRAFTING_RESULTS_DEPRECATED": [ + "container", + [ + { + "name": "result_items", + "type": "ItemStacks" + }, + { + "name": "times_crafted", + "type": "u8" + } + ] + ] + } + } + ] + } + ] + ] + } + ] + } + ] + ] + } + ], + "ItemStackResponses": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "result", + "type": "u8" + }, + { + "name": "request_id", + "type": "varint32" + }, + { + "name": "containers", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "container_id", + "type": "u8" + }, + { + "name": "slots", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "slot", + "type": "u8" + }, + { + "name": "hotbar_slot", + "type": "u8" + }, + { + "name": "count", + "type": "u8" + }, + { + "name": "item_stack_id", + "type": "varint32" + }, + { + "name": "custom_name", + "type": "string" + } + ] + ] + } + ] + } + ] + ] + } + ] + } + ] + ] + } + ], + "ItemComponentList": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "nbt", + "type": "nbt" + } + ] + ] + } + ], + "mcpe_packet": [ + "container", + [ + { + "name": "name", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0x01": "login", + "0x02": "play_status", + "0x03": "server_to_client_handshake", + "0x04": "client_to_server_handshake", + "0x05": "disconnect", + "0x06": "resource_packs_info", + "0x07": "resource_pack_stack", + "0x08": "resource_pack_client_response", + "0x09": "text", + "0x0a": "set_time", + "0x0b": "start_game", + "0x0c": "add_player", + "0x0d": "add_entity", + "0x0e": "remove_entity", + "0x0f": "add_item_entity", + "0x11": "take_item_entity", + "0x12": "move_entity", + "0x13": "move_player", + "0x14": "rider_jump", + "0x15": "update_block", + "0x16": "add_painting", + "0x17": "tick_sync", + "0x18": "level_sound_event_old", + "0x19": "level_event", + "0x1a": "block_event", + "0x1b": "entity_event", + "0x1c": "mob_effect", + "0x1d": "update_attributes", + "0x1e": "inventory_transaction", + "0x1f": "mob_equipment", + "0x20": "mob_armor_equipment", + "0x21": "interact", + "0x22": "block_pick_request", + "0x23": "entity_pick_request", + "0x24": "player_action", + "0x26": "hurt_armor", + "0x27": "set_entity_data", + "0x28": "set_entity_motion", + "0x29": "set_entity_link", + "0x2a": "set_health", + "0x2b": "set_spawn_position", + "0x2c": "animate", + "0x2d": "respawn", + "0x2e": "container_open", + "0x2f": "container_close", + "0x30": "player_hotbar", + "0x31": "inventory_content", + "0x32": "inventory_slot", + "0x33": "container_set_data", + "0x34": "crafting_data", + "0x35": "crafting_event", + "0x36": "gui_data_pick_item", + "0x37": "adventure_settings", + "0x38": "block_entity_data", + "0x39": "player_input", + "0x3a": "level_chunk", + "0x3b": "set_commands_enabled", + "0x3c": "set_difficulty", + "0x3d": "change_dimension", + "0x3e": "set_player_game_type", + "0x3f": "player_list", + "0x40": "simple_event", + "0x42": "spawn_experience_orb", + "0x43": "clientbound_map_item_data_", + "0x44": "map_info_request", + "0x45": "request_chunk_radius", + "0x46": "chunk_radius_update", + "0x47": "item_frame_drop_item", + "0x48": "game_rules_changed", + "0x49": "camera", + "0x4a": "boss_event", + "0x4b": "show_credits", + "0x4c": "available_commands", + "0x4d": "command_request", + "0x4e": "command_block_update", + "0x4f": "command_output", + "0x50": "update_trade", + "0x51": "update_equipment", + "0x52": "resource_pack_data_info", + "0x53": "resource_pack_chunk_data", + "0x54": "resource_pack_chunk_request", + "0x55": "transfer", + "0x56": "play_sound", + "0x57": "stop_sound", + "0x58": "set_title", + "0x59": "add_behavior_tree", + "0x5a": "structure_block_update", + "0x5b": "show_store_offer", + "0x5c": "purchase_receipt", + "0x5d": "player_skin", + "0x5e": "sub_client_login", + "0x5f": "initiate_web_socket_connection", + "0x60": "set_last_hurt_by", + "0x61": "book_edit", + "0x62": "npc_request", + "0x63": "photo_transfer", + "0x64": "modal_form_request", + "0x65": "modal_form_response", + "0x66": "server_settings_request", + "0x67": "server_settings_response", + "0x68": "show_profile", + "0x69": "set_default_game_type", + "0x6a": "remove_objective", + "0x6b": "set_display_objective", + "0x6c": "set_score", + "0x6d": "lab_table", + "0x6e": "update_block_synced", + "0x6f": "move_entity_delta", + "0x70": "set_scoreboard_identity", + "0x71": "set_local_player_as_initialized", + "0x72": "update_soft_enum", + "0x73": "network_stack_latency", + "0x75": "script_custom_event", + "0x76": "spawn_particle_effect", + "0x77": "available_entity_identifiers", + "0x78": "level_sound_event_v2", + "0x79": "network_chunk_publisher_update", + "0x7a": "biome_definition_list", + "0x7b": "level_sound_event", + "0x7c": "level_event_generic", + "0x7d": "lectern_update", + "0x7e": "video_stream_connect", + "0x81": "client_cache_status", + "0x82": "on_screen_texture_animation", + "0x83": "map_create_locked_copy", + "0x84": "structure_template_data_export_request", + "0x85": "structure_template_data_export_response", + "0x86": "update_block_properties", + "0x87": "client_cache_blob_status", + "0x88": "client_cache_miss_response", + "0x8f": "network_settings", + "0x91": "creative_content", + "0x92": "player_enchant_options", + "0x93": "item_stack_request", + "0x94": "item_stack_response", + "0x97": "update_player_game_type", + "0x9c": "packet_violation_warning", + "0xa2": "item_component", + "0xa3": "filter_text_packet" + } + } + ] + }, + { + "name": "params", + "type": [ + "switch", + { + "compareTo": "name", + "fields": { + "login": "packet_login", + "play_status": "packet_play_status", + "server_to_client_handshake": "packet_server_to_client_handshake", + "client_to_server_handshake": "packet_client_to_server_handshake", + "disconnect": "packet_disconnect", + "resource_packs_info": "packet_resource_packs_info", + "resource_pack_stack": "packet_resource_pack_stack", + "resource_pack_client_response": "packet_resource_pack_client_response", + "text": "packet_text", + "set_time": "packet_set_time", + "start_game": "packet_start_game", + "add_player": "packet_add_player", + "add_entity": "packet_add_entity", + "remove_entity": "packet_remove_entity", + "add_item_entity": "packet_add_item_entity", + "take_item_entity": "packet_take_item_entity", + "move_entity": "packet_move_entity", + "move_player": "packet_move_player", + "rider_jump": "packet_rider_jump", + "update_block": "packet_update_block", + "add_painting": "packet_add_painting", + "tick_sync": "packet_tick_sync", + "level_sound_event_old": "packet_level_sound_event_old", + "level_event": "packet_level_event", + "block_event": "packet_block_event", + "entity_event": "packet_entity_event", + "mob_effect": "packet_mob_effect", + "update_attributes": "packet_update_attributes", + "inventory_transaction": "packet_inventory_transaction", + "mob_equipment": "packet_mob_equipment", + "mob_armor_equipment": "packet_mob_armor_equipment", + "interact": "packet_interact", + "block_pick_request": "packet_block_pick_request", + "entity_pick_request": "packet_entity_pick_request", + "player_action": "packet_player_action", + "hurt_armor": "packet_hurt_armor", + "set_entity_data": "packet_set_entity_data", + "set_entity_motion": "packet_set_entity_motion", + "set_entity_link": "packet_set_entity_link", + "set_health": "packet_set_health", + "set_spawn_position": "packet_set_spawn_position", + "animate": "packet_animate", + "respawn": "packet_respawn", + "container_open": "packet_container_open", + "container_close": "packet_container_close", + "player_hotbar": "packet_player_hotbar", + "inventory_content": "packet_inventory_content", + "inventory_slot": "packet_inventory_slot", + "container_set_data": "packet_container_set_data", + "crafting_data": "packet_crafting_data", + "crafting_event": "packet_crafting_event", + "gui_data_pick_item": "packet_gui_data_pick_item", + "adventure_settings": "packet_adventure_settings", + "block_entity_data": "packet_block_entity_data", + "player_input": "packet_player_input", + "level_chunk": "packet_level_chunk", + "set_commands_enabled": "packet_set_commands_enabled", + "set_difficulty": "packet_set_difficulty", + "change_dimension": "packet_change_dimension", + "set_player_game_type": "packet_set_player_game_type", + "player_list": "packet_player_list", + "simple_event": "packet_simple_event", + "spawn_experience_orb": "packet_spawn_experience_orb", + "clientbound_map_item_data_": "packet_clientbound_map_item_data_", + "map_info_request": "packet_map_info_request", + "request_chunk_radius": "packet_request_chunk_radius", + "chunk_radius_update": "packet_chunk_radius_update", + "item_frame_drop_item": "packet_item_frame_drop_item", + "game_rules_changed": "packet_game_rules_changed", + "camera": "packet_camera", + "boss_event": "packet_boss_event", + "show_credits": "packet_show_credits", + "available_commands": "packet_available_commands", + "command_request": "packet_command_request", + "command_block_update": "packet_command_block_update", + "command_output": "packet_command_output", + "update_trade": "packet_update_trade", + "update_equipment": "packet_update_equipment", + "resource_pack_data_info": "packet_resource_pack_data_info", + "resource_pack_chunk_data": "packet_resource_pack_chunk_data", + "resource_pack_chunk_request": "packet_resource_pack_chunk_request", + "transfer": "packet_transfer", + "play_sound": "packet_play_sound", + "stop_sound": "packet_stop_sound", + "set_title": "packet_set_title", + "add_behavior_tree": "packet_add_behavior_tree", + "structure_block_update": "packet_structure_block_update", + "show_store_offer": "packet_show_store_offer", + "purchase_receipt": "packet_purchase_receipt", + "player_skin": "packet_player_skin", + "sub_client_login": "packet_sub_client_login", + "initiate_web_socket_connection": "packet_initiate_web_socket_connection", + "set_last_hurt_by": "packet_set_last_hurt_by", + "book_edit": "packet_book_edit", + "npc_request": "packet_npc_request", + "photo_transfer": "packet_photo_transfer", + "modal_form_request": "packet_modal_form_request", + "modal_form_response": "packet_modal_form_response", + "server_settings_request": "packet_server_settings_request", + "server_settings_response": "packet_server_settings_response", + "show_profile": "packet_show_profile", + "set_default_game_type": "packet_set_default_game_type", + "remove_objective": "packet_remove_objective", + "set_display_objective": "packet_set_display_objective", + "set_score": "packet_set_score", + "lab_table": "packet_lab_table", + "update_block_synced": "packet_update_block_synced", + "move_entity_delta": "packet_move_entity_delta", + "set_scoreboard_identity": "packet_set_scoreboard_identity", + "set_local_player_as_initialized": "packet_set_local_player_as_initialized", + "update_soft_enum": "packet_update_soft_enum", + "network_stack_latency": "packet_network_stack_latency", + "script_custom_event": "packet_script_custom_event", + "spawn_particle_effect": "packet_spawn_particle_effect", + "available_entity_identifiers": "packet_available_entity_identifiers", + "level_sound_event_v2": "packet_level_sound_event_v2", + "network_chunk_publisher_update": "packet_network_chunk_publisher_update", + "biome_definition_list": "packet_biome_definition_list", + "level_sound_event": "packet_level_sound_event", + "level_event_generic": "packet_level_event_generic", + "lectern_update": "packet_lectern_update", + "video_stream_connect": "packet_video_stream_connect", + "client_cache_status": "packet_client_cache_status", + "on_screen_texture_animation": "packet_on_screen_texture_animation", + "map_create_locked_copy": "packet_map_create_locked_copy", + "structure_template_data_export_request": "packet_structure_template_data_export_request", + "structure_template_data_export_response": "packet_structure_template_data_export_response", + "update_block_properties": "packet_update_block_properties", + "client_cache_blob_status": "packet_client_cache_blob_status", + "client_cache_miss_response": "packet_client_cache_miss_response", + "network_settings": "packet_network_settings", + "creative_content": "packet_creative_content", + "player_enchant_options": "packet_player_enchant_options", + "item_stack_request": "packet_item_stack_request", + "item_stack_response": "packet_item_stack_response", + "update_player_game_type": "packet_update_player_game_type", + "packet_violation_warning": "packet_packet_violation_warning", + "item_component": "packet_item_component", + "filter_text_packet": "packet_filter_text_packet" + } + } + ] + } + ] + ], + "packet_login": [ + "container", + [ + { + "name": "protocol_version", + "type": "i32" + }, + { + "name": "payload", + "type": "ByteArray" + } + ] + ], + "packet_play_status": [ + "container", + [ + { + "name": "status", + "type": "i32" + } + ] + ], + "packet_server_to_client_handshake": [ + "container", + [ + { + "name": "token", + "type": "string" + } + ] + ], + "packet_client_to_server_handshake": [ + "container", + [] + ], + "packet_disconnect": [ + "container", + [ + { + "name": "hide_disconnect_reason", + "type": "bool" + }, + { + "name": "message", + "type": "string" + } + ] + ], + "packet_resource_packs_info": [ + "container", + [ + { + "name": "must_accept", + "type": "bool" + }, + { + "name": "has_scripts", + "type": "bool" + }, + { + "name": "behahaviorpackinfos", + "type": "BehaviourPackInfos" + }, + { + "name": "texturepacks", + "type": "TexturePackInfos" + } + ] + ], + "packet_resource_pack_stack": [ + "container", + [ + { + "name": "must_accept", + "type": "bool" + }, + { + "name": "behaviorpackidversions", + "type": "ResourcePackIdVersions" + }, + { + "name": "resourcepackidversions", + "type": "ResourcePackIdVersions" + }, + { + "name": "game_version", + "type": "string" + }, + { + "name": "experiments", + "type": "li32" + }, + { + "name": "experiments_previously_toggled", + "type": "bool" + } + ] + ], + "packet_resource_pack_client_response": [ + "container", + [ + { + "name": "response_status", + "type": "u8" + }, + { + "name": "resourcepackids", + "type": "ResourcePackIds" + } + ] + ], + "packet_text": [ + "container", + [ + { + "name": "type", + "type": "u8" + } + ] + ], + "packet_set_time": [ + "container", + [ + { + "name": "time", + "type": "zigzag32" + } + ] + ], + "packet_start_game": [ + "container", + [ + { + "name": "entity_id", + "type": "zigzag64" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "player_gamemode", + "type": "zigzag32" + }, + { + "name": "spawn", + "type": "vec3f" + }, + { + "name": "rotation", + "type": "vec3f" + }, + { + "name": "seed", + "type": "zigzag32" + }, + { + "name": "biome_type", + "type": "li16" + }, + { + "name": "biome_name", + "type": "string" + }, + { + "name": "dimension", + "type": "zigzag32" + }, + { + "name": "generator", + "type": "zigzag32" + }, + { + "name": "gamemode", + "type": "zigzag32" + }, + { + "name": "difficulty", + "type": "zigzag32" + }, + { + "name": "x", + "type": "zigzag32" + }, + { + "name": "y", + "type": "varint" + }, + { + "name": "z", + "type": "zigzag32" + }, + { + "name": "has_achievements_disabled", + "type": "bool" + }, + { + "name": "day_cycle_stop_time", + "type": "zigzag32" + }, + { + "name": "edu_offer", + "type": "zigzag32" + }, + { + "name": "has_edu_features_enabled", + "type": "bool" + }, + { + "name": "edu_product_uuid_", + "type": "string" + }, + { + "name": "rain_level", + "type": "lf32" + }, + { + "name": "lightning_level", + "type": "lf32" + }, + { + "name": "has_confirmed_platform_locked_content", + "type": "bool" + }, + { + "name": "is_multiplayer", + "type": "bool" + }, + { + "name": "broadcast_to_lan", + "type": "bool" + }, + { + "name": "xbox_live_broadcast_mode", + "type": "varint" + }, + { + "name": "platform_broadcast_mode", + "type": "varint" + }, + { + "name": "enable_commands", + "type": "bool" + }, + { + "name": "is_texturepacks_required", + "type": "bool" + }, + { + "name": "gamerules", + "type": "GameRules" + }, + { + "name": "experiments", + "type": "Experiments" + }, + { + "name": "experiments_previously_toggled", + "type": "bool" + }, + { + "name": "bonus_chest", + "type": "bool" + }, + { + "name": "map_enabled", + "type": "bool" + }, + { + "name": "permission_level", + "type": "zigzag32" + }, + { + "name": "server_chunk_tick_range", + "type": "li32" + }, + { + "name": "has_locked_behavior_pack", + "type": "bool" + }, + { + "name": "has_locked_resource_pack", + "type": "bool" + }, + { + "name": "is_from_locked_world_template", + "type": "bool" + }, + { + "name": "msa_gamertags_only", + "type": "bool" + }, + { + "name": "is_from_world_template", + "type": "bool" + }, + { + "name": "is_world_template_option_locked", + "type": "bool" + }, + { + "name": "only_spawn_v1_villagers", + "type": "bool" + }, + { + "name": "game_version", + "type": "string" + }, + { + "name": "limited_world_width_", + "type": "li32" + }, + { + "name": "limited_world_length_", + "type": "li32" + }, + { + "name": "is_new_nether_", + "type": "bool" + }, + { + "name": "experimental_gameplay_override", + "type": "bool" + }, + { + "name": "level_id", + "type": "string" + }, + { + "name": "world_name", + "type": "string" + }, + { + "name": "premium_world_template_id", + "type": "string" + }, + { + "name": "is_trial", + "type": "bool" + }, + { + "name": "movement_type", + "type": "zigzag32" + }, + { + "name": "current_tick", + "type": "li64" + }, + { + "name": "enchantment_seed", + "type": "zigzag32" + }, + { + "name": "block_palette", + "type": "BlockPalette" + }, + { + "name": "itemstates", + "type": "Itemstates" + }, + { + "name": "multiplayer_correlation_id", + "type": "string" + }, + { + "name": "server_authoritative_inventory", + "type": "bool" + } + ] + ], + "packet_add_player": [ + "container", + [ + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "username", + "type": "string" + }, + { + "name": "entity_id_self", + "type": "zigzag64" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "platform_chat_id", + "type": "string" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "speed_x", + "type": "lf32" + }, + { + "name": "speed_y", + "type": "lf32" + }, + { + "name": "speed_z", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "head_yaw", + "type": "lf32" + }, + { + "name": "held_item", + "type": "Item" + }, + { + "name": "metadata", + "type": "MetadataDictionary" + }, + { + "name": "flags", + "type": "varint" + }, + { + "name": "command_permission", + "type": "varint" + }, + { + "name": "action_permissions", + "type": "varint" + }, + { + "name": "permission_level", + "type": "varint" + }, + { + "name": "custom_stored_permissions", + "type": "varint" + }, + { + "name": "user_id", + "type": "li64" + }, + { + "name": "links", + "type": "Links" + }, + { + "name": "device_id", + "type": "string" + }, + { + "name": "device_os", + "type": "li32" + } + ] + ], + "packet_add_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "zigzag64" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "entity_type", + "type": "string" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "speed_x", + "type": "lf32" + }, + { + "name": "speed_y", + "type": "lf32" + }, + { + "name": "speed_z", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "head_yaw", + "type": "lf32" + }, + { + "name": "attributes", + "type": "EntityAttributes" + }, + { + "name": "metadata", + "type": "MetadataDictionary" + }, + { + "name": "links", + "type": "Links" + } + ] + ], + "packet_remove_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "zigzag64" + } + ] + ], + "packet_add_item_entity": [ + "container", + [ + { + "name": "entity_id_self", + "type": "zigzag64" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "item", + "type": "Item" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "speed_x", + "type": "lf32" + }, + { + "name": "speed_y", + "type": "lf32" + }, + { + "name": "speed_z", + "type": "lf32" + }, + { + "name": "metadata", + "type": "MetadataDictionary" + }, + { + "name": "is_from_fishing", + "type": "bool" + } + ] + ], + "packet_take_item_entity": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "target", + "type": "varint" + } + ] + ], + "packet_move_entity": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "flags", + "type": "u8" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "rotation", + "type": "Rotation" + } + ] + ], + "packet_move_player": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "head_yaw", + "type": "lf32" + }, + { + "name": "mode", + "type": "u8" + }, + { + "name": "on_ground", + "type": "bool" + }, + { + "name": "other_runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_rider_jump": [ + "container", + [ + { + "name": "unknown", + "type": "zigzag32" + } + ] + ], + "packet_update_block": [ + "container", + [ + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "block_runtime_id", + "type": "varint" + }, + { + "name": "block_priority", + "type": "varint" + }, + { + "name": "storage", + "type": "varint" + } + ] + ], + "packet_add_painting": [ + "container", + [ + { + "name": "entity_id_self", + "type": "zigzag64" + }, + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "direction", + "type": "zigzag32" + }, + { + "name": "title", + "type": "string" + } + ] + ], + "packet_tick_sync": [ + "container", + [ + { + "name": "request_time", + "type": "li64" + }, + { + "name": "response_time", + "type": "li64" + } + ] + ], + "packet_level_sound_event_old": [ + "container", + [ + { + "name": "sound_id", + "type": "u8" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "block_id", + "type": "zigzag32" + }, + { + "name": "entity_type", + "type": "zigzag32" + }, + { + "name": "is_baby_mob", + "type": "bool" + }, + { + "name": "is_global", + "type": "bool" + } + ] + ], + "packet_level_event": [ + "container", + [ + { + "name": "event_id", + "type": "zigzag32" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "data", + "type": "zigzag32" + } + ] + ], + "packet_block_event": [ + "container", + [ + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "case_1", + "type": "zigzag32" + }, + { + "name": "case_2", + "type": "zigzag32" + } + ] + ], + "packet_entity_event": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "event_id", + "type": "u8" + }, + { + "name": "data", + "type": "zigzag32" + } + ] + ], + "packet_mob_effect": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "event_id", + "type": "u8" + }, + { + "name": "effect_id", + "type": "zigzag32" + }, + { + "name": "amplifier", + "type": "zigzag32" + }, + { + "name": "particles", + "type": "bool" + }, + { + "name": "duration", + "type": "zigzag32" + } + ] + ], + "packet_update_attributes": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "attributes", + "type": "PlayerAttributes" + }, + { + "name": "tick", + "type": "varint" + } + ] + ], + "packet_inventory_transaction": [ + "container", + [ + { + "name": "transaction", + "type": "Transaction" + } + ] + ], + "packet_mob_equipment": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "item", + "type": "Item" + }, + { + "name": "slot", + "type": "u8" + }, + { + "name": "selected_slot", + "type": "u8" + }, + { + "name": "windows_id", + "type": "u8" + } + ] + ], + "packet_mob_armor_equipment": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "helmet", + "type": "Item" + }, + { + "name": "chestplate", + "type": "Item" + }, + { + "name": "leggings", + "type": "Item" + }, + { + "name": "boots", + "type": "Item" + } + ] + ], + "packet_interact": [ + "container", + [ + { + "name": "action_id", + "type": "u8" + }, + { + "name": "target_runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_block_pick_request": [ + "container", + [ + { + "name": "x", + "type": "zigzag32" + }, + { + "name": "y", + "type": "zigzag32" + }, + { + "name": "z", + "type": "zigzag32" + }, + { + "name": "add_user_data", + "type": "bool" + }, + { + "name": "selected_slot", + "type": "u8" + } + ] + ], + "packet_entity_pick_request": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "lu64" + }, + { + "name": "selected_slot", + "type": "u8" + } + ] + ], + "packet_player_action": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "action_id", + "type": "zigzag32" + }, + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "face", + "type": "zigzag32" + } + ] + ], + "packet_hurt_armor": [ + "container", + [ + { + "name": "health", + "type": "zigzag32" + } + ] + ], + "packet_set_entity_data": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "metadata", + "type": "MetadataDictionary" + }, + { + "name": "tick", + "type": "varint" + } + ] + ], + "packet_set_entity_motion": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "velocity", + "type": "vec3f" + } + ] + ], + "packet_set_entity_link": [ + "container", + [ + { + "name": "ridden_id", + "type": "zigzag64" + }, + { + "name": "rider_id", + "type": "zigzag64" + }, + { + "name": "link_type", + "type": "u8" + }, + { + "name": "unknown", + "type": "u8" + } + ] + ], + "packet_set_health": [ + "container", + [ + { + "name": "health", + "type": "zigzag32" + } + ] + ], + "packet_set_spawn_position": [ + "container", + [ + { + "name": "spawn_type", + "type": "zigzag32" + }, + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "dimension", + "type": "zigzag32" + }, + { + "name": "unknown_coordinates", + "type": "BlockCoordinates" + } + ] + ], + "packet_animate": [ + "container", + [ + { + "name": "action_id", + "type": "zigzag32" + }, + { + "name": "runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_respawn": [ + "container", + [ + { + "name": "x", + "type": "lf32" + }, + { + "name": "y", + "type": "lf32" + }, + { + "name": "z", + "type": "lf32" + }, + { + "name": "state", + "type": "u8" + }, + { + "name": "runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_container_open": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "type", + "type": "u8" + }, + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "runtime_entity_id", + "type": "zigzag64" + } + ] + ], + "packet_container_close": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "server", + "type": "bool" + } + ] + ], + "packet_player_hotbar": [ + "container", + [ + { + "name": "selected_slot", + "type": "varint" + }, + { + "name": "window_id", + "type": "u8" + }, + { + "name": "select_slot_", + "type": "bool" + } + ] + ], + "packet_inventory_content": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + }, + { + "name": "input", + "type": "ItemStacks" + } + ] + ], + "packet_inventory_slot": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "uniqueid", + "type": "zigzag32" + }, + { + "name": "item", + "type": "Item" + } + ] + ], + "packet_container_set_data": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "property", + "type": "zigzag32" + }, + { + "name": "value", + "type": "zigzag32" + } + ] + ], + "packet_crafting_data": [ + "container", + [ + { + "name": "recipes", + "type": "Recipes" + }, + { + "name": "potion_type_recipes", + "type": "PotionTypeRecipes" + }, + { + "name": "potion_container_recipes", + "type": "PotionContainerChangeRecipes" + }, + { + "name": "is_clean", + "type": "bool" + } + ] + ], + "packet_crafting_event": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "recipe_type", + "type": "zigzag32" + }, + { + "name": "recipe_id", + "type": "uuid" + }, + { + "name": "input", + "type": "ItemStacks" + }, + { + "name": "result", + "type": "ItemStacks" + } + ] + ], + "packet_gui_data_pick_item": [ + "container", + [] + ], + "packet_adventure_settings": [ + "container", + [ + { + "name": "flags", + "type": "varint" + }, + { + "name": "command_permission", + "type": "varint" + }, + { + "name": "action_permissions", + "type": "varint" + }, + { + "name": "permission_level", + "type": "varint" + }, + { + "name": "custom_stored_permissions", + "type": "varint" + }, + { + "name": "user_id", + "type": "li64" + } + ] + ], + "packet_block_entity_data": [ + "container", + [ + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "namedtag", + "type": "nbt" + } + ] + ], + "packet_player_input": [ + "container", + [ + { + "name": "motion_x", + "type": "lf32" + }, + { + "name": "motion_z", + "type": "lf32" + }, + { + "name": "jumping", + "type": "bool" + }, + { + "name": "sneaking", + "type": "bool" + } + ] + ], + "packet_level_chunk": [ + "container", + [ + { + "name": "chunk_x", + "type": "zigzag32" + }, + { + "name": "chunk_z", + "type": "zigzag32" + }, + { + "name": "sub_chunk_count", + "type": "varint" + }, + { + "name": "cache_enabled", + "type": "bool" + } + ] + ], + "packet_set_commands_enabled": [ + "container", + [ + { + "name": "enabled", + "type": "bool" + } + ] + ], + "packet_set_difficulty": [ + "container", + [ + { + "name": "difficulty", + "type": "varint" + } + ] + ], + "packet_change_dimension": [ + "container", + [ + { + "name": "dimension", + "type": "zigzag32" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "respawn", + "type": "bool" + } + ] + ], + "packet_set_player_game_type": [ + "container", + [ + { + "name": "gamemode", + "type": "zigzag32" + } + ] + ], + "packet_player_list": [ + "container", + [ + { + "name": "records", + "type": "PlayerRecords" + } + ] + ], + "packet_simple_event": [ + "container", + [ + { + "name": "event_type", + "type": "lu16" + } + ] + ], + "packet_spawn_experience_orb": [ + "container", + [ + { + "name": "position", + "type": "vec3f" + }, + { + "name": "count", + "type": "zigzag32" + } + ] + ], + "packet_clientbound_map_item_data_": [ + "container", + [ + { + "name": "mapinfo", + "type": "MapInfo" + } + ] + ], + "packet_map_info_request": [ + "container", + [ + { + "name": "map_id", + "type": "zigzag64" + } + ] + ], + "packet_request_chunk_radius": [ + "container", + [ + { + "name": "chunk_radius", + "type": "zigzag32" + } + ] + ], + "packet_chunk_radius_update": [ + "container", + [ + { + "name": "chunk_radius", + "type": "zigzag32" + } + ] + ], + "packet_item_frame_drop_item": [ + "container", + [ + { + "name": "coordinates", + "type": "BlockCoordinates" + } + ] + ], + "packet_game_rules_changed": [ + "container", + [ + { + "name": "rules", + "type": "GameRules" + } + ] + ], + "packet_camera": [ + "container", + [ + { + "name": "unknown1", + "type": "zigzag64" + }, + { + "name": "unknown2", + "type": "zigzag64" + } + ] + ], + "packet_boss_event": [ + "container", + [ + { + "name": "boss_entity_id", + "type": "zigzag64" + }, + { + "name": "event_type", + "type": "varint" + } + ] + ], + "packet_show_credits": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "status", + "type": "zigzag32" + } + ] + ], + "packet_available_commands": [ + "container", + [] + ], + "packet_command_request": [ + "container", + [ + { + "name": "command", + "type": "string" + }, + { + "name": "command_type", + "type": "varint" + }, + { + "name": "unknown_uuid", + "type": "uuid" + }, + { + "name": "request_id", + "type": "string" + }, + { + "name": "unknown", + "type": "bool" + } + ] + ], + "packet_command_block_update": [ + "container", + [ + { + "name": "is_block", + "type": "bool" + } + ] + ], + "packet_command_output": [ + "container", + [] + ], + "packet_update_trade": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "window_type", + "type": "u8" + }, + { + "name": "unknown0", + "type": "varint" + }, + { + "name": "unknown1", + "type": "varint" + }, + { + "name": "unknown2", + "type": "varint" + }, + { + "name": "is_willing", + "type": "bool" + }, + { + "name": "trader_entity_id", + "type": "zigzag64" + }, + { + "name": "player_entity_id", + "type": "zigzag64" + }, + { + "name": "display_name", + "type": "string" + }, + { + "name": "namedtag", + "type": "nbt" + } + ] + ], + "packet_update_equipment": [ + "container", + [ + { + "name": "window_id", + "type": "u8" + }, + { + "name": "window_type", + "type": "u8" + }, + { + "name": "unknown", + "type": "u8" + }, + { + "name": "entity_id", + "type": "zigzag64" + }, + { + "name": "namedtag", + "type": "nbt" + } + ] + ], + "packet_resource_pack_data_info": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "max_chunk_size", + "type": "lu32" + }, + { + "name": "chunk_count", + "type": "lu32" + }, + { + "name": "compressed_package_size", + "type": "lu64" + }, + { + "name": "hash", + "type": "ByteArray" + }, + { + "name": "is_premium", + "type": "bool" + }, + { + "name": "pack_type", + "type": "u8" + } + ] + ], + "packet_resource_pack_chunk_data": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "chunk_index", + "type": "lu32" + }, + { + "name": "progress", + "type": "lu64" + }, + { + "name": "payload", + "type": "ByteArray" + } + ] + ], + "packet_resource_pack_chunk_request": [ + "container", + [ + { + "name": "package_id", + "type": "string" + }, + { + "name": "chunk_index", + "type": "lu32" + } + ] + ], + "packet_transfer": [ + "container", + [ + { + "name": "server_address", + "type": "string" + }, + { + "name": "port", + "type": "lu16" + } + ] + ], + "packet_play_sound": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "volume", + "type": "lf32" + }, + { + "name": "pitch", + "type": "lf32" + } + ] + ], + "packet_stop_sound": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "stop_all", + "type": "bool" + } + ] + ], + "packet_set_title": [ + "container", + [ + { + "name": "type", + "type": "zigzag32" + }, + { + "name": "text", + "type": "string" + }, + { + "name": "fade_in_time", + "type": "zigzag32" + }, + { + "name": "stay_time", + "type": "zigzag32" + }, + { + "name": "fade_out_time", + "type": "zigzag32" + } + ] + ], + "packet_add_behavior_tree": [ + "container", + [ + { + "name": "behaviortree", + "type": "string" + } + ] + ], + "packet_structure_block_update": [ + "container", + [] + ], + "packet_show_store_offer": [ + "container", + [ + { + "name": "unknown0", + "type": "string" + }, + { + "name": "unknown1", + "type": "bool" + } + ] + ], + "packet_purchase_receipt": [ + "container", + [] + ], + "packet_player_skin": [ + "container", + [ + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "skin", + "type": "Skin" + }, + { + "name": "skin_name", + "type": "string" + }, + { + "name": "old_skin_name", + "type": "string" + }, + { + "name": "is_verified", + "type": "bool" + } + ] + ], + "packet_sub_client_login": [ + "container", + [] + ], + "packet_initiate_web_socket_connection": [ + "container", + [ + { + "name": "server", + "type": "string" + } + ] + ], + "packet_set_last_hurt_by": [ + "container", + [ + { + "name": "unknown", + "type": "varint" + } + ] + ], + "packet_book_edit": [ + "container", + [] + ], + "packet_npc_request": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "unknown0", + "type": "u8" + }, + { + "name": "unknown1", + "type": "string" + }, + { + "name": "unknown2", + "type": "u8" + } + ] + ], + "packet_photo_transfer": [ + "container", + [ + { + "name": "file_name", + "type": "string" + }, + { + "name": "image_data", + "type": "string" + }, + { + "name": "unknown2", + "type": "string" + } + ] + ], + "packet_modal_form_request": [ + "container", + [ + { + "name": "form_id", + "type": "varint" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "packet_modal_form_response": [ + "container", + [ + { + "name": "form_id", + "type": "varint" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "packet_server_settings_request": [ + "container", + [] + ], + "packet_server_settings_response": [ + "container", + [ + { + "name": "form_id", + "type": "varint" + }, + { + "name": "data", + "type": "string" + } + ] + ], + "packet_show_profile": [ + "container", + [ + { + "name": "xuid", + "type": "string" + } + ] + ], + "packet_set_default_game_type": [ + "container", + [ + { + "name": "gamemode", + "type": "varint" + } + ] + ], + "packet_remove_objective": [ + "container", + [ + { + "name": "objective_name", + "type": "string" + } + ] + ], + "packet_set_display_objective": [ + "container", + [ + { + "name": "display_slot", + "type": "string" + }, + { + "name": "objective_name", + "type": "string" + }, + { + "name": "display_name", + "type": "string" + }, + { + "name": "criteria_name", + "type": "string" + }, + { + "name": "sort_order", + "type": "zigzag32" + } + ] + ], + "packet_set_score": [ + "container", + [ + { + "name": "entries", + "type": "ScoreEntries" + } + ] + ], + "packet_lab_table": [ + "container", + [ + { + "name": "useless_byte", + "type": "u8" + }, + { + "name": "lab_table_x", + "type": "varint" + }, + { + "name": "lab_table_y", + "type": "varint" + }, + { + "name": "lab_table_z", + "type": "varint" + }, + { + "name": "reaction_type", + "type": "u8" + } + ] + ], + "packet_update_block_synced": [ + "container", + [ + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "block_runtime_id", + "type": "varint" + }, + { + "name": "block_priority", + "type": "varint" + }, + { + "name": "data_layer_id", + "type": "varint" + }, + { + "name": "unknown0", + "type": "varint" + }, + { + "name": "unknown1", + "type": "varint" + } + ] + ], + "packet_move_entity_delta": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + }, + { + "name": "flags", + "type": "lu16" + } + ] + ], + "packet_set_scoreboard_identity": [ + "container", + [ + { + "name": "entries", + "type": "ScoreboardIdentityEntries" + } + ] + ], + "packet_set_local_player_as_initialized": [ + "container", + [ + { + "name": "runtime_entity_id", + "type": "varint" + } + ] + ], + "packet_update_soft_enum": [ + "container", + [] + ], + "packet_network_stack_latency": [ + "container", + [ + { + "name": "timestamp", + "type": "lu64" + }, + { + "name": "unknown_flag", + "type": "u8" + } + ] + ], + "packet_script_custom_event": [ + "container", + [ + { + "name": "event_name", + "type": "string" + }, + { + "name": "event_data", + "type": "string" + } + ] + ], + "packet_spawn_particle_effect": [ + "container", + [ + { + "name": "dimension_id", + "type": "u8" + }, + { + "name": "entity_id", + "type": "zigzag64" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "particle_name", + "type": "string" + } + ] + ], + "packet_available_entity_identifiers": [ + "container", + [ + { + "name": "namedtag", + "type": "nbt" + } + ] + ], + "packet_level_sound_event_v2": [ + "container", + [ + { + "name": "sound_id", + "type": "u8" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "block_id", + "type": "zigzag32" + }, + { + "name": "entity_type", + "type": "string" + }, + { + "name": "is_baby_mob", + "type": "bool" + }, + { + "name": "is_global", + "type": "bool" + } + ] + ], + "packet_network_chunk_publisher_update": [ + "container", + [ + { + "name": "coordinates", + "type": "BlockCoordinates" + }, + { + "name": "radius", + "type": "varint" + } + ] + ], + "packet_biome_definition_list": [ + "container", + [ + { + "name": "namedtag", + "type": "nbt" + } + ] + ], + "packet_level_sound_event": [ + "container", + [ + { + "name": "sound_id", + "type": "varint" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "block_id", + "type": "zigzag32" + }, + { + "name": "entity_type", + "type": "string" + }, + { + "name": "is_baby_mob", + "type": "bool" + }, + { + "name": "is_global", + "type": "bool" + } + ] + ], + "packet_level_event_generic": [ + "container", + [] + ], + "packet_lectern_update": [ + "container", + [] + ], + "packet_video_stream_connect": [ + "container", + [ + { + "name": "server_uri", + "type": "string" + }, + { + "name": "frame_send_frequency", + "type": "lf32" + }, + { + "name": "action", + "type": "u8" + }, + { + "name": "resolution_x", + "type": "li32" + }, + { + "name": "resolution_y", + "type": "li32" + } + ] + ], + "packet_client_cache_status": [ + "container", + [ + { + "name": "enabled", + "type": "bool" + } + ] + ], + "packet_on_screen_texture_animation": [ + "container", + [] + ], + "packet_map_create_locked_copy": [ + "container", + [] + ], + "packet_structure_template_data_export_request": [ + "container", + [] + ], + "packet_structure_template_data_export_response": [ + "container", + [] + ], + "packet_update_block_properties": [ + "container", + [ + { + "name": "namedtag", + "type": "nbt" + } + ] + ], + "packet_client_cache_blob_status": [ + "container", + [] + ], + "packet_client_cache_miss_response": [ + "container", + [] + ], + "packet_network_settings": [ + "container", + [ + { + "name": "unknown", + "type": "u8" + }, + { + "name": "compression_threshold", + "type": "u8" + } + ] + ], + "packet_creative_content": [ + "container", + [ + { + "name": "input", + "type": "ItemStacks" + } + ] + ], + "packet_player_enchant_options": [ + "container", + [ + { + "name": "enchant_options", + "type": "EnchantOptions" + } + ] + ], + "packet_item_stack_request": [ + "container", + [ + { + "name": "requests", + "type": "ItemStackRequests" + } + ] + ], + "packet_item_stack_response": [ + "container", + [ + { + "name": "responses", + "type": "ItemStackResponses" + } + ] + ], + "packet_update_player_game_type": [ + "container", + [] + ], + "packet_packet_violation_warning": [ + "container", + [ + { + "name": "violation_type", + "type": "zigzag32" + }, + { + "name": "severity", + "type": "zigzag32" + }, + { + "name": "packet_id", + "type": "zigzag32" + }, + { + "name": "reason", + "type": "string" + } + ] + ], + "packet_item_component": [ + "container", + [ + { + "name": "entries", + "type": "ItemComponentList" + } + ] + ], + "packet_filter_text_packet": [ + "container", + [ + { + "name": "text", + "type": "string" + }, + { + "name": "from_server", + "type": "bool" + } + ] + ] + } +} \ No newline at end of file diff --git a/package.json b/package.json index 480db34..12fc42f 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,19 @@ "@babel/preset-env": "^7.5.4", "@babel/preset-typescript": "^7.3.3", "@babel/register": "^7.4.4", - "asn1": "^0.2.3", + "@jsprismarine/jsbinaryutils": "^2.1.8", + "@jsprismarine/raknet": "github:extremeheat/raknet", + "aes-js": "^3.1.2", + "asn1": "^0.2.4", "bn.js": "^4.11.4", - "jwt-simple": "^0.5.0", + "ec-pem": "^0.18.0", + "jsonwebtoken": "^8.5.1", + "jwt-simple": "^0.5.6", "lodash.merge": "^4.4.0", - "prismarine-nbt": "^1.0.0", - "protodef": "^1.2.3", + "prismarine-nbt": "github:extremeheat/prismarine-nbt#le", + "protodef": "github:extremeheat/node-protodef#big", "raknet": "git+https://github.com/mhsjlw/node-raknet.git#master", - "uuid-1345": "^0.99.6" + "uuid-1345": "^0.99.7" }, "devDependencies": { "@babel/cli": "^7.5.0", diff --git a/src/BatchPacket.js b/src/BatchPacket.js new file mode 100644 index 0000000..5cffd28 --- /dev/null +++ b/src/BatchPacket.js @@ -0,0 +1,86 @@ +const BinaryStream = require('@jsprismarine/jsbinaryutils').default +const Zlib = require('zlib'); + +const NETWORK_ID = 0xfe + +// This is not a MCPE packet, it's a wrapper that contains compressed batched packets +class BatchPacket { + + constructor(stream) { + this.payload = Buffer.alloc(0) + this.stream = stream || new BinaryStream() + this.packets = [] + this.compressionLevel = 7 + } + + init() { + + } + + decode() { + // Read header + const pid = this.stream.readByte(); + if (!pid === NETWORK_ID) { + throw new Error(`Batch ID mismatch: is ${BatchPacket.NETWORK_ID}, got ${pid}`) // this is not a BatchPacket + } + + // Decode the payload + try { + this.payload = Zlib.inflateRawSync(this.stream.readRemaining(), { + chunkSize: 1024 * 1024 * 2 + }); + } catch (e) { + console.error(e) + console.debug(`[bp] Error decompressing packet ${pid}`) + } + } + + encode() { + const buf = this.stream.getBuffer() + console.log('Encoding payload', buf) + const def = Zlib.deflateRawSync(buf, { level: this.compressionLevel }) + const ret = Buffer.concat([Buffer.from([0xfe]), def]) + console.log('Compressed', ret) + return ret + } + + encodePayload() { + } + + addEncoded(packet) { + + } + + addEncodedPacket(packet) { + this.stream.writeUnsignedVarInt(packet.byteLength) + this.stream.append(packet) + // this.payload = Buffer.concat([this.payload, stream.getBuffer()]); + } + + getPackets() { + const stream = new BinaryStream() + stream.buffer = this.payload + const packets = [] + while (!stream.feof()) { + const length = stream.readUnsignedVarInt() + const buffer = stream.read(length) + packets.push(buffer) + } + + return packets + } + + static getPackets(stream) { + stream.buffer = this.payload + const packets = [] + while (!stream.feof()) { + const length = stream.readUnsignedVarInt() + const buffer = stream.read(length) + packets.push(buffer) + } + + return packets + } +} + +module.exports = BatchPacket \ No newline at end of file diff --git a/src/auth/constants.js b/src/auth/constants.js new file mode 100644 index 0000000..3d04d67 --- /dev/null +++ b/src/auth/constants.js @@ -0,0 +1,4 @@ +module.exports = { + PUBLIC_KEY: 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V', + secret_key: 'nwOn35gXIfEfgZPIrjNJ+cAxODD/XIpjs3YG7FO1pmwbzpRSlac', +} diff --git a/src/auth/encrypt.js b/src/auth/encrypt.js new file mode 100644 index 0000000..e5aca37 --- /dev/null +++ b/src/auth/encrypt.js @@ -0,0 +1,232 @@ +const crypto = require('crypto') +const JWT = require('jsonwebtoken') +const constants = require('./constants') +const { Ber } = require('asn1') +const ec_pem = require('ec-pem'); + +// function Encrypt(client, options) { +// this.startClientboundEncryption = (pubKeyBuf) => { + +// } +// client.on('start_encrypt', this.startClientboundEncryption) +// } + +// module.exports = Encrypt + + +// Server -> Client : sent right after the client sends us a LOGIN_PACKET so +// we can start the encryption process +// @param {key} - The key from the client Login Packet final JWT chain +function startClientboundEncryption(pubKeyBuf) { + // create our ecdh keypair + const type = 'secp256k1' + const alice = crypto.createECDH(type) + const aliceKey = alice.generateKeys() + const alicePublicKey = aliceKey.toString('base64') + const alicePrivateKey = mcPubKeyToPem(alice.getPrivateKey('base64')) + // get our secret key hex encoded + // const aliceSecret = alice.computeSecret(pubKeyBuf, null, 'hex') + + // (yawkat:) + // From the public key of the remote and the private key of the local, + // a shared secret is generated using ECDH. The secret key bytes are + // then computed as sha256(server_token + shared_secret). These secret + // key bytes are 32 bytes long. + const salt = Buffer.from('', 'utf-8') + let secret = crypto.createHash('sha256').update(Buffer.concat([salt, pubKeyBuf])).digest() + console.log('alice', alicePrivateKey) + const pem = mcPubKeyToPem(alice.getPrivateKey().toString('base64')) + console.log('pem', pem) + + const token = JWT.sign({ + salt, + signedToken: alicePublicKey + }, pem, { algorithm: 'ES384' }) + + console.log('Token', token) + + // get our Secret Bytes from the secret key + + + // alice.setPrivateKey( + // crypto.createHash('sha256').update('alice', 'utf8').digest() + // ) + + // using (var sha = SHA256.Create()) + // { + // secret = sha.ComputeHash(secretPrepend.Concat(agreement.CalculateAgreement(remotePublicKey).ToByteArrayUnsigned()).ToArray()); + // } + + + + const bob = crypto.createECDH('secp256k1'); + + + // URI x5u = URI.create(Base64.getEncoder().encodeToString(serverKeyPair.getPublic().getEncoded())); + + // JWTClaimsSet claimsSet = new JWTClaimsSet.Builder().claim("salt", Base64.getEncoder().encodeToString(token)).build(); + // SignedJWT jwt = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.ES384).x509CertURL(x5u).build(), claimsSet); + + // signJwt(jwt, (ECPrivateKey) serverKeyPair.getPrivate()); + + // return jwt; +} + +function testECDH() { + const crypto = require('crypto') + const alice = crypto.createECDH('secp256k1') + const bob = crypto.createECDH('secp256k1') + + // Note: This is a shortcut way to specify one of Alice's previous private + // keys. It would be unwise to use such a predictable private key in a real + // application. + alice.setPrivateKey( + crypto.createHash('sha256').update('alice', 'utf8').digest() + ); + + // Bob uses a newly generated cryptographically strong + // pseudorandom key pair bob.generateKeys(); + + const alice_secret = alice.computeSecret(bob.getPublicKey(), null, 'hex') + const bob_secret = bob.computeSecret(alice.getPublicKey(), null, 'hex') + + // alice_secret and bob_secret should be the same shared secret value + console.log(alice_secret === bob_secret) +} + +function testECDH2() { + const type = 'secp256k1' + const alice = crypto.createECDH(type); + const aliceKey = alice.generateKeys(); + + // Generate Bob's keys... + const bob = crypto.createECDH(type); + const bobKey = bob.generateKeys(); + + console.log("\nAlice private key:\t", alice.getPrivateKey().toString('hex')); + console.log("Alice public key:\t", aliceKey.toString('hex')) + + console.log("\nBob private key:\t", bob.getPrivateKey().toString('hex')); + console.log("Bob public key:\t", bobKey.toString('hex')); + + + // Exchange and generate the secret... + const aliceSecret = alice.computeSecret(bobKey); + const bobSecret = bob.computeSecret(aliceKey); + + console.log("\nAlice shared key:\t", aliceSecret.toString('hex')) + console.log("Bob shared key:\t\t", bobSecret.toString('hex')); + //wow it actually works?! +} + +function mcPubKeyToPem(mcPubKeyBuffer) { + console.log(mcPubKeyBuffer) + if (mcPubKeyBuffer[0] == '-') return mcPubKeyBuffer + let pem = '-----BEGIN PUBLIC KEY-----\n' + let base64PubKey = mcPubKeyBuffer.toString('base64') + const maxLineLength = 65 + while (base64PubKey.length > 0) { + pem += base64PubKey.substring(0, maxLineLength) + '\n' + base64PubKey = base64PubKey.substring(maxLineLength) + } + pem += '-----END PUBLIC KEY-----\n' + return pem +} + +function readX509PublicKey(key) { + var reader = new Ber.Reader(Buffer.from(key, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); // Hey, I'm an elliptic curve + reader.readOID(); // This contains the curve type, could be useful + return Buffer.from(reader.readString(Ber.BitString, true)).slice(1); +} + +function testMC() { + // const pubKeyBuf = Buffer.from(constants.PUBLIC_KEY, 'base64') + // const pem = mcPubKeyToPem(pubKeyBuf) + // console.log(mcPubKeyToPem(pubKeyBuf)) + // const publicKey = crypto.createPublicKey({ key: pem, format: 'der' }) + + const pubKeyBuf = readX509PublicKey(constants.PUBLIC_KEY) + + // console.log('Mojang pub key', pubKeyBuf.toString('hex'), publicKey) + startClientboundEncryption(pubKeyBuf) +} + +function testMC2() { + // const mojangPubKeyBuf = Buffer.from('MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V', 'base64') + // const pem = mcPubKeyToPem(mojangPubKeyBuf) + // const publicKey = crypto.createPublicKey({ key: pem }) + + const publicKey = readX509PublicKey(constants.PUBLIC_KEY) + + const curve = 'secp384r1' + const alice = crypto.createECDH(curve) + // const keys = crypto.generateKeyPair('ec',) + + // const bob = crypto.generateKeyPairSync('ec', { + // namedCurve: type + // }) + // alice.setPrivateKey(bob.privateKey.export({ type: 'pkcs8', format: 'pem' })) + // alice.setPublicKey(bob.publicKey.export({ type: 'spki', format: 'pem' })) + + // console.log(bob) + + const aliceKey = alice.generateKeys() + + const alicePEM = ec_pem(alice, curve) + + const alicePEMPrivate = alicePEM.encodePrivateKey() + const alicePEMPublic = alicePEM.encodePublicKey() + + // const alicePublicKey = aliceKey.toString('base64') + // const alicePrivateKey = alice.getPrivateKey().toString('base64') + const aliceSecret = alice.computeSecret(publicKey, null, 'hex') + + console.log('Alice private key PEM', alicePEMPrivate) + console.log('Alice public key PEM', alicePEMPublic) + console.log('Alice public key', alice.getPublicKey('base64')) + console.log('Alice secret key', aliceSecret) + + + var sign = crypto.createSign('RSA-SHA256') + sign.write('something') + sign.end() +// // const pem2 = +// // `-----BEGIN PRIVATE KEY----- +// // ${alice.getPrivateKey('base64')} +// // -----END PRIVATE KEY-----` + +// console.log('PEM', bob.privateKey) + const sig = sign.sign(alicePEMPrivate, 'hex') + console.log('Signature', sig) + + + + const token = JWT.sign({ + salt: 'HELLO', + signedToken: alice.getPublicKey('base64') + }, alicePEMPrivate, { algorithm: 'ES384' }) + console.log('Token', token) + + const verified = JWT.verify(token, alicePEMPublic, { algorithms: 'ES384' }) + console.log('Verified!', verified) +} + +function testMC3() { + var Ber = require('asn1').Ber; + var reader = new Ber.Reader(new Buffer(constants.PUBLIC_KEY, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); // Hey, I'm an elliptic curve + reader.readOID(); // This contains the curve type, could be useful + var pubKey = reader.readString(Ber.BitString, true).slice(1); + var server = crypto.createECDH('secp384r1'); + server.generateKeys(); + console.log(server.computeSecret(pubKey)); + +} + +// testECDH2() +testMC2() \ No newline at end of file diff --git a/src/auth/encryptTest.js b/src/auth/encryptTest.js new file mode 100644 index 0000000..d1d83ef --- /dev/null +++ b/src/auth/encryptTest.js @@ -0,0 +1,88 @@ +const crypto = require('crypto') +const JWT = require('jsonwebtoken') +const constants = require('./constants') +const { Ber } = require('asn1') +const ec_pem = require('ec-pem') + +function readX509PublicKey(key) { + var reader = new Ber.Reader(Buffer.from(key, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); // Hey, I'm an elliptic curve + reader.readOID(); // This contains the curve type, could be useful + return Buffer.from(reader.readString(Ber.BitString, true)).slice(1); +} + +function writeX509PublicKey(key) { + var writer = new Ber.Writer(); + writer.startSequence(); + writer.startSequence(); + writer.writeOID("1.2.840.10045.2.1"); + writer.writeOID("1.3.132.0.34"); + writer.endSequence(); + writer.writeBuffer(Buffer.concat([Buffer.from([0x00]), key]), Ber.BitString); + writer.endSequence(); + return writer.buffer.toString("base64"); +} + +function test(pubKey = constants.PUBLIC_KEY) { + const publicKey = readX509PublicKey(pubKey) + const curve = 'secp384r1' + const alice = crypto.createECDH(curve) + const aliceKey = alice.generateKeys() + const alicePEM = ec_pem(alice, curve) + const alicePEMPrivate = alicePEM.encodePrivateKey() + const alicePEMPublic = alicePEM.encodePublicKey() + const aliceSecret = alice.computeSecret(publicKey, null, 'hex') + console.log('Alice private key PEM', alicePEMPrivate) + console.log('Alice public key PEM', alicePEMPublic) + console.log('Alice public key', alice.getPublicKey('hex')) + console.log('Alice secret key', aliceSecret) + + // Test signing manually + const sign = crypto.createSign('RSA-SHA256') + sign.write('🧂') + sign.end() + const sig = sign.sign(alicePEMPrivate, 'hex') + console.log('Signature', sig) + + // Test JWT sign+verify + const x509 = writeX509PublicKey(alice.getPublicKey()) + const token = JWT.sign({ + salt: 'HELLO', + signedToken: alice.getPublicKey('base64') + }, alicePEMPrivate, { algorithm: 'ES384', header: { x5u: x509 } }) + console.log('Encoded JWT', token) + // send the jwt to the client... + + const verified = JWT.verify(token, alicePEMPublic, { algorithms: 'ES384' }) + console.log('Decoded JWT', verified) + // Good +} + +/** + * Alice private key PEM -----BEGIN EC PRIVATE KEY----- +MIGkAgEBBDBGgHZwH3BzieyJrdrVTVLmrEoUxpDUSqSzS98lobTXeUxJR/OmywPV +57I8YtnsJlCgBwYFK4EEACKhZANiAATjvTRgjsxKruO7XbduSQoHeR/6ouIm4Rmc +La9EkSpLFpuYZfsdtq9Vcf2t3Q3+jIbXjD/wNo97P4Hr5ghXG8sCVV7jpqadOF8j +SzyfajLGfX9mkS5WWLAg+dpi/KiEo/g= +-----END EC PRIVATE KEY----- + +Alice public key PEM -----BEGIN PUBLIC KEY----- +MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE4700YI7MSq7ju123bkkKB3kf+qLiJuEZ +nC2vRJEqSxabmGX7HbavVXH9rd0N/oyG14w/8DaPez+B6+YIVxvLAlVe46amnThf +I0s8n2oyxn1/ZpEuVliwIPnaYvyohKP4 +-----END PUBLIC KEY----- + +Alice public key 04e3bd34608ecc4aaee3bb5db76e490a07791ffaa2e226e1199c2daf44912a4b169b9865fb1db6af5571fdaddd0dfe8c86d78c3ff0368f7b3f81ebe608571bcb02555ee3a6a69d385f234b3c9f6a32c67d7f66912e5658b020f9da62fca884a3f8 +Alice secret key 76feb5d420b33907c4841a74baa707b717a29c021b17b6662fd46dba3227cac3e256eee9e890edb0308f66a3119b4914 +Signature 3066023100d5ea70b8fc5e441c5e93d9f7dcde031f54291011c950a4aa8625ea9b27f7c798a8bc4de40baf35d487a05db6b5c628c6023100ae06cc2ea65db77138163c546ccf13933faae3d91bd6aa7108b99539cdb1c86f1e8a3704cb099f0b00eebed4ee75ccb2 +Encoded JWT eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJzYWx0IjoiSEVMTE8iLCJzaWduZWRUb2tlbiI6IkJPTzlOR0NPekVxdTQ3dGR0MjVKQ2dkNUgvcWk0aWJoR1p3dHIwU1JLa3NXbTVobCt4MjJyMVZ4L2EzZERmNk1odGVNUC9BMmozcy9nZXZtQ0ZjYnl3SlZYdU9tcHAwNFh5TkxQSjlxTXNaOWYyYVJMbFpZc0NENTJtTDhxSVNqK0E9PSIsImlhdCI6MTYxMTc4MDYwNX0._g8k086U7nD-Tthn8jGWuuM3Q4EfhgqCfFA1Q5ePmjqhqMHOJvmrCz6tWsCytr2i-a2M51fb9K_YDAHbZ66Kos9ZkjF4Tqz5fPS880fM9woZ_1xjh7nGcOQ6sbY81zyi +Decoded JWT { + salt: 'HELLO', + signedToken: 'BOO9NGCOzEqu47tdt25JCgd5H/qi4ibhGZwtr0SRKksWm5hl+x22r1Vx/a3dDf6MhteMP/A2j3s/gevmCFcbywJVXuOmpp04XyNLPJ9qMsZ9f2aRLlZYsCD52mL8qISj+A==', + iat: 1611780605 +} + */ + +test() \ No newline at end of file diff --git a/src/auth/encryption.js b/src/auth/encryption.js new file mode 100644 index 0000000..9529fc0 --- /dev/null +++ b/src/auth/encryption.js @@ -0,0 +1,102 @@ +const JWT = require('jsonwebtoken') +const crypto = require('crypto') +const constants = require('./constants') +const { Ber } = require('asn1') +const ec_pem = require('ec-pem') + +const SALT = 'ABC' + +function Encrypt(client, options) { + function startClientboundEncryption(publicKey) { + console.warn('[encrypt] Pub key base64: ', publicKey) + const pubKeyBuf = readX509PublicKey(publicKey.key) + + const curve = 'secp384r1' + const alice = crypto.createECDH(curve) + alice.generateKeys() + const alicePEM = ec_pem(alice, curve) // https://github.com/nodejs/node/issues/15116#issuecomment-384790125 + const alicePEMPrivate = alicePEM.encodePrivateKey() + // Shared secret from bob's public key + our private key + client.sharedSecret = alice.computeSecret(pubKeyBuf) + + // Secret hash we use for packet encryption: + // From the public key of the remote and the private key + // of the local, a shared secret is generated using ECDH. + // The secret key bytes are then computed as + // sha256(server_token + shared_secret). These secret key + // bytes are 32 bytes long. + const secretHash = crypto.createHash('sha256') + secretHash.update(SALT) + secretHash.update(client.sharedSecret) + + client.secretKeyBytes = secretHash.digest() + + const x509 = writeX509PublicKey(alice.getPublicKey()) + const token = JWT.sign({ + salt: toBase64(SALT), + signedToken: alice.getPublicKey('base64') + }, alicePEMPrivate, { algorithm: 'ES384', header: { x5u: x509 } }) + + client.write('server_to_client_handshake', { + token: token + }) + + // The encryption scheme is AES/CFB8/NoPadding with the + // secret key being the result of the sha256 above and + // the IV being the first 16 bytes of this secret key. + const initial = client.secretKeyBytes.slice(0, 16) + client.startEncryption(initial) + } + + function startClientCiphers() { + + var decipher = crypto.createDecipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0, 16)) + + let customPackets = JSON.parse(JSON.stringify(require("../data/protocol"))) + + customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe_encrypted'] = 'restBuffer' + customPackets['types']['encapsulated_packet'][1][0]['type'][1]['mappings']['0xfe'] = 'mcpe_encrypted' + client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol, customPackets).types) + + client.encryptionEnabled = true + + client.on("mcpe_encrypted", packet => { + decipher.write(packet); + }); + + client.cipher = crypto.createCipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0, 16)); + } + + client.on('server.client_handshake', startClientboundEncryption) +} + +function toBase64(string) { + return Buffer.from(string).toString('base64') +} + +function readX509PublicKey(key) { + var reader = new Ber.Reader(Buffer.from(key, "base64")); + reader.readSequence(); + reader.readSequence(); + reader.readOID(); // Hey, I'm an elliptic curve + reader.readOID(); // This contains the curve type, could be useful + return Buffer.from(reader.readString(Ber.BitString, true)).slice(1); +} + +function writeX509PublicKey(key) { + var writer = new Ber.Writer(); + writer.startSequence(); + writer.startSequence(); + writer.writeOID("1.2.840.10045.2.1"); + writer.writeOID("1.3.132.0.34"); + writer.endSequence(); + writer.writeBuffer(Buffer.concat([Buffer.from([0x00]), key]), Ber.BitString); + writer.endSequence(); + return writer.buffer.toString("base64"); +} + +module.exports = { + readX509PublicKey, + writeX509PublicKey, + Encrypt +} \ No newline at end of file diff --git a/src/auth/jwt.js b/src/auth/jwt.js new file mode 100644 index 0000000..155f7fb --- /dev/null +++ b/src/auth/jwt.js @@ -0,0 +1,104 @@ +const JWT = require('jsonwebtoken') +const constants = require('./constants') +const fs = require('fs') +const { decode } = require('jwt-simple') +// import jwt from 'jwt-simple'; +// const jwt = require('jwt-simple') + +// 💗 web archive +// https://web.archive.org/web/20180917171505if_/https://confluence.yawk.at/display/PEPROTOCOL/Game+Packets#GamePackets-Login + +function mcPubKeyToPem(mcPubKeyBuffer) { + console.log(mcPubKeyBuffer) + if (mcPubKeyBuffer[0] == '-') return mcPubKeyBuffer + let pem = '-----BEGIN PUBLIC KEY-----\n' + let base64PubKey = mcPubKeyBuffer.toString('base64') + const maxLineLength = 65 + while (base64PubKey.length > 0) { + pem += base64PubKey.substring(0, maxLineLength) + '\n' + base64PubKey = base64PubKey.substring(maxLineLength) + } + pem += '-----END PUBLIC KEY-----\n' + return pem +} + +function getX5U(token) { + const [header] = token.split('.') + const hdec = Buffer.from(header, 'base64').toString('utf-8') + const hjson = JSON.parse(hdec) + return hjson.x5u +} + +function verifyAuth(chain) { + let data = {} + + // There are three JWT tokens sent to us, one signed by the client + // one signed by Mojang with the Mojang token we have and another one + // from Xbox with addition user profile data + // We verify that at least one of the tokens in the chain has been properly + // signed by Mojang by checking the x509 public key in the JWT headers + let didVerify = false + + let pubKey = mcPubKeyToPem(getX5U(chain[0])) // the first one is client signed, allow it + let finalKey = null + console.log(pubKey) + for (var token of chain) { + // const decoded = jwt.decode(token, pubKey, 'ES384') + // console.log('Decoding...', token) + const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' }) + // console.log('Decoded...') + console.log('Decoded', decoded) + + // Check if signed by Mojang key + const x5u = getX5U(token) + if (x5u == constants.PUBLIC_KEY && !data.extraData?.XUID) { + didVerify = true + console.log('verified with mojang key!', x5u) + } + + pubKey = decoded.identityPublicKey ? mcPubKeyToPem(decoded.identityPublicKey) : x5u + finalKey = decoded.identityPublicKey || finalKey // non pem + data = { ...data, ...decoded } + } + // console.log('Result', data) + + return { key: finalKey, data } +} + +function verifySkin(publicKey, token) { + // console.log('token', token) + const pubKey = mcPubKeyToPem(publicKey) + + const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' }) + + return decoded +} + +function decodeLoginJWT(authTokens, skinTokens) { + const { key, data } = verifyAuth(authTokens) + const skinData = verifySkin(key, skinTokens) + return { key, userData: data, skinData } +} + +function test() { + const loginPacket = require('./login.json') + + // console.log(loginPacket) + const authChains = JSON.parse(loginPacket.data.chain) + const skinChain = loginPacket.data.clientData + + try { + var { data, chain } = decodeLoginJWT(authChains.chain, skinChain) + } catch (e) { + console.error(e) + throw new Error('Failed to verify user') + } + + console.log('Authed') + + // console.log(loginPacket) +} + +module.exports = { decodeLoginJWT } + +// test() \ No newline at end of file diff --git a/src/auth/jwtTest.js b/src/auth/jwtTest.js new file mode 100644 index 0000000..acf5307 --- /dev/null +++ b/src/auth/jwtTest.js @@ -0,0 +1,49 @@ +function test() { + const chain = require('./sampleChain.json').chain + + let data = {} + + // There are three JWT tokens sent to us, one signed by the client + // one signed by Mojang with the Mojang token we have and another one + // from Xbox with addition user profile data + // We verify that at least one of the tokens in the chain has been properly + // signed by Mojang by checking the x509 public key in the JWT headers + let didVerify = false + + let pubKey = mcPubKeyToPem(constants.PUBLIC_KEY_NEW) + console.log(pubKey) + for (var token of chain) { + // const decoded = jwt.decode(token, pubKey, 'ES384') + console.log('Decoding...', token) + const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' }) + console.log('Decoded...') + console.log('Decoded', decoded) + + // Check if signed by Mojang key + const [header] = token.split('.') + const hdec = Buffer.from(header, 'base64').toString('utf-8') + const hjson = JSON.parse(hdec) + if (hjson.x5u == constants.PUBLIC_KEY && !data.extraData?.XUID) { + didVerify = true + console.log('verified with mojang key!', hjson.x5u) + } + + pubKey = mcPubKeyToPem(decoded.identityPublicKey) + data = { ...data, ...decoded } + } + console.log('Result', data) +} + +function test2() { + const chain = require('./login.json') + const token = chain.data.clientData + // console.log(token) + + const pubKey = mcPubKeyToPem(constants.CDATA_PUBLIC_KEY) + + const decoded = JWT.verify(token, pubKey, { algorithms: 'ES384' }) + + // console.log('Decoded', decoded) + + fs.writeFileSync('clientData.json', JSON.stringify(decoded)) +} diff --git a/src/serverTest.js b/src/serverTest.js new file mode 100644 index 0000000..df29724 --- /dev/null +++ b/src/serverTest.js @@ -0,0 +1,226 @@ +console.log('IMPORTING') +const BinaryStream = require('@jsprismarine/jsbinaryutils').default +const Listener = require('@jsprismarine/raknet/listener') +const { ProtoDef, Parser, Serializer } = require('protodef') +const BatchPacket = require('./BatchPacket') +const { EventEmitter } = require('events') +const fs = require('fs') +const cipher = require('./transforms/encryption') +const { Encrypt } = require('./auth/encryption') + +const { decodeLoginJWT } = require('./auth/jwt') +const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') +console.log('IMPORTED') +// const Zlib = require('zlib'); + +var protocol = require('../data/newproto.json').types; + +function createProtocol() { + var proto = new ProtoDef(); + proto.addTypes(require('./datatypes/minecraft')); + proto.addTypes(protocol); + + return proto; +} + +function createSerializer() { + var proto = createProtocol() + return new Serializer(proto, 'mcpe_packet'); +} + +function createDeserializer() { + var proto = createProtocol() + return new Parser(proto, 'mcpe_packet'); +} + +class Player extends EventEmitter { + constructor(server, connection, options) { + super() + this.server = server + this.connection = connection + Encrypt(this, server, options) + } + + // TODO: Move this to a protodef native type + onLogin(packet) { + let dataProto = new ProtoDef() + dataProto.addType('data_chain', ['container', [{ + 'name': 'chain', + 'type': ['pstring', { + 'countType': 'li32' + }] + }, { + 'name': 'clientData', + 'type': ['pstring', { + 'countType': 'li32' + }] + }]]) + + //FIXME: Xbox & Non-Xbox support + console.log(packet); + let pbody = packet.data.params.payload + let body = dataProto.parsePacketBuffer('data_chain', pbody) + console.log('Body', body) + + fs.writeFileSync('login.json', JSON.stringify(body)) + + // Parse login data + const authChain = JSON.parse(body.data.chain) + const skinChain = body.data.clientData + + try { + var { key, userData, chain } = decodeLoginJWT(authChain.chain, skinChain) + } catch (e) { + console.error(e) + throw new Error('Failed to verify user') + } + console.log('Verified user', 'got pub key', key, userData) + + this.emit('join', { + user: userData.extraData + }) + this.emit('server.client_handshake', { + key + }) + } + + startEncryption(iv) { + this.encryptionEnabled = true + + // this.cipher = cipher.createCipher(client.secretKeyBytes, iv) + // this.decipher = cipher.createDecipher(client.secretKeyBytes, iv) + + this.decrypt = cipher.createDecryptor(this, iv) + this.encrypt = cipher.createDecryptor(this, iv) + } + + write(name, params) { + console.log('Need to encode', name, params) + const batch = new BatchPacket() + const packet = this.server.serializer.createPacketBuffer({ name, params }) + batch.addEncodedPacket(packet) + const buf = batch.encode() + // send to raknet + const sendPacket = new EncapsulatedPacket(); + sendPacket.reliability = 0; + sendPacket.buffer = buf + + this.connection.addEncapsulatedToQueue(sendPacket, 1) + this.connection.sendQueue() + } + + sendDecryptedBatch(batch) { + + } + + sendEncryptedBatch(batch) { + + } + + onDecryptedPacket = (buf) => { + console.log('Decrypted', buf) + } + + readPacket(packet) { + console.log('packet', packet) + const des = this.server.deserializer.parsePacketBuffer(packet) + console.log(des) + switch (des.data.name) { + case 'login': + console.log(des) + this.onLogin(des) + default: + this.emit(des.data.name, des.data.params) + } + } + + handle(buffer) { // handle encapsulated + if (buffer[0] == 0xfe) { // wrapper + + if (this.encryptionEnabled) { + this.decrypt(buffer.slice(1)) + } else { + const stream = new BinaryStream(buffer) + const batch = new BatchPacket(stream) + batch.decode() + const packets = batch.getPackets() + console.log('Reading ', packets.length, 'packets') + for (var packet of packets) { + this.readPacket(packet) + } + } + } + } +} + +class Server extends EventEmitter { + constructor(options = {}) { + // const customTypes = require('./datatypes/minecraft') + // this.batchProto = new ProtoDef() + // this.batchProto.addTypes(customTypes) + // this.batchProto.addType('insideBatch', ['endOfArray', { + // 'type': ['buffer', { + // 'countType': 'varint', + // }] + // }]) + + super() + + this.serializer = createSerializer() + this.deserializer = createDeserializer() + + this.clients = {} + } + + getAddrHash(inetAddr) { + return inetAddr.address + '/' + inetAddr.port + } + + onOpenConnection = (conn) => { + console.log('Got connection', conn) + this.clients[this.getAddrHash(conn.address)] = new Player(this, conn) + } + + onCloseConnection = (inetAddr, reason) => { + console.log('Close connection', inetAddr, reason) + delete this.clients[this.getAddrHash(inetAddr)] + } + + onEncapsulated = (encapsulated, inetAddr) => { + console.log('Encapsulated', encapsulated, inetAddr) + const buffer = encapsulated.buffer + const client = this.clients[this.getAddrHash(inetAddr)] + if (!client) { + console.warn('packet from unknown inet addr', inetAddr.address, inetAddr.port) + return + } + client.handle(buffer) + } + + // write(name, params) { + // console.log('Need to encode', name, params) + // const batch = new BatchPacket() + // const packet = this.serializer.createPacketBuffer({ name, params }) + // batch.addEncodedPacket(packet) + // const buf = batch.encode() + // // send to raknet + // this.listener.sendBuffer() + // } + + async create(serverIp, port) { + this.listener = new Listener(this) + this.raknet = await this.listener.listen(serverIp, port) + console.log('Listening on', serverIp, port) + + this.raknet.on('openConnection', this.onOpenConnection) + this.raknet.on('closeConnection', this.onCloseConnection) + this.raknet.on('encapsulated', this.onEncapsulated) + + this.raknet.on('raw', (buffer, inetAddr) => { + console.log('Raw packet', buffer, inetAddr) + }) + } +} + +let server = new Server() +server.create('0.0.0.0', 19130) \ No newline at end of file diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js new file mode 100644 index 0000000..aa539f0 --- /dev/null +++ b/src/transforms/encryption.js @@ -0,0 +1,108 @@ +const Transform = require('readable-stream').Transform +const crypto = require('crypto') +const aesjs = require('aes-js') +const Zlib = require('zlib') + +const CIPHER = 'aes-256-cfb8' + +function createCipher(secret, initialValue) { + if (crypto.getCiphers().includes(CIPHER)) { + return crypto.createCipheriv(CIPHER, secret, initialValue) + } + return new Cipher(secret, initialValue) +} + +function createDecipher(secret, initialValue) { + if (crypto.getCiphers().includes(CIPHER)) { + return crypto.createDecipheriv(CIPHER, secret, initialValue) + } + return new Decipher(secret, initialValue) +} + +class Cipher extends Transform { + constructor(secret, iv) { + super() + this.aes = new aesjs.ModeOfOperation.cfb(secret, iv, 1) // eslint-disable-line new-cap + } + + _transform(chunk, enc, cb) { + try { + const res = this.aes.encrypt(chunk) + cb(null, res) + } catch (e) { + cb(e) + } + } +} + +class Decipher extends Transform { + constructor(secret, iv) { + super() + this.aes = new aesjs.ModeOfOperation.cfb(secret, iv, 1) // eslint-disable-line new-cap + } + + _transform(chunk, enc, cb) { + try { + const res = this.aes.decrypt(chunk) + cb(null, res) + } catch (e) { + cb(e) + } + } +} + +function computeCheckSum(packetPlaintext, sendCounter, secretKeyBytes) { + let digest = crypto.createHash('sha256'); + let counter = Buffer.alloc(8) + // writeLI64(sendCounter, counter, 0); + counter.writeBigInt64LE(sendCounter, 0) + console.log('Send counter' , counter) + digest.update(counter); + digest.update(packetPlaintext); + digest.update(secretKeyBytes); + let hash = digest.digest(); + + return hash.slice(0, 8); +} + +function createEncryptor(client, iv) { + client.cipher = createCipher(client.secretKeyBytes, iv) + +} + +function createDecryptor(client, iv) { + client.decipher = createDecipher(client.secretKeyBytes, iv) + client.receiveCounter = client.receiveCounter || 0n + + const decryptor = new Transform({ + transform(chunk, encoding, cb) { + console.log('Got transform', chunk) + const packet = chunk.slice(0, chunk.length - 8); + const checksum = chunk.slice(chunk.length - 8); + const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) + // const computedCheckSum1 = computeCheckSum(packet, 1n, client.secretKeyBytes) + // console.log('Checksums', checksum) + // console.log('Checksum1', computedCheckSum) + // console.log('Checksum2', computedCheckSum1) + console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') + client.receiveCounter++ + if (checksum.toString("hex") == computedCheckSum.toString("hex")) this.push(packet) + else console.log('FAILED', checksum.toString("hex"), computedCheckSum.toString("hex")) + // else process.exit(`Checksum mismatch ${checksum.toString("hex")} - ${computedCheckSum.toString("hex")}`) // TODO: remove + cb() + } + }) + + client.decipher.pipe(decryptor) + .pipe(Zlib.createInflateRaw({ chunkSize: 1024 * 1024 * 2 })) + .on('data', client.onDecryptedPacket) + // .on('end', () => console.log('Finished!')) + + return (blob) => { + client.decipher.write(blob) + } +} + +module.exports = { + createCipher, createDecipher, createEncryptor, createDecryptor +} From d578eae98f053e17a0507e2d016e67f470b22027 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 30 Jan 2021 01:40:34 -0500 Subject: [PATCH 075/106] add encryptor --- data/newproto.json | 166 +++++++++++++++++------------- package.json | 4 +- src/BatchPacket.js | 8 -- src/serverTest.js | 191 +++++++++++++++++++++++------------ src/transforms/encryption.js | 46 +++++++-- 5 files changed, 264 insertions(+), 151 deletions(-) diff --git a/data/newproto.json b/data/newproto.json index ae404a4..81d1621 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -12,6 +12,12 @@ "countType": "varint" } ], + "LittleString": [ + "pstring", + { + "countType": "li32" + } + ], "varint32": "varint", "varint64": "varint", "bool": "i8", @@ -22,74 +28,86 @@ "MapInfo": "native", "nbt": "native", "BehaviourPackInfos": [ - "container", - [ - { - "name": "uuid", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "size", - "type": "lu64" - }, - { - "name": "content_key", - "type": "string" - }, - { - "name": "sub_pack_name", - "type": "string" - }, - { - "name": "content_identity", - "type": "string" - }, - { - "name": "has_scripts", - "type": "bool" - } - ] + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "size", + "type": "lu64" + }, + { + "name": "content_key", + "type": "string" + }, + { + "name": "sub_pack_name", + "type": "string" + }, + { + "name": "content_identity", + "type": "string" + }, + { + "name": "has_scripts", + "type": "bool" + } + ] + ] + } ], "TexturePackInfos": [ - "container", - [ - { - "name": "uuid", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "size", - "type": "lu64" - }, - { - "name": "content_key", - "type": "string" - }, - { - "name": "sub_pack_name", - "type": "string" - }, - { - "name": "content_identity", - "type": "string" - }, - { - "name": "has_scripts", - "type": "bool" - }, - { - "name": "rtx_enabled", - "type": "bool" - } - ] + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "size", + "type": "lu64" + }, + { + "name": "content_key", + "type": "string" + }, + { + "name": "sub_pack_name", + "type": "string" + }, + { + "name": "content_identity", + "type": "string" + }, + { + "name": "has_scripts", + "type": "bool" + }, + { + "name": "rtx_enabled", + "type": "bool" + } + ] + ] + } ], "ResourcePackIdVersions": [ "container", @@ -2307,8 +2325,16 @@ "type": "i32" }, { - "name": "payload", - "type": "ByteArray" + "name": "payload_size", + "type": "varint" + }, + { + "name": "chain", + "type": "LittleString" + }, + { + "name": "client_data", + "type": "LittleString" } ] ], @@ -2359,11 +2385,11 @@ "type": "bool" }, { - "name": "behahaviorpackinfos", + "name": "behaviour_packs", "type": "BehaviourPackInfos" }, { - "name": "texturepacks", + "name": "texture_packs", "type": "TexturePackInfos" } ] diff --git a/package.json b/package.json index 12fc42f..6c7aa73 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pocket-minecraft-protocol", - "version": "2.4.0", - "description": "Parse and serialize Minecraft Pocket Edition packets", + "version": "3.0.0", + "description": "Parse and serialize Minecraft Bedrock Edition packets", "main": "index.js", "scripts": { "build": "babel src --out-dir dist", diff --git a/src/BatchPacket.js b/src/BatchPacket.js index 5cffd28..98de0c4 100644 --- a/src/BatchPacket.js +++ b/src/BatchPacket.js @@ -44,13 +44,6 @@ class BatchPacket { return ret } - encodePayload() { - } - - addEncoded(packet) { - - } - addEncodedPacket(packet) { this.stream.writeUnsignedVarInt(packet.byteLength) this.stream.append(packet) @@ -71,7 +64,6 @@ class BatchPacket { } static getPackets(stream) { - stream.buffer = this.payload const packets = [] while (!stream.feof()) { const length = stream.readUnsignedVarInt() diff --git a/src/serverTest.js b/src/serverTest.js index df29724..eece259 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -33,6 +33,17 @@ function createDeserializer() { return new Parser(proto, 'mcpe_packet'); } +const PLAY_STATUS = { + 'LoginSuccess': 0, + 'LoginFailedClient': 1, + 'LoginFailedServer': 2, + 'PlayerSpawn': 3, + 'LoginFailedInvalidTenant': 4, + 'LoginFailedVanillaEdu': 5, + 'LoginFailedEduVanilla': 6, + 'LoginFailedServerFull': 7 +} + class Player extends EventEmitter { constructor(server, connection, options) { super() @@ -41,32 +52,28 @@ class Player extends EventEmitter { Encrypt(this, server, options) } - // TODO: Move this to a protodef native type - onLogin(packet) { - let dataProto = new ProtoDef() - dataProto.addType('data_chain', ['container', [{ - 'name': 'chain', - 'type': ['pstring', { - 'countType': 'li32' - }] - }, { - 'name': 'clientData', - 'type': ['pstring', { - 'countType': 'li32' - }] - }]]) + getData() { + return this.userData + } - //FIXME: Xbox & Non-Xbox support - console.log(packet); - let pbody = packet.data.params.payload - let body = dataProto.parsePacketBuffer('data_chain', pbody) + onLogin(packet) { + let body = packet.data console.log('Body', body) - fs.writeFileSync('login.json', JSON.stringify(body)) + const clientVer = body.protocol_version + if (this.server.options.version) { + if (this.server.options.version < clientVer) { + this.sendDisconnectStatus(PLAY_STATUS.LoginFailedClient) + return + } + } else if (clientVer < MIN_VERSION) { + this.sendDisconnectStatus(PLAY_STATUS.LoginFailedClient) + return + } // Parse login data - const authChain = JSON.parse(body.data.chain) - const skinChain = body.data.clientData + const authChain = JSON.parse(body.params.chain) + const skinChain = body.params.client_data try { var { key, userData, chain } = decodeLoginJWT(authChain.chain, skinChain) @@ -76,29 +83,47 @@ class Player extends EventEmitter { } console.log('Verified user', 'got pub key', key, userData) - this.emit('join', { - user: userData.extraData - }) - this.emit('server.client_handshake', { - key - }) + this.emit('login', { user: userData.extraData }) // emit events for user + this.emit('server.client_handshake', { key }) // internal so we start encryption + + this.userData = userData.extraData + this.version = clientVer + } + + sendDisconnectStatus(play_status) { + this.write('play_status', { status: play_status }) + this.connection.close() + } + + // After sending Server to Client Handshake, this handles the client's + // Client to Server handshake response. This indicates successful encryption + onHandshake() { + // https://wiki.vg/Bedrock_Protocol#Play_Status + this.write('play_status', { status: PLAY_STATUS.LoginSuccess }) + this.emit('join') } startEncryption(iv) { this.encryptionEnabled = true - // this.cipher = cipher.createCipher(client.secretKeyBytes, iv) - // this.decipher = cipher.createDecipher(client.secretKeyBytes, iv) - this.decrypt = cipher.createDecryptor(this, iv) - this.encrypt = cipher.createDecryptor(this, iv) + this.encrypt = cipher.createEncryptor(this, iv) } - write(name, params) { + write(name, params) { // TODO: Batch console.log('Need to encode', name, params) const batch = new BatchPacket() const packet = this.server.serializer.createPacketBuffer({ name, params }) batch.addEncodedPacket(packet) + + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } + } + + sendDecryptedBatch(batch) { const buf = batch.encode() // send to raknet const sendPacket = new EncapsulatedPacket(); @@ -109,29 +134,50 @@ class Player extends EventEmitter { this.connection.sendQueue() } - sendDecryptedBatch(batch) { - + sendEncryptedBatch(batch) { + const buf = batch.stream.getBuffer() + console.log('Sending encrypted batch', batch) + this.encrypt(buf) } - sendEncryptedBatch(batch) { - + // These are callbacks called from encryption.js + onEncryptedPacket = (buf) => { + console.log('ENC BUF', buf) + const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header + const sendPacket = new EncapsulatedPacket(); + sendPacket.reliability = 0 + sendPacket.buffer = packet + console.log('Sending wrapped encrypted batch', packet) + this.connection.addEncapsulatedToQueue(sendPacket) } onDecryptedPacket = (buf) => { console.log('Decrypted', buf) + + const stream = new BinaryStream(buf) + const packets = BatchPacket.getPackets(stream) + + for (const packet of packets) { + this.readPacket(packet) + } } readPacket(packet) { console.log('packet', packet) const des = this.server.deserializer.parsePacketBuffer(packet) - console.log(des) + console.log('->', des) switch (des.data.name) { case 'login': console.log(des) this.onLogin(des) + return + case 'client_to_server_handshake': + this.onHandshake() default: - this.emit(des.data.name, des.data.params) + console.log('ignoring, unhandled') } + this.emit(des.data.name, des.data.params) + } handle(buffer) { // handle encapsulated @@ -147,29 +193,36 @@ class Player extends EventEmitter { console.log('Reading ', packets.length, 'packets') for (var packet of packets) { this.readPacket(packet) - } + } } } } } +// Minimum supported version (< will be kicked) +const MIN_VERSION = 422 +// Currently supported verson +const CURRENT_VERSION = 422 + +const defaultServerOptions = { + // https://minecraft.gamepedia.com/Protocol_version#Bedrock_Edition_2 + version: CURRENT_VERSION, +} + class Server extends EventEmitter { - constructor(options = {}) { - // const customTypes = require('./datatypes/minecraft') - // this.batchProto = new ProtoDef() - // this.batchProto.addTypes(customTypes) - // this.batchProto.addType('insideBatch', ['endOfArray', { - // 'type': ['buffer', { - // 'countType': 'varint', - // }] - // }]) - + constructor(options) { super() - + this.options = { ...defaultServerOptions, options } this.serializer = createSerializer() this.deserializer = createDeserializer() - this.clients = {} + this.validateOptions() + } + + validateOptions() { + if (this.options.version < defaultServerOptions.version) { + throw new Error(`Unsupported protocol version < ${defaultServerOptions.version}: ${this.options.version}`) + } } getAddrHash(inetAddr) { @@ -178,7 +231,10 @@ class Server extends EventEmitter { onOpenConnection = (conn) => { console.log('Got connection', conn) - this.clients[this.getAddrHash(conn.address)] = new Player(this, conn) + const player = new Player(this, conn) + this.clients[this.getAddrHash(conn.address)] = player + + this.emit('connect', { client: player }) } onCloseConnection = (inetAddr, reason) => { @@ -197,16 +253,6 @@ class Server extends EventEmitter { client.handle(buffer) } - // write(name, params) { - // console.log('Need to encode', name, params) - // const batch = new BatchPacket() - // const packet = this.serializer.createPacketBuffer({ name, params }) - // batch.addEncodedPacket(packet) - // const buf = batch.encode() - // // send to raknet - // this.listener.sendBuffer() - // } - async create(serverIp, port) { this.listener = new Listener(this) this.raknet = await this.listener.listen(serverIp, port) @@ -222,5 +268,22 @@ class Server extends EventEmitter { } } -let server = new Server() -server.create('0.0.0.0', 19130) \ No newline at end of file +let server = new Server({ + +}) +server.create('0.0.0.0', 19130) + +server.on('connect', (data) => { + // TODO: send other packets needed to login... + const client = data.client + client.on('join', () => { + console.log('Client joined', client.getData()) + + client.write('resource_packs_info', { + 'must_accept': false, + 'has_scripts': false, + 'behaviour_packs': [], + 'texture_packs': [] + }) + }) +}) \ No newline at end of file diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index aa539f0..92acd20 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -1,4 +1,4 @@ -const Transform = require('readable-stream').Transform +const { PassThrough, Transform } = require('readable-stream') const crypto = require('crypto') const aesjs = require('aes-js') const Zlib = require('zlib') @@ -56,7 +56,7 @@ function computeCheckSum(packetPlaintext, sendCounter, secretKeyBytes) { let counter = Buffer.alloc(8) // writeLI64(sendCounter, counter, 0); counter.writeBigInt64LE(sendCounter, 0) - console.log('Send counter' , counter) + // console.log('Send counter', counter) digest.update(counter); digest.update(packetPlaintext); digest.update(secretKeyBytes); @@ -67,7 +67,43 @@ function computeCheckSum(packetPlaintext, sendCounter, secretKeyBytes) { function createEncryptor(client, iv) { client.cipher = createCipher(client.secretKeyBytes, iv) + client.sendCounter = client.sendCounter || 0n + // A packet is encrypted via AES256(plaintext + SHA256(send_counter + plaintext + secret_key)[0:8]). + // The send counter is represented as a little-endian 64-bit long and incremented after each packet. + + const encryptor = new Transform({ + transform(chunk, enc, cb) { + console.log('Encryptor called', chunk) + // Here we concat the payload + checksum before the encryption + const packet = Buffer.concat([chunk, computeCheckSum(chunk, client.sendCounter, client.secretKeyBytes)]) + client.sendCounter++ + this.push(packet) + cb() + } + }) + + // https://stackoverflow.com/q/25971715/11173996 + // TODO: Fix deflate stream - for some reason using .pipe() doesn't work here + // so we deflate it outside the pipe + const compressor = Zlib.createDeflateRaw({ level: 7, chunkSize: 1024 * 1024 * 2, flush: Zlib.Z_SYNC_FLUSH }) + const writableStream = new PassThrough() + + writableStream + // .pipe(compressor) + .pipe(encryptor).pipe(client.cipher).on('data', client.onEncryptedPacket) + + return (blob) => { + // console.log('ENCRYPTING') + Zlib.deflateRaw(blob, { level: 7 }, (err, res) => { + if (err) { + console.error(err) + throw new Error(`Failed to deflate stream`) + } + writableStream.write(res) + }) + // writableStream.write(blob) + } } function createDecryptor(client, iv) { @@ -80,10 +116,6 @@ function createDecryptor(client, iv) { const packet = chunk.slice(0, chunk.length - 8); const checksum = chunk.slice(chunk.length - 8); const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) - // const computedCheckSum1 = computeCheckSum(packet, 1n, client.secretKeyBytes) - // console.log('Checksums', checksum) - // console.log('Checksum1', computedCheckSum) - // console.log('Checksum2', computedCheckSum1) console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') client.receiveCounter++ if (checksum.toString("hex") == computedCheckSum.toString("hex")) this.push(packet) @@ -96,7 +128,7 @@ function createDecryptor(client, iv) { client.decipher.pipe(decryptor) .pipe(Zlib.createInflateRaw({ chunkSize: 1024 * 1024 * 2 })) .on('data', client.onDecryptedPacket) - // .on('end', () => console.log('Finished!')) + // .on('end', () => console.log('Finished!')) return (blob) => { client.decipher.write(blob) From 040887e9df372a9d2f99a350f87c52ba1ad81b77 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 30 Jan 2021 02:36:34 -0500 Subject: [PATCH 076/106] fix zlib decryption issue --- data/newproto.json | 8 ++-- src/serverTest.js | 9 ++-- src/transforms/encryption.js | 91 +++++++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 36 deletions(-) diff --git a/data/newproto.json b/data/newproto.json index 81d1621..2af7f0b 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -30,7 +30,7 @@ "BehaviourPackInfos": [ "array", { - "countType": "varint", + "countType": "li16", "type": [ "container", [ @@ -69,7 +69,7 @@ "TexturePackInfos": [ "array", { - "countType": "varint", + "countType": "li16", "type": [ "container", [ @@ -2402,11 +2402,11 @@ "type": "bool" }, { - "name": "behaviorpackidversions", + "name": "behavior_pack_id_versions", "type": "ResourcePackIdVersions" }, { - "name": "resourcepackidversions", + "name": "resource_pack_id_versions", "type": "ResourcePackIdVersions" }, { diff --git a/src/serverTest.js b/src/serverTest.js index eece259..226cd22 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -184,6 +184,7 @@ class Player extends EventEmitter { if (buffer[0] == 0xfe) { // wrapper if (this.encryptionEnabled) { + // console.log('READING ENCRYPTED PACKET', buffer) this.decrypt(buffer.slice(1)) } else { const stream = new BinaryStream(buffer) @@ -247,8 +248,7 @@ class Server extends EventEmitter { const buffer = encapsulated.buffer const client = this.clients[this.getAddrHash(inetAddr)] if (!client) { - console.warn('packet from unknown inet addr', inetAddr.address, inetAddr.port) - return + throw new Error(`packet from unknown inet addr: ${inetAddr.address}/${inetAddr.port}`) } client.handle(buffer) } @@ -273,9 +273,8 @@ let server = new Server({ }) server.create('0.0.0.0', 19130) -server.on('connect', (data) => { - // TODO: send other packets needed to login... - const client = data.client +server.on('connect', ({ client }) => { + /** @type {Player} */ client.on('join', () => { console.log('Client joined', client.getData()) diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index 92acd20..491fe09 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -72,9 +72,9 @@ function createEncryptor(client, iv) { // A packet is encrypted via AES256(plaintext + SHA256(send_counter + plaintext + secret_key)[0:8]). // The send counter is represented as a little-endian 64-bit long and incremented after each packet. - const encryptor = new Transform({ + const addChecksum = new Transform({ // append checksum transform(chunk, enc, cb) { - console.log('Encryptor called', chunk) + console.log('Encryptor: checking checksum', chunk) // Here we concat the payload + checksum before the encryption const packet = Buffer.concat([chunk, computeCheckSum(chunk, client.sendCounter, client.secretKeyBytes)]) client.sendCounter++ @@ -84,51 +84,74 @@ function createEncryptor(client, iv) { }) // https://stackoverflow.com/q/25971715/11173996 - // TODO: Fix deflate stream - for some reason using .pipe() doesn't work here - // so we deflate it outside the pipe - const compressor = Zlib.createDeflateRaw({ level: 7, chunkSize: 1024 * 1024 * 2, flush: Zlib.Z_SYNC_FLUSH }) - const writableStream = new PassThrough() + // TODO: Fix deflate stream - for some reason using .pipe() doesn't work using zlib.createDeflateRaw() + // so we define our own compressor transform + // const compressor = Zlib.createDeflateRaw({ level: 7, chunkSize: 1024 * 1024 * 2, flush: Zlib.Z_SYNC_FLUSH }) + const compressor = new Transform({ + transform(chunk, enc, cb) { + Zlib.deflateRaw(chunk, { level: 7 }, (err, res) => { + if (err) { + console.error(err) + throw new Error(`Failed to deflate stream`) + } + this.push(res) + cb() + }) + } + }) - writableStream - // .pipe(compressor) - .pipe(encryptor).pipe(client.cipher).on('data', client.onEncryptedPacket) + + const stream = new PassThrough() + + stream + .pipe(compressor) + .pipe(addChecksum).pipe(client.cipher).on('data', client.onEncryptedPacket) return (blob) => { - // console.log('ENCRYPTING') - Zlib.deflateRaw(blob, { level: 7 }, (err, res) => { - if (err) { - console.error(err) - throw new Error(`Failed to deflate stream`) - } - writableStream.write(res) - }) - // writableStream.write(blob) + stream.write(blob) } } + function createDecryptor(client, iv) { client.decipher = createDecipher(client.secretKeyBytes, iv) client.receiveCounter = client.receiveCounter || 0n - const decryptor = new Transform({ + const verifyChecksum = new Transform({ // verify checksum transform(chunk, encoding, cb) { - console.log('Got transform', chunk) + console.log('Decryptor: checking checksum', chunk) const packet = chunk.slice(0, chunk.length - 8); const checksum = chunk.slice(chunk.length - 8); const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') client.receiveCounter++ - if (checksum.toString("hex") == computedCheckSum.toString("hex")) this.push(packet) - else console.log('FAILED', checksum.toString("hex"), computedCheckSum.toString("hex")) - // else process.exit(`Checksum mismatch ${checksum.toString("hex")} - ${computedCheckSum.toString("hex")}`) // TODO: remove + if (checksum.toString("hex") == computedCheckSum.toString("hex")) { + this.push(packet) + } else { + throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) + } + // console.log('Calling cb') cb() } }) - client.decipher.pipe(decryptor) - .pipe(Zlib.createInflateRaw({ chunkSize: 1024 * 1024 * 2 })) - .on('data', client.onDecryptedPacket) - // .on('end', () => console.log('Finished!')) + const inflator = new Transform({ + transform(chunk, enc, cb) { + // console.log('INFLATING') + Zlib.inflateRaw(chunk, { chunkSize: 1024 * 1024 * 2 }, (err, buf) => { + if (err) throw err + this.push(buf) + cb() + }) + } + }) + + client.decipher.pipe(verifyChecksum) + .pipe(inflator) + // .pipe(Zlib.createInflateRaw({ chunkSize: 1024 * 1024 * 2 })) + .on('data', (...args) => client.onDecryptedPacket(...args)) + .on('end', () => console.log('Decryptor: finish pipeline')) + return (blob) => { client.decipher.write(blob) @@ -138,3 +161,17 @@ function createDecryptor(client, iv) { module.exports = { createCipher, createDecipher, createEncryptor, createDecryptor } + +function testDecrypt() { + const client = { + secretKeyBytes: Buffer.from('ZOBpyzki/M8UZv5tiBih048eYOBVPkQE3r5Fl0gmUP4=', 'base64'), + onDecryptedPacket: (...data) => console.log('Decrypted', data) + } + const iv = Buffer.from('ZOBpyzki/M8UZv5tiBih0w==', 'base64') + + const decrypt = createDecryptor(client, iv) + console.log('Dec', decrypt(Buffer.from('4B4FCA0C2A4114155D67F8092154AAA5EF', 'hex'))) + console.log('Dec 2', decrypt(Buffer.from('DF53B9764DB48252FA1AE3AEE4', 'hex'))) +} + +// testDecrypt() \ No newline at end of file From d92a38d3cd21a97c775f4a93a0ccd83251aa48d6 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 3 Feb 2021 13:01:51 -0500 Subject: [PATCH 077/106] add creativeitems, biome definitions --- data/biome_definitions.nbt | Bin 0 -> 37626 bytes data/creativeitems.json | 4898 ++++++++++++++++++++++++++++++++++++ src/datatypes/minecraft.js | 47 +- 3 files changed, 4924 insertions(+), 21 deletions(-) create mode 100644 data/biome_definitions.nbt create mode 100644 data/creativeitems.json diff --git a/data/biome_definitions.nbt b/data/biome_definitions.nbt new file mode 100644 index 0000000000000000000000000000000000000000..68705c5d4f97c43f712894fcf5f25cb07bcf5892 GIT binary patch literal 37626 zcmeHQ+m74D8CKVlEOF24-5!z_XoLX0F#^Zii`GEaet-gffFK|!X|!TOkqeUY)-eM3 z0eaE9*16~t^sW!!K7joceUbj0gE&Xdkdii9m(EQrYp9v;KOg3&*YOU=!D5^w{i zzvL*M!n4uz8u@t|#MvxKVQcUmZ*MT1B=IyX{_?Nx>k*v8PiCWMU%wtD_{WoU^z6&W zqii|;7ESWevnP*7Im+OFM)M%^$6>O7X9m}!$D@}4AOoKh#6~|nZvKd5f`S-7A&6hC zyB|1gv0-sPaEuy9nk3P5tq07*D9YA)!UA0f>pftZ12?XBjB%Jw=A$3Jf&aV*7r=i0 zO^{__eC@|5yq=GfG}{{Emq`vozCzaqoZ;rS@lQ| zL?3^bTP=&tunXLn4ZMC3gZM>#vbs-x`r#spvmB+vmAv$$wZssk_^ z26fOeNc4dy(LIde8gdN=J`1AUpQ0!aG8c(1%zZ-xk3EGd0}o$#AsYA>9q+T!z{e<` zqg1i(z2iJcuTk#9Ny2Vq_p_VeHukTi)%j50yzY7gEUqhK<3p~;8$ z@2?utq*yBRny|GG@BgGYUGf5IZotA7J67#W_cllu)~9+0*s}V>RdG4@k8gj~)Y&YS z%Eu6Ph`-Rx*}S0cCn}EOQx7=v_8#zNwo{sKi|s$-VUbP$@M3{o8k6I2E-WVBot8gs zVr!;n_QweM^I#l;+XS8nI6i$s9+k*;^fU*#&s44k{u2Rstfzfv_>ZWXH^NU8e-k29 z?8}81g*s@gYCw}zsejP3uBwIsB=DpN%0r6w`O3}Z42Qt1y5IG*f^!cMGO`e3o;7ju zim=dkHdQ~qecRMj6-z7m2YB-<(R~0{#VtQ@p3NaZHYri=jCR#Ytzfsng<)(6wX_>1 zKZb*U7j^^Jp{YO?ODh4zU)Z7z?3ZW`&(jdnH`Nrtpzv!Ps3xs38N7i&uO41ypqdsH zLbW^yuLBpVZPR0e{k>}_22P&KfTsX4Y^!7k%cqg7#R=987?iqx%Ne&+F`L5;iYxPU zF#XNW4WX>y!0BLCPJEApKLen3A(J`5wjouF$e`XMRDYH>YCbOwFpLW_lL1=o4DF zQdEWN5vFLg{0p=O(&kP+X_1ZPU3G#^uOC1yS8d+%YUGzIN=yv!e^xdQg zx?{-EZ=z)eDISD4wc?zkbJA~njH&y!mWl(yU3C)^M|7E*l=w|c;wS@_(~(#fFzRXd zsfaVv&1C_kRErus3iR7W9bq{0fT=Ys5=~AnvEV&CJ3DoCro+kthk|x-!C}kghbtw% z+M=EKw`eD{O@f!&4!;nTaM@Prlb*#@@8Xj$o<1Rep8oLreJXbO{Jz06zx?7! z(}uY-fyi>-oNIx{U_82}n!ND2P^Tc4%#iVRuy?kK{e^hmwd_pGBDl4(GS=A7@+3y2 zg2|i*SY_1Sq@_|+Jxre&>=)GeRL!8_>z&kKZoy}Dv7jEttCCFNDeHkAERtmmneey{ z;(E#2MbHh*$NG8om@s2n2NI*c+C@}c6I(=Ono7yP74>WBud3}imaw=PSBu1xDvpi# z+Ipg0B&LDIne11h)P&OyXHjws4F>MzupMc2^7sxO@f6JLSn$yHH&MoOVU4>6!d1@o zZI+vM=?)0T)Xfu!l(IV(Ot|Hr49125K29`%(U#$a>u#i^ zdcapFOAfVIJ;N%q!@O?Yjr|}lKe@0nBy_jg5~o%MH{l}J>M`uoVkV~%2s*qd;Ka7v zz1N+iC~^exZZqoJZU(_{)NKY?^#mNz?vF!y2jv!ScA)HtbaxatOVb64Ps>IS+Wx^` z1fl=R-2tIjL*%9rd-dV4Nba)`$o1OJM=lcsDiaR?8=D)g6%DVfm^cc^E+T43bcvTw zRxO;?Dv8KxoRP5HJ2@@EgzMblcYMXiQZN?uJ@<>%DTZ45ljjwV?3_BaDpK`;ZcOv0 zIn%tcc5Cl|Y4WHTaZATBZqX$gm7;w^Fs)N@nr+>tw2b@fXy>W<5 zI5?ma4lw4N{ogl(r!FJIz+f9eGBTkx*Tp@Xy zwS>HAyk6@8t)4N@G_VyuA90gW)Lgtx3v`QOkx>=cwSex|TW!!zI1zgv>iG<w|07j zC(dkoFriJBB`IFhL_eapCHTsui*!Touz6n9J_Vz3UbXtloaV4xzN9+etwX9@Y@!+~ z9NO-)ss}z|*X-JhkK&LE37C=wmO8p|or!jXP26-W(wH!+)_F|H_NG1IaXxZ+dW-Gy ze>U8zs&^dTQCcQAn zDNb7|*(>(zkJDEZRIakvW6Trfw@vKW$KO+hUtl`mnitAdFm6*WvVPaBXHb1CW*3gl zy!=x4*^hsKX#zKra}+Fh5dd$C&c}a6G1T7Gt0zzt$hCx0Bh~d1+_YBPIOddPZq3_# zVw2PAD)^r5D!8-_n|3+pIaxJib$po-O{|ZY196UCFIcPS$hB?DtnX7bJX+|jB$_bpXdfu*grliqxA%i7t3s(CdtAN zvnYtCZXj&0r@QDtPy$J}96|LgFi6=52lercgp&I#oNHTdik`bCizE?#xMX0#FVP-c z|EvGEG%|tQuL2p<*$y=+5V=9S)zVv2_TO+*vvwk(F7e%4|n`dq4h3(_l0>qt6uefNBEq}2ne6sODAk7rf{vgq^y24CU|j{%=k&RjOkng zGODk9q>1`0AID#iW(-m4QbuUr;1$IK#g67(7mbd0z%>Slipw$$ z^9uC6gN{WTefjIB#;MbRVe3*Q)qs;!Owl4#a*?K-qWdkcw<}k(RsMGLl`1Dhk>lA# zv&$i;y^gJJ?+|>=8BB}c-Kiw&>18p#UFl_OMphX_xvrJXyW-_%d7E_7Qps0#x+mAcd!orhWQGKk}!ybcQ$VpTBR^oEm@ zx$-)!S)F5wNHMp!sFIZ`$HxAvmCm>42GnAzzQc+xyz`(1N&ZzA&W5miYn^%@-v3ph zq=B=U8^w;#Sh|#QEeyI}@K!KTvN^)A#l`}-DK7Z~u4!*ZM@%P51SRWZ;tLa#6!;Pijh+aJR{4j98w zyaT={()0$?iGCwBJg++^wB@<2X-p%C1%}!OX*aVuoh6?mOhKxf?fz?zIb&vIw;MV2v zcb#^SIhYP6XY#3wvQ<;z9BmJ?+h75L?V4ELrm55<12)?L1H9^LbzF*LeDGjNtDLT2 zRt=P`JEJ=oPLdd27#=3^KYK#YFxRyMs?$$qqi0{g9+fS1^-8hiJp$|X@8DNI%Qx2R z^%3DrNzuUbSU79bQ_=otcv#aXXzt+GJJG6$Cv2kLGd7G$ISgqt^!}#lFm)xa?r`k> z_q~m<0J+A$nS-uD!eSo4TANt$K!f+5@H0iqC=ROnm5HX(JaB6a7RnsI^|1C6{1ULw zsvE6pNf!eRT77E{v~HV*buffer.length) + if (offset + 16 > buffer.length) throw new PartialReadError(); return { - value: UUID.stringify(buffer.slice(offset,16+offset)), + value: UUID.stringify(buffer.slice(offset, 16 + offset)), size: 16 }; } function writeUUID(value, buffer, offset) { - const buf=UUID.parse(value); - buf.copy(buffer,offset); + const buf = UUID.parse(value); + buf.copy(buffer, offset); return offset + 16; } function readNbt(buffer, offset) { - return nbt.protoLE.read(buffer,offset,"nbt"); + return proto.read(buffer, offset, "nbt") } function writeNbt(value, buffer, offset) { - return nbt.protoLE.write(value,buffer,offset,"nbt"); + return proto.write(value, buffer, offset, "nbt") } function sizeOfNbt(value) { - return nbt.protoLE.sizeOf(value,"nbt"); + return proto.sizeOf(value, "nbt") } function readEntityMetadata(buffer, offset, _ref) { @@ -74,7 +77,7 @@ function sizeOfEntityMetadata(value, _ref3) { } function readIpAddress(buffer, offset) { - var address = buffer[offset] + '.' + buffer[offset+1] + '.' + buffer[offset+2] + '.' + buffer[offset+3]; + var address = buffer[offset] + '.' + buffer[offset + 1] + '.' + buffer[offset + 2] + '.' + buffer[offset + 3]; return { size: 4, value: address @@ -84,7 +87,7 @@ function readIpAddress(buffer, offset) { function writeIpAddress(value, buffer, offset) { var address = value.split('.'); - address.forEach(function(b) { + address.forEach(function (b) { buffer[offset] = parseInt(b); offset++; }); @@ -93,10 +96,10 @@ function writeIpAddress(value, buffer, offset) { } function readEndOfArray(buffer, offset, typeArgs) { - var type=typeArgs.type; + var type = typeArgs.type; var cursor = offset; var elements = []; - while(cursor Date: Wed, 3 Feb 2021 13:17:13 -0500 Subject: [PATCH 078/106] move files --- .gitignore | 3 +- src/BatchPacket.js | 7 +-- src/auth/encryption.js | 22 +------- src/auth/{ => tests}/encrypt.js | 0 src/auth/{ => tests}/encryptTest.js | 0 src/auth/{ => tests}/jwtTest.js | 0 src/{serverTest.js => server.js} | 84 +++++++++++++++++++++++++++-- src/transforms/encryption.js | 2 - 8 files changed, 84 insertions(+), 34 deletions(-) rename src/auth/{ => tests}/encrypt.js (100%) rename src/auth/{ => tests}/encryptTest.js (100%) rename src/auth/{ => tests}/jwtTest.js (100%) rename src/{serverTest.js => server.js} (74%) diff --git a/.gitignore b/.gitignore index 9303c34..20c7123 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -npm-debug.log \ No newline at end of file +npm-debug.log +__* \ No newline at end of file diff --git a/src/BatchPacket.js b/src/BatchPacket.js index 98de0c4..cdd9296 100644 --- a/src/BatchPacket.js +++ b/src/BatchPacket.js @@ -3,7 +3,7 @@ const Zlib = require('zlib'); const NETWORK_ID = 0xfe -// This is not a MCPE packet, it's a wrapper that contains compressed batched packets +// This is not a real MCPE packet, it's a wrapper that contains compressed/encrypted batched packets class BatchPacket { constructor(stream) { @@ -13,10 +13,6 @@ class BatchPacket { this.compressionLevel = 7 } - init() { - - } - decode() { // Read header const pid = this.stream.readByte(); @@ -47,7 +43,6 @@ class BatchPacket { addEncodedPacket(packet) { this.stream.writeUnsignedVarInt(packet.byteLength) this.stream.append(packet) - // this.payload = Buffer.concat([this.payload, stream.getBuffer()]); } getPackets() { diff --git a/src/auth/encryption.js b/src/auth/encryption.js index 9529fc0..a487f3e 100644 --- a/src/auth/encryption.js +++ b/src/auth/encryption.js @@ -1,10 +1,9 @@ const JWT = require('jsonwebtoken') const crypto = require('crypto') -const constants = require('./constants') const { Ber } = require('asn1') const ec_pem = require('ec-pem') -const SALT = 'ABC' +const SALT = '🧂' function Encrypt(client, options) { function startClientboundEncryption(publicKey) { @@ -48,25 +47,6 @@ function Encrypt(client, options) { client.startEncryption(initial) } - function startClientCiphers() { - - var decipher = crypto.createDecipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0, 16)) - - let customPackets = JSON.parse(JSON.stringify(require("../data/protocol"))) - - customPackets['types']['encapsulated_packet'][1][1]['type'][1]['fields']['mcpe_encrypted'] = 'restBuffer' - customPackets['types']['encapsulated_packet'][1][0]['type'][1]['mappings']['0xfe'] = 'mcpe_encrypted' - client.encapsulatedPacketParser.proto.addTypes(merge(require('raknet').protocol, customPackets).types) - - client.encryptionEnabled = true - - client.on("mcpe_encrypted", packet => { - decipher.write(packet); - }); - - client.cipher = crypto.createCipheriv('aes-256-cfb8', client.secretKeyBytes, client.secretKeyBytes.slice(0, 16)); - } - client.on('server.client_handshake', startClientboundEncryption) } diff --git a/src/auth/encrypt.js b/src/auth/tests/encrypt.js similarity index 100% rename from src/auth/encrypt.js rename to src/auth/tests/encrypt.js diff --git a/src/auth/encryptTest.js b/src/auth/tests/encryptTest.js similarity index 100% rename from src/auth/encryptTest.js rename to src/auth/tests/encryptTest.js diff --git a/src/auth/jwtTest.js b/src/auth/tests/jwtTest.js similarity index 100% rename from src/auth/jwtTest.js rename to src/auth/tests/jwtTest.js diff --git a/src/serverTest.js b/src/server.js similarity index 74% rename from src/serverTest.js rename to src/server.js index 226cd22..c4eaeb7 100644 --- a/src/serverTest.js +++ b/src/server.js @@ -1,4 +1,3 @@ -console.log('IMPORTING') const BinaryStream = require('@jsprismarine/jsbinaryutils').default const Listener = require('@jsprismarine/raknet/listener') const { ProtoDef, Parser, Serializer } = require('protodef') @@ -10,8 +9,7 @@ const { Encrypt } = require('./auth/encryption') const { decodeLoginJWT } = require('./auth/jwt') const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') -console.log('IMPORTED') -// const Zlib = require('zlib'); + var protocol = require('../data/newproto.json').types; @@ -123,6 +121,25 @@ class Player extends EventEmitter { } } + writeRaw(name, buffer) { // skip protodef serializaion + // temporary hard coded stuff + const batch = new BatchPacket() + if (name == 'biome_definition_list') { + // so we can send nbt straight from file without parsing + const stream = new BinaryStream() + stream.writeUnsignedVarInt(0x7a) + stream.append(buffer) + batch.addEncodedPacket(stream.getBuffer()) + // console.log('----- SENDING BIOME DEFINITIONS') + } + + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } + } + sendDecryptedBatch(batch) { const buf = batch.encode() // send to raknet @@ -130,7 +147,7 @@ class Player extends EventEmitter { sendPacket.reliability = 0; sendPacket.buffer = buf - this.connection.addEncapsulatedToQueue(sendPacket, 1) + this.connection.addEncapsulatedToQueue(sendPacket) this.connection.sendQueue() } @@ -268,21 +285,80 @@ class Server extends EventEmitter { } } +let CreativeItems = require('../data/creativeitems.json') +let NBT = require('prismarine-nbt') + let server = new Server({ }) server.create('0.0.0.0', 19130) +let ran = false + server.on('connect', ({ client }) => { /** @type {Player} */ client.on('join', () => { console.log('Client joined', client.getData()) + + // ResourcePacksInfo is sent by the server to inform the client on what resource packs the server has. It + // sends a list of the resource packs it has and basic information on them like the version and description. client.write('resource_packs_info', { 'must_accept': false, 'has_scripts': false, 'behaviour_packs': [], 'texture_packs': [] }) + + client.once('resource_pack_client_response', (packet) => { + // ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs + // should be applied (and downloaded) by the client. + client.write('resource_pack_stack', { + 'must_accept': false, + 'behavior_packs': [], + 'resource_packs': [], + 'game_version': '', + 'experiments': [], + 'experiments_previously_toggled': false + }) + + client.once('resource_pack_client_response', async (packet) => { + if (ran === true) throw 'Already sent' + ran = true + let items = [] + let ids = 0 + for (var item of CreativeItems) { + let creativeitem = { runtime_id: items.length } + if (item.id != 0) { + const hasNbt = !!item.nbt_b64 + creativeitem.item = { + network_id: item.id, + auxiliary_value: item.damage || 0, + has_nbt: hasNbt|0, + nbt_version: 1, + blocking_tick: 0, + can_destroy: [], + can_place_on: [] + } + if (hasNbt) { + let nbtBuf = Buffer.from(item.nbt_b64, 'base64') + let { result } = await NBT.parse(nbtBuf, 'little') + creativeitem.item.nbt = result + } + } + items.push(creativeitem) + // console.log(creativeitem) + } + + console.log(items, ids) + + client.write('creative_content', { items }) + + setTimeout(() => { + const biomeDefs = fs.readFileSync('../data/biome_definitions.nbt') + client.writeRaw('biome_definition_list', biomeDefs) + }, 1000) + }) + }) }) }) \ No newline at end of file diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index 491fe09..7aaee6b 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -130,14 +130,12 @@ function createDecryptor(client, iv) { } else { throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) } - // console.log('Calling cb') cb() } }) const inflator = new Transform({ transform(chunk, enc, cb) { - // console.log('INFLATING') Zlib.inflateRaw(chunk, { chunkSize: 1024 * 1024 * 2 }, (err, buf) => { if (err) throw err this.push(buf) From 9c171aa0da0e67d5436037d3a1675c18bb9bc213 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 3 Feb 2021 13:26:13 -0500 Subject: [PATCH 079/106] seperate server/serverTest --- data/newproto.json | 751 ++++++++++++++++++++++++++++++--------------- src/server.js | 79 +---- src/serverTest.js | 79 +++++ 3 files changed, 583 insertions(+), 326 deletions(-) create mode 100644 src/serverTest.js diff --git a/data/newproto.json b/data/newproto.json index 2af7f0b..3a166bf 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -20,7 +20,7 @@ ], "varint32": "varint", "varint64": "varint", - "bool": "i8", + "bool": "native", "zigzag32": "native", "zigzag64": "native", "uuid": "native", @@ -110,21 +110,27 @@ } ], "ResourcePackIdVersions": [ - "container", - [ - { - "name": "uuid", - "type": "string" - }, - { - "name": "version", - "type": "string" - }, - { - "name": "name", - "type": "string" - } - ] + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "uuid", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "name", + "type": "string" + } + ] + ] + } ], "ResourcePackIds": [ "array", @@ -187,6 +193,32 @@ "type": "GameRule" } ], + "Chunks": [ + "container", + [ + { + "name": "cache_enabled", + "type": "bool" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "cache_enabled", + "fields": { + "true": "void", + "false": "void" + } + } + ] + }, + { + "name": "data", + "type": "string" + } + ] + ], "BlockPalette": [ "array", { @@ -253,17 +285,88 @@ "type": "zigzag32" }, { - "name": "user_data_marker", - "type": "li16" + "name": "has_nbt", + "type": [ + "mapper", + { + "type": "lu16", + "mappings": { + "0": "0", + "0xffff": "1" + } + } + ] }, { - "name": "nbt", - "type": "nbt" + "anon": true, + "type": [ + "switch", + { + "compareTo": "has_nbt", + "fields": { + "1": [ + "container", + [ + { + "name": "nbt_version", + "type": "u8" + }, + { + "name": "nbt", + "type": "nbt" + } + ] + ] + }, + "default": "void" + } + ] + }, + { + "name": "can_place_on", + "type": [ + "array", + { + "countType": "zigzag32", + "type": "string" + } + ] + }, + { + "name": "can_destroy", + "type": [ + "array", + { + "countType": "zigzag32", + "type": "string" + } + ] } ] ] } ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "network_id", + "fields": { + "355": [ + "container", + [ + { + "name": "blocking_tick", + "type": "zigzag64" + } + ] + ] + }, + "default": "void" + } + ] } ] ], @@ -573,7 +676,7 @@ "type": "zigzag32" }, { - "anon": true, + "name": "legacy_transactions", "type": [ "switch", { @@ -640,125 +743,216 @@ { "name": "inventory_actions", "type": [ - "array", + "switch", { - "countType": "varint", - "type": [ - "container", - [ + "compareTo": "has_network_ids", + "fields": { + "true": [ + "array", { - "name": "source_type", + "countType": "varint", "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "INV_SOURCE_TYPE_CONTAINER", - "1": "INV_SOURCE_TYPE_GLOBAL", - "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", - "3": "INV_SOURCE_TYPE_CREATIVE", - "100": "INV_SOURCE_TYPE_CRAFT_SLOT", - "99999": "INV_SOURCE_TYPE_CRAFT" - } - } - ] - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "source_type", - "fields": { - "INV_SOURCE_TYPE_CONTAINER": [ - "container", - [ - { - "name": "inventory_id", - "type": "varint" + "container", + [ + { + "name": "source_type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "INV_SOURCE_TYPE_CONTAINER", + "1": "INV_SOURCE_TYPE_GLOBAL", + "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", + "3": "INV_SOURCE_TYPE_CREATIVE", + "100": "INV_SOURCE_TYPE_CRAFT_SLOT", + "99999": "INV_SOURCE_TYPE_CRAFT" } - ] - ], - "INV_SOURCE_TYPE_WORLD_INTERACTION": [ - "container", - [ - { - "name": "flags", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CREATIVE": [ - "container", - [ - { - "name": "inventory_id", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CRAFT": [ - "container", - [ - { - "name": "action", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CRAFT_SLOT": [ - "container", - [ - { - "name": "action", - "type": "varint" - } - ] + } ] - } - } - ] - }, - { - "name": "slot", - "type": "varint" - }, - { - "name": "old_item", - "type": "Item" - }, - { - "name": "new_item", - "type": "Item" - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "has_network_ids", - "fields": { - "true": [ - "container", - [ - { - "name": "new_item_stack_id", - "type": "zigzag32" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "source_type", + "fields": { + "INV_SOURCE_TYPE_CONTAINER": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_WORLD_INTERACTION": [ + "container", + [ + { + "name": "flags", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CREATIVE": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT_SLOT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ] } - ] - ], - "false": "void" + } + ] + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "old_item", + "type": "Item" + }, + { + "name": "new_item", + "type": "Item" + }, + { + "name": "new_item_stack_id", + "type": "zigzag32" } - } + ] + ] + } + ], + "false": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "source_type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "INV_SOURCE_TYPE_CONTAINER", + "1": "INV_SOURCE_TYPE_GLOBAL", + "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", + "3": "INV_SOURCE_TYPE_CREATIVE", + "100": "INV_SOURCE_TYPE_CRAFT_SLOT", + "99999": "INV_SOURCE_TYPE_CRAFT" + } + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "source_type", + "fields": { + "INV_SOURCE_TYPE_CONTAINER": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_WORLD_INTERACTION": [ + "container", + [ + { + "name": "flags", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CREATIVE": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT_SLOT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ] + } + } + ] + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "old_item", + "type": "Item" + }, + { + "name": "new_item", + "type": "Item" + }, + { + "name": "new_item_stack_id", + "type": "void" + } + ] ] } ] - ] + } } ] }, { - "name": "transactionMap", + "name": "transaction_data", "type": [ "switch", { @@ -766,7 +960,7 @@ "fields": { "TYPE_NORMAL": "void", "TYPE_INVENTORY_MISMATCH": "void", - "TYPE_USE_ITEM": [ + "TYPE_ITEM_USE": [ "container", [ { @@ -863,7 +1057,7 @@ "container", [ { - "name": "network_id", + "name": "runtime_id", "type": "zigzag32" }, { @@ -1431,7 +1625,8 @@ } ] ] - } + }, + "default": "void" } ] }, @@ -1464,97 +1659,139 @@ ] }, { - "name": "entries", + "anon": true, "type": [ - "array", + "switch", { - "countType": "varint", - "type": [ - "container", - [ - { - "name": "scoreboard_id", - "type": "li64" - }, - { - "name": "objective_name", - "type": "string" - }, - { - "name": "score", - "type": "li32" - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "remove": [ + "compareTo": "type", + "fields": { + "remove": [ + "container", + [ + { + "name": "entries", + "type": [ + "array", + { + "countType": "varint", + "type": [ "container", [ { - "name": "entry_type", - "type": [ - "mapper", - { - "type": "i8", - "mappings": { - "1": "player", - "2": "entity", - "3": "fake_player" - } - } - ] + "name": "scoreboard_id", + "type": "zigzag64" + }, + { + "name": "objective_name", + "type": "string" + }, + { + "name": "score", + "type": "li32" }, { "anon": true, "type": [ - "switch", - { - "compareTo": "entry_type", - "fields": { - "player": [ - "container", - [ - { - "name": "entity_unique_id", - "type": "zigzag64" + "container", + [ + { + "name": "entry_type", + "type": [ + "mapper", + { + "type": "i8", + "mappings": { + "1": "player", + "2": "entity", + "3": "fake_player" } - ] - ], - "entity": [ - "container", - [ - { - "name": "entity_unique_id", - "type": "zigzag64" + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "entry_type", + "fields": { + "player": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" + } + ] + ], + "entity": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" + } + ] + ], + "fake_player": [ + "container", + [ + { + "name": "custom_name", + "type": "string" + } + ] + ] } - ] - ], - "fake_player": [ - "container", - [ - { - "name": "custom_name", - "type": "string" - } - ] + } ] } - } + ] ] } ] - ], - "change": "void" + ] } - } - ] - } + ] + } + ] + ], + "change": [ + "container", + [ + { + "name": "entries", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "scoreboard_id", + "type": "zigzag64" + }, + { + "name": "objective_name", + "type": "string" + }, + { + "name": "score", + "type": "li32" + }, + { + "anon": true, + "type": "void" + } + ] + ] + } + ] + } + ] ] - ] + } } ] } @@ -1577,41 +1814,67 @@ ] }, { - "name": "entries", + "anon": true, "type": [ - "array", + "switch", { - "countType": "varint", - "type": [ - "container", - [ - { - "name": "scoreboard_id", - "type": "zigzag64" - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "TYPE_REGISTER_IDENTITY": [ + "compareTo": "type", + "fields": { + "TYPE_REGISTER_IDENTITY": [ + "container", + [ + { + "name": "entries", + "type": [ + "array", + { + "countType": "varint", + "type": [ "container", [ + { + "name": "scoreboard_id", + "type": "zigzag64" + }, { "name": "entity_unique_id", "type": "zigzag64" } ] ] - }, - "default": "void" - } - ] - } + } + ] + } + ] + ], + "TYPE_CLEAR_IDENTITY": [ + "container", + [ + { + "name": "entries", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "scoreboard_id", + "type": "zigzag64" + }, + { + "anon": true, + "type": "void" + } + ] + ] + } + ] + } + ] ] - ] + } } ] } @@ -2020,7 +2283,7 @@ "type": [ "mapper", { - "type": "u8", + "type": "varint", "mappings": { "0x01": "login", "0x02": "play_status", @@ -2402,11 +2665,11 @@ "type": "bool" }, { - "name": "behavior_pack_id_versions", + "name": "behavior_packs", "type": "ResourcePackIdVersions" }, { - "name": "resource_pack_id_versions", + "name": "resource_packs", "type": "ResourcePackIdVersions" }, { @@ -2415,7 +2678,7 @@ }, { "name": "experiments", - "type": "li32" + "type": "Experiments" }, { "name": "experiments_previously_toggled", @@ -3644,7 +3907,7 @@ "type": "BlockCoordinates" }, { - "name": "namedtag", + "name": "nbt", "type": "nbt" } ] @@ -3686,8 +3949,8 @@ "type": "varint" }, { - "name": "cache_enabled", - "type": "bool" + "name": "column", + "type": "Chunks" } ] ], @@ -3941,7 +4204,7 @@ "type": "string" }, { - "name": "namedtag", + "name": "nbt", "type": "nbt" } ] @@ -3966,7 +4229,7 @@ "type": "zigzag64" }, { - "name": "namedtag", + "name": "nbt", "type": "nbt" } ] @@ -4324,15 +4587,7 @@ } ] ], - "packet_set_score": [ - "container", - [ - { - "name": "entries", - "type": "ScoreEntries" - } - ] - ], + "packet_set_score": "ScoreEntries", "packet_lab_table": [ "container", [ @@ -4473,7 +4728,7 @@ "container", [ { - "name": "namedtag", + "name": "nbt", "type": "nbt" } ] @@ -4524,7 +4779,7 @@ "container", [ { - "name": "namedtag", + "name": "nbt", "type": "nbt" } ] @@ -4620,7 +4875,7 @@ "container", [ { - "name": "namedtag", + "name": "nbt", "type": "nbt" } ] @@ -4650,7 +4905,7 @@ "container", [ { - "name": "input", + "name": "items", "type": "ItemStacks" } ] diff --git a/src/server.js b/src/server.js index c4eaeb7..636f104 100644 --- a/src/server.js +++ b/src/server.js @@ -3,7 +3,6 @@ const Listener = require('@jsprismarine/raknet/listener') const { ProtoDef, Parser, Serializer } = require('protodef') const BatchPacket = require('./BatchPacket') const { EventEmitter } = require('events') -const fs = require('fs') const cipher = require('./transforms/encryption') const { Encrypt } = require('./auth/encryption') @@ -285,80 +284,4 @@ class Server extends EventEmitter { } } -let CreativeItems = require('../data/creativeitems.json') -let NBT = require('prismarine-nbt') - -let server = new Server({ - -}) -server.create('0.0.0.0', 19130) - -let ran = false - -server.on('connect', ({ client }) => { - /** @type {Player} */ - client.on('join', () => { - console.log('Client joined', client.getData()) - - - // ResourcePacksInfo is sent by the server to inform the client on what resource packs the server has. It - // sends a list of the resource packs it has and basic information on them like the version and description. - client.write('resource_packs_info', { - 'must_accept': false, - 'has_scripts': false, - 'behaviour_packs': [], - 'texture_packs': [] - }) - - client.once('resource_pack_client_response', (packet) => { - // ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs - // should be applied (and downloaded) by the client. - client.write('resource_pack_stack', { - 'must_accept': false, - 'behavior_packs': [], - 'resource_packs': [], - 'game_version': '', - 'experiments': [], - 'experiments_previously_toggled': false - }) - - client.once('resource_pack_client_response', async (packet) => { - if (ran === true) throw 'Already sent' - ran = true - let items = [] - let ids = 0 - for (var item of CreativeItems) { - let creativeitem = { runtime_id: items.length } - if (item.id != 0) { - const hasNbt = !!item.nbt_b64 - creativeitem.item = { - network_id: item.id, - auxiliary_value: item.damage || 0, - has_nbt: hasNbt|0, - nbt_version: 1, - blocking_tick: 0, - can_destroy: [], - can_place_on: [] - } - if (hasNbt) { - let nbtBuf = Buffer.from(item.nbt_b64, 'base64') - let { result } = await NBT.parse(nbtBuf, 'little') - creativeitem.item.nbt = result - } - } - items.push(creativeitem) - // console.log(creativeitem) - } - - console.log(items, ids) - - client.write('creative_content', { items }) - - setTimeout(() => { - const biomeDefs = fs.readFileSync('../data/biome_definitions.nbt') - client.writeRaw('biome_definition_list', biomeDefs) - }, 1000) - }) - }) - }) -}) \ No newline at end of file +module.exports = { Server, Player, PLAY_STATUS } \ No newline at end of file diff --git a/src/serverTest.js b/src/serverTest.js new file mode 100644 index 0000000..aa356fc --- /dev/null +++ b/src/serverTest.js @@ -0,0 +1,79 @@ +const { Server } = require('./server') +const CreativeItems = require('../data/creativeitems.json') +const NBT = require('prismarine-nbt') +const fs = require('fs') + +let server = new Server({ + +}) +server.create('0.0.0.0', 19130) + +let ran = false + +server.on('connect', ({ client }) => { + /** @type {Player} */ + client.on('join', () => { + console.log('Client joined', client.getData()) + + // ResourcePacksInfo is sent by the server to inform the client on what resource packs the server has. It + // sends a list of the resource packs it has and basic information on them like the version and description. + client.write('resource_packs_info', { + 'must_accept': false, + 'has_scripts': false, + 'behaviour_packs': [], + 'texture_packs': [] + }) + + client.once('resource_pack_client_response', (packet) => { + // ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs + // should be applied (and downloaded) by the client. + client.write('resource_pack_stack', { + 'must_accept': false, + 'behavior_packs': [], + 'resource_packs': [], + 'game_version': '', + 'experiments': [], + 'experiments_previously_toggled': false + }) + + client.once('resource_pack_client_response', async (packet) => { + ran = true + let items = [] + let ids = 0 + for (var item of CreativeItems) { + let creativeitem = { runtime_id: items.length } + if (item.id != 0) { + const hasNbt = !!item.nbt_b64 + creativeitem.item = { + network_id: item.id, + auxiliary_value: item.damage || 0, + has_nbt: hasNbt|0, + nbt_version: 1, + blocking_tick: 0, + can_destroy: [], + can_place_on: [] + } + if (hasNbt) { + let nbtBuf = Buffer.from(item.nbt_b64, 'base64') + let { result } = await NBT.parse(nbtBuf, 'little') + creativeitem.item.nbt = result + } + } + items.push(creativeitem) + // console.log(creativeitem) + } + + console.log(items, ids) + + client.write('creative_content', { items }) + // wait a bit just for easier debugging + setTimeout(() => { + const biomeDefs = fs.readFileSync('../data/biome_definitions.nbt') + client.writeRaw('biome_definition_list', biomeDefs) + + // TODO: send chunks so we can spawn player + }, 1000) + }) + }) + }) +}) \ No newline at end of file From 73d4dd1325efc7d6f51d42dfab494ed74a5e7126 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 7 Feb 2021 05:25:22 -0500 Subject: [PATCH 080/106] protocol def updates --- data/new/compile.js | 15 + data/new/proto.yml | 1426 +++++++++++++++++++++++++++++++++++++++++++ data/new/types.yaml | 457 ++++++++++++++ data/newproto.json | 1067 +++++++++++++------------------- 4 files changed, 2322 insertions(+), 643 deletions(-) create mode 100644 data/new/compile.js create mode 100644 data/new/proto.yml create mode 100644 data/new/types.yaml diff --git a/data/new/compile.js b/data/new/compile.js new file mode 100644 index 0000000..8a3b575 --- /dev/null +++ b/data/new/compile.js @@ -0,0 +1,15 @@ +const fs = require('fs') + +let compile +try { + compile = require('protodef-yaml/compiler') +} catch (e) { + require('child_process').execSync('npx protodef-yaml proto.yml protocol.json') +} + +if (compile) { + compile('./proto.yml', 'protocol.json') +} + +fs.writeFileSync( '../newproto.json', JSON.stringify({ types: require('./protocol.json') }, null, 2) ) +fs.unlinkSync('./protocol.json') //remove temp file \ No newline at end of file diff --git a/data/new/proto.yml b/data/new/proto.yml new file mode 100644 index 0000000..37f7f0a --- /dev/null +++ b/data/new/proto.yml @@ -0,0 +1,1426 @@ +# Created from MiNET docs +string: ["pstring",{"countType":"varint"}] +ByteArray: ["buffer",{"countType":"varint"}] +LittleString: ["pstring",{"countType":"li32"}] +varint32: varint +varint64: varint +bool: native +zigzag32: native +zigzag64: native +uuid: native +byterot: native +MapInfo: native +nbt: native + +!import: types.yaml + +mcpe_packet: + name: varint => + 0x01: login + 0x02: play_status + 0x03: server_to_client_handshake + 0x04: client_to_server_handshake + 0x05: disconnect + 0x06: resource_packs_info + 0x07: resource_pack_stack + 0x08: resource_pack_client_response + 0x09: text + 0x0a: set_time + 0x0b: start_game + 0x0c: add_player + 0x0d: add_entity + 0x0e: remove_entity + 0x0f: add_item_entity + 0x11: take_item_entity + 0x12: move_entity + 0x13: move_player + 0x14: rider_jump + 0x15: update_block + 0x16: add_painting + 0x17: tick_sync + 0x18: level_sound_event_old + 0x19: level_event + 0x1a: block_event + 0x1b: entity_event + 0x1c: mob_effect + 0x1d: update_attributes + 0x1e: inventory_transaction + 0x1f: mob_equipment + 0x20: mob_armor_equipment + 0x21: interact + 0x22: block_pick_request + 0x23: entity_pick_request + 0x24: player_action + 0x26: hurt_armor + 0x27: set_entity_data + 0x28: set_entity_motion + 0x29: set_entity_link + 0x2a: set_health + 0x2b: set_spawn_position + 0x2c: animate + 0x2d: respawn + 0x2e: container_open + 0x2f: container_close + 0x30: player_hotbar + 0x31: inventory_content + 0x32: inventory_slot + 0x33: container_set_data + 0x34: crafting_data + 0x35: crafting_event + 0x36: gui_data_pick_item + 0x37: adventure_settings + 0x38: block_entity_data + 0x39: player_input + 0x3a: level_chunk + 0x3b: set_commands_enabled + 0x3c: set_difficulty + 0x3d: change_dimension + 0x3e: set_player_game_type + 0x3f: player_list + 0x40: simple_event + 0x42: spawn_experience_orb + 0x43: clientbound_map_item_data + 0x44: map_info_request + 0x45: request_chunk_radius + 0x46: chunk_radius_update + 0x47: item_frame_drop_item + 0x48: game_rules_changed + 0x49: camera + 0x4a: boss_event + 0x4b: show_credits + 0x4c: available_commands + 0x4d: command_request + 0x4e: command_block_update + 0x4f: command_output + 0x50: update_trade + 0x51: update_equipment + 0x52: resource_pack_data_info + 0x53: resource_pack_chunk_data + 0x54: resource_pack_chunk_request + 0x55: transfer + 0x56: play_sound + 0x57: stop_sound + 0x58: set_title + 0x59: add_behavior_tree + 0x5a: structure_block_update + 0x5b: show_store_offer + 0x5c: purchase_receipt + 0x5d: player_skin + 0x5e: sub_client_login + 0x5f: initiate_web_socket_connection + 0x60: set_last_hurt_by + 0x61: book_edit + 0x62: npc_request + 0x63: photo_transfer + 0x64: modal_form_request + 0x65: modal_form_response + 0x66: server_settings_request + 0x67: server_settings_response + 0x68: show_profile + 0x69: set_default_game_type + 0x6a: remove_objective + 0x6b: set_display_objective + 0x6c: set_score + 0x6d: lab_table + 0x6e: update_block_synced + 0x6f: move_entity_delta + 0x70: set_scoreboard_identity + 0x71: set_local_player_as_initialized + 0x72: update_soft_enum + 0x73: network_stack_latency + 0x75: script_custom_event + 0x76: spawn_particle_effect + 0x77: available_entity_identifiers + 0x78: level_sound_event_v2 + 0x79: network_chunk_publisher_update + 0x7a: biome_definition_list + 0x7b: level_sound_event + 0x7c: level_event_generic + 0x7d: lectern_update + 0x7e: video_stream_connect + 0x81: client_cache_status + 0x82: on_screen_texture_animation + 0x83: map_create_locked_copy + 0x84: structure_template_data_export_request + 0x85: structure_template_data_export_response + 0x86: update_block_properties + 0x87: client_cache_blob_status + 0x88: client_cache_miss_response + 0x8f: network_settings + 0x91: creative_content + 0x92: player_enchant_options + 0x93: item_stack_request + 0x94: item_stack_response + 0x97: update_player_game_type + 0x9c: packet_violation_warning + 0xa2: item_component + 0xa3: filter_text_packet + params: name ? + if login: packet_login + if play_status: packet_play_status + if server_to_client_handshake: packet_server_to_client_handshake + if client_to_server_handshake: packet_client_to_server_handshake + if disconnect: packet_disconnect + if resource_packs_info: packet_resource_packs_info + if resource_pack_stack: packet_resource_pack_stack + if resource_pack_client_response: packet_resource_pack_client_response + if text: packet_text + if set_time: packet_set_time + if start_game: packet_start_game + if add_player: packet_add_player + if add_entity: packet_add_entity + if remove_entity: packet_remove_entity + if add_item_entity: packet_add_item_entity + if take_item_entity: packet_take_item_entity + if move_entity: packet_move_entity + if move_player: packet_move_player + if rider_jump: packet_rider_jump + if update_block: packet_update_block + if add_painting: packet_add_painting + if tick_sync: packet_tick_sync + if level_sound_event_old: packet_level_sound_event_old + if level_event: packet_level_event + if block_event: packet_block_event + if entity_event: packet_entity_event + if mob_effect: packet_mob_effect + if update_attributes: packet_update_attributes + if inventory_transaction: packet_inventory_transaction + if mob_equipment: packet_mob_equipment + if mob_armor_equipment: packet_mob_armor_equipment + if interact: packet_interact + if block_pick_request: packet_block_pick_request + if entity_pick_request: packet_entity_pick_request + if player_action: packet_player_action + if hurt_armor: packet_hurt_armor + if set_entity_data: packet_set_entity_data + if set_entity_motion: packet_set_entity_motion + if set_entity_link: packet_set_entity_link + if set_health: packet_set_health + if set_spawn_position: packet_set_spawn_position + if animate: packet_animate + if respawn: packet_respawn + if container_open: packet_container_open + if container_close: packet_container_close + if player_hotbar: packet_player_hotbar + if inventory_content: packet_inventory_content + if inventory_slot: packet_inventory_slot + if container_set_data: packet_container_set_data + if crafting_data: packet_crafting_data + if crafting_event: packet_crafting_event + if gui_data_pick_item: packet_gui_data_pick_item + if adventure_settings: packet_adventure_settings + if block_entity_data: packet_block_entity_data + if player_input: packet_player_input + if level_chunk: packet_level_chunk + if set_commands_enabled: packet_set_commands_enabled + if set_difficulty: packet_set_difficulty + if change_dimension: packet_change_dimension + if set_player_game_type: packet_set_player_game_type + if player_list: packet_player_list + if simple_event: packet_simple_event + if spawn_experience_orb: packet_spawn_experience_orb + if clientbound_map_item_data: packet_clientbound_map_item_data + if map_info_request: packet_map_info_request + if request_chunk_radius: packet_request_chunk_radius + if chunk_radius_update: packet_chunk_radius_update + if item_frame_drop_item: packet_item_frame_drop_item + if game_rules_changed: packet_game_rules_changed + if camera: packet_camera + if boss_event: packet_boss_event + if show_credits: packet_show_credits + if available_commands: packet_available_commands + if command_request: packet_command_request + if command_block_update: packet_command_block_update + if command_output: packet_command_output + if update_trade: packet_update_trade + if update_equipment: packet_update_equipment + if resource_pack_data_info: packet_resource_pack_data_info + if resource_pack_chunk_data: packet_resource_pack_chunk_data + if resource_pack_chunk_request: packet_resource_pack_chunk_request + if transfer: packet_transfer + if play_sound: packet_play_sound + if stop_sound: packet_stop_sound + if set_title: packet_set_title + if add_behavior_tree: packet_add_behavior_tree + if structure_block_update: packet_structure_block_update + if show_store_offer: packet_show_store_offer + if purchase_receipt: packet_purchase_receipt + if player_skin: packet_player_skin + if sub_client_login: packet_sub_client_login + if initiate_web_socket_connection: packet_initiate_web_socket_connection + if set_last_hurt_by: packet_set_last_hurt_by + if book_edit: packet_book_edit + if npc_request: packet_npc_request + if photo_transfer: packet_photo_transfer + if modal_form_request: packet_modal_form_request + if modal_form_response: packet_modal_form_response + if server_settings_request: packet_server_settings_request + if server_settings_response: packet_server_settings_response + if show_profile: packet_show_profile + if set_default_game_type: packet_set_default_game_type + if remove_objective: packet_remove_objective + if set_display_objective: packet_set_display_objective + if set_score: packet_set_score + if lab_table: packet_lab_table + if update_block_synced: packet_update_block_synced + if move_entity_delta: packet_move_entity_delta + if set_scoreboard_identity: packet_set_scoreboard_identity + if set_local_player_as_initialized: packet_set_local_player_as_initialized + if update_soft_enum: packet_update_soft_enum + if network_stack_latency: packet_network_stack_latency + if script_custom_event: packet_script_custom_event + if spawn_particle_effect: packet_spawn_particle_effect + if available_entity_identifiers: packet_available_entity_identifiers + if level_sound_event_v2: packet_level_sound_event_v2 + if network_chunk_publisher_update: packet_network_chunk_publisher_update + if biome_definition_list: packet_biome_definition_list + if level_sound_event: packet_level_sound_event + if level_event_generic: packet_level_event_generic + if lectern_update: packet_lectern_update + if video_stream_connect: packet_video_stream_connect + if client_cache_status: packet_client_cache_status + if on_screen_texture_animation: packet_on_screen_texture_animation + if map_create_locked_copy: packet_map_create_locked_copy + if structure_template_data_export_request: packet_structure_template_data_export_request + if structure_template_data_export_response: packet_structure_template_data_export_response + if update_block_properties: packet_update_block_properties + if client_cache_blob_status: packet_client_cache_blob_status + if client_cache_miss_response: packet_client_cache_miss_response + if network_settings: packet_network_settings + if creative_content: packet_creative_content + if player_enchant_options: packet_player_enchant_options + if item_stack_request: packet_item_stack_request + if item_stack_response: packet_item_stack_response + if update_player_game_type: packet_update_player_game_type + if packet_violation_warning: packet_packet_violation_warning + if item_component: packet_item_component + if filter_text_packet: packet_filter_text_packet + +packet_login: + !id: 0x01 + !server: false + !client: true + protocol_version: i32 + payload_size: varint + chain: LittleString + client_data: LittleString + +packet_play_status: + !id: 0x02 + !server: true + !client: false + status: i32 + +packet_server_to_client_handshake: + !id: 0x03 + !server: true + !client: false + token: string + +packet_client_to_server_handshake: + !id: 0x04 + !server: false + !client: true + +packet_disconnect: + !id: 0x05 + !server: true + !client: false + hide_disconnect_reason: bool + message: string + +packet_resource_packs_info: + !id: 0x06 + !server: true + !client: false + must_accept: bool + has_scripts: bool + behaviour_packs: BehaviourPackInfos + texture_packs: TexturePackInfos + +packet_resource_pack_stack: + !id: 0x07 + !server: true + !client: false + must_accept: bool + behavior_packs: ResourcePackIdVersions + resource_packs: ResourcePackIdVersions + game_version: string + experiments: Experiments + experiments_previously_toggled: bool + +packet_resource_pack_client_response: + !id: 0x08 + !server: false + !client: true + response_status: u8 + resourcepackids: ResourcePackIds + +packet_text: + !id: 0x09 + !server: true + !client: true + type: u8 + +packet_set_time: + !id: 0x0a + !server: true + !client: false + time: zigzag32 + +packet_start_game: + !id: 0x0b + !server: true + !client: false + entity_id: zigzag64 + runtime_entity_id: varint + player_gamemode: zigzag32 + spawn: vec3f + rotation: vec3f + seed: zigzag32 + biome_type: li16 + biome_name: string + dimension: zigzag32 + generator: zigzag32 + gamemode: zigzag32 + difficulty: zigzag32 + x: zigzag32 + y: varint + z: zigzag32 + has_achievements_disabled: bool + day_cycle_stop_time: zigzag32 + edu_offer: zigzag32 + has_edu_features_enabled: bool + edu_product_uuid_: string + rain_level: lf32 + lightning_level: lf32 + has_confirmed_platform_locked_content: bool + is_multiplayer: bool + broadcast_to_lan: bool + xbox_live_broadcast_mode: varint + platform_broadcast_mode: varint + enable_commands: bool + is_texturepacks_required: bool + gamerules: GameRules + experiments: Experiments + experiments_previously_toggled: bool + bonus_chest: bool + map_enabled: bool + permission_level: zigzag32 + server_chunk_tick_range: li32 + has_locked_behavior_pack: bool + has_locked_resource_pack: bool + is_from_locked_world_template: bool + msa_gamertags_only: bool + is_from_world_template: bool + is_world_template_option_locked: bool + only_spawn_v1_villagers: bool + game_version: string + limited_world_width_: li32 + limited_world_length_: li32 + is_new_nether_: bool + experimental_gameplay_override: bool + level_id: string + world_name: string + premium_world_template_id: string + is_trial: bool + movement_type: zigzag32 + current_tick: li64 + enchantment_seed: zigzag32 + block_palette: BlockPalette + itemstates: Itemstates + multiplayer_correlation_id: string + server_authoritative_inventory: bool + +packet_add_player: + !id: 0x0c + !server: true + !client: false + uuid: uuid + username: string + entity_id_self: zigzag64 + runtime_entity_id: varint + platform_chat_id: string + x: lf32 + y: lf32 + z: lf32 + speed_x: lf32 + speed_y: lf32 + speed_z: lf32 + pitch: lf32 + yaw: lf32 + head_yaw: lf32 + held_item: Item + metadata: MetadataDictionary + flags: varint + command_permission: varint + action_permissions: varint + permission_level: varint + custom_stored_permissions: varint + user_id: li64 + links: Links + device_id: string + device_os: li32 + +packet_add_entity: + !id: 0x0d + !server: true + !client: false + entity_id_self: zigzag64 + runtime_entity_id: varint + entity_type: string + x: lf32 + y: lf32 + z: lf32 + speed_x: lf32 + speed_y: lf32 + speed_z: lf32 + pitch: lf32 + yaw: lf32 + head_yaw: lf32 + attributes: EntityAttributes + metadata: MetadataDictionary + links: Links + +packet_remove_entity: + !id: 0x0e + !server: true + !client: false + entity_id_self: zigzag64 + +packet_add_item_entity: + !id: 0x0f + !server: true + !client: false + entity_id_self: zigzag64 + runtime_entity_id: varint + item: Item + x: lf32 + y: lf32 + z: lf32 + speed_x: lf32 + speed_y: lf32 + speed_z: lf32 + metadata: MetadataDictionary + is_from_fishing: bool + +packet_take_item_entity: + !id: 0x11 + !server: true + !client: false + runtime_entity_id: varint + target: varint + +packet_move_entity: + !id: 0x12 + !server: true + !client: true + runtime_entity_id: varint + flags: u8 + position: vec3f + rotation: Rotation + +packet_move_player: + !id: 0x13 + !server: true + !client: true + runtime_entity_id: varint + x: lf32 + y: lf32 + z: lf32 + pitch: lf32 + yaw: lf32 + head_yaw: lf32 + mode: u8 + on_ground: bool + other_runtime_entity_id: varint + +packet_rider_jump: + !id: 0x14 + !server: true + !client: true + unknown: zigzag32 + +packet_update_block: + !id: 0x15 + !server: true + !client: false + coordinates: BlockCoordinates + block_runtime_id: varint + block_priority: varint + storage: varint + +packet_add_painting: + !id: 0x16 + !server: true + !client: false + entity_id_self: zigzag64 + runtime_entity_id: varint + coordinates: BlockCoordinates + direction: zigzag32 + title: string + +packet_tick_sync: + !id: 0x17 + !server: true + !client: true + request_time: li64 + response_time: li64 + +packet_level_sound_event_old: + !id: 0x18 + !server: true + !client: true + sound_id: u8 + position: vec3f + block_id: zigzag32 + entity_type: zigzag32 + is_baby_mob: bool + is_global: bool + +packet_level_event: + !id: 0x19 + !server: true + !client: false + event_id: zigzag32 + position: vec3f + data: zigzag32 + +packet_block_event: + !id: 0x1a + !server: true + !client: false + coordinates: BlockCoordinates + case_1: zigzag32 + case_2: zigzag32 + +packet_entity_event: + !id: 0x1b + !server: true + !client: true + runtime_entity_id: varint + event_id: u8 + data: zigzag32 + +packet_mob_effect: + !id: 0x1c + !server: true + !client: false + runtime_entity_id: varint + event_id: u8 + effect_id: zigzag32 + amplifier: zigzag32 + particles: bool + duration: zigzag32 + +packet_update_attributes: + !id: 0x1d + !server: true + !client: false + runtime_entity_id: varint + attributes: PlayerAttributes + tick: varint + +packet_inventory_transaction: + !id: 0x1e + !server: true + !client: true + transaction: Transaction + +packet_mob_equipment: + !id: 0x1f + !server: true + !client: true + runtime_entity_id: varint + item: Item + slot: u8 + selected_slot: u8 + windows_id: u8 + +packet_mob_armor_equipment: + !id: 0x20 + !server: true + !client: true + runtime_entity_id: varint + helmet: Item + chestplate: Item + leggings: Item + boots: Item + +packet_interact: + !id: 0x21 + !server: true + !client: true + action_id: u8 + target_runtime_entity_id: varint + +packet_block_pick_request: + !id: 0x22 + !server: false + !client: true + x: zigzag32 + y: zigzag32 + z: zigzag32 + add_user_data: bool + selected_slot: u8 + +packet_entity_pick_request: + !id: 0x23 + !server: false + !client: true + runtime_entity_id: lu64 + selected_slot: u8 + +packet_player_action: + !id: 0x24 + !server: false + !client: true + runtime_entity_id: varint + action_id: zigzag32 + coordinates: BlockCoordinates + face: zigzag32 + +packet_hurt_armor: + !id: 0x26 + !server: true + !client: false + health: zigzag32 + +packet_set_entity_data: + !id: 0x27 + !server: true + !client: true + runtime_entity_id: varint + metadata: MetadataDictionary + tick: varint + +packet_set_entity_motion: + !id: 0x28 + !server: true + !client: true + runtime_entity_id: varint + velocity: vec3f + +packet_set_entity_link: + !id: 0x29 + !server: true + !client: false + ridden_id: zigzag64 + rider_id: zigzag64 + link_type: u8 + unknown: u8 + +packet_set_health: + !id: 0x2a + !server: true + !client: false + health: zigzag32 + +packet_set_spawn_position: + !id: 0x2b + !server: true + !client: false + spawn_type: zigzag32 + coordinates: BlockCoordinates + dimension: zigzag32 + unknown_coordinates: BlockCoordinates + +packet_animate: + !id: 0x2c + !server: true + !client: true + action_id: zigzag32 + runtime_entity_id: varint + +packet_respawn: + !id: 0x2d + !server: true + !client: true + x: lf32 + y: lf32 + z: lf32 + state: u8 + runtime_entity_id: varint + +packet_container_open: + !id: 0x2e + !server: true + !client: false + window_id: u8 + type: u8 + coordinates: BlockCoordinates + runtime_entity_id: zigzag64 + +packet_container_close: + !id: 0x2f + !server: true + !client: true + window_id: u8 + server: bool + +packet_player_hotbar: + !id: 0x30 + !server: true + !client: true + selected_slot: varint + window_id: u8 + select_slot_: bool + +packet_inventory_content: + !id: 0x31 + !server: true + !client: true + inventory_id: varint + input: ItemStacks + +packet_inventory_slot: + !id: 0x32 + !server: true + !client: true + inventory_id: varint + slot: varint + uniqueid: zigzag32 + item: Item + +packet_container_set_data: + !id: 0x33 + !server: true + !client: false + window_id: u8 + property: zigzag32 + value: zigzag32 + +packet_crafting_data: + !id: 0x34 + !server: true + !client: false + recipes: Recipes + potion_type_recipes: PotionTypeRecipes + potion_container_recipes: PotionContainerChangeRecipes + is_clean: bool + +packet_crafting_event: + !id: 0x35 + !server: true + !client: true + window_id: u8 + recipe_type: zigzag32 + recipe_id: uuid + input: ItemStacks + result: ItemStacks + +packet_gui_data_pick_item: + !id: 0x36 + !server: true + !client: false + +packet_adventure_settings: + !id: 0x37 + !server: true + !client: true + flags: varint + command_permission: varint + action_permissions: varint + permission_level: varint + custom_stored_permissions: varint + user_id: li64 + +packet_block_entity_data: + !id: 0x38 + !server: true + !client: true + coordinates: BlockCoordinates + nbt: nbt + +packet_player_input: + !id: 0x39 + !server: false + !client: true + motion_x: lf32 + motion_z: lf32 + jumping: bool + sneaking: bool + +packet_level_chunk: + !id: 0x3a + !server: true + !client: false + chunk_x: zigzag32 + chunk_z: zigzag32 + sub_chunk_count: varint + column: Chunks + +packet_set_commands_enabled: + !id: 0x3b + !server: true + !client: false + enabled: bool + +packet_set_difficulty: + !id: 0x3c + !server: true + !client: false + difficulty: varint + +packet_change_dimension: + !id: 0x3d + !server: true + !client: false + dimension: zigzag32 + position: vec3f + respawn: bool + +packet_set_player_game_type: + !id: 0x3e + !server: true + !client: true + gamemode: zigzag32 + +packet_player_list: + !id: 0x3f + !server: true + !client: false + records: PlayerRecords + +packet_simple_event: + !id: 0x40 + !server: true + !client: false + event_type: lu16 + +packet_spawn_experience_orb: + !id: 0x42 + !server: true + !client: false + position: vec3f + count: zigzag32 + +packet_clientbound_map_item_data: + !id: 0x43 + !server: true + !client: false + mapinfo: MapInfo + +packet_map_info_request: + !id: 0x44 + !server: true + !client: true + map_id: zigzag64 + +packet_request_chunk_radius: + !id: 0x45 + !server: true + !client: true + chunk_radius: zigzag32 + +packet_chunk_radius_update: + !id: 0x46 + !server: true + !client: false + chunk_radius: zigzag32 + +packet_item_frame_drop_item: + !id: 0x47 + !server: true + !client: true + coordinates: BlockCoordinates + +packet_game_rules_changed: + !id: 0x48 + !server: true + !client: false + rules: GameRules + +packet_camera: + !id: 0x49 + !server: true + !client: false + unknown1: zigzag64 + unknown2: zigzag64 + +packet_boss_event: + !id: 0x4a + !server: true + !client: false + boss_entity_id: zigzag64 + event_type: varint + +packet_show_credits: + !id: 0x4b + !server: true + !client: false + runtime_entity_id: varint + status: zigzag32 + +packet_available_commands: + !id: 0x4c + !server: true + !client: false + +packet_command_request: + !id: 0x4d + !server: false + !client: true + command: string + command_type: varint + unknown_uuid: uuid + request_id: string + unknown: bool + +packet_command_block_update: + !id: 0x4e + !server: false + !client: true + is_block: bool + +packet_command_output: + !id: 0x4f + !server: true + !client: false + +packet_update_trade: + !id: 0x50 + !server: true + !client: false + window_id: u8 + window_type: u8 + unknown0: varint + unknown1: varint + unknown2: varint + is_willing: bool + trader_entity_id: zigzag64 + player_entity_id: zigzag64 + display_name: string + nbt: nbt + +packet_update_equipment: + !id: 0x51 + !server: true + !client: false + window_id: u8 + window_type: u8 + unknown: u8 + entity_id: zigzag64 + nbt: nbt + +packet_resource_pack_data_info: + !id: 0x52 + !server: true + !client: false + package_id: string + max_chunk_size: lu32 + chunk_count: lu32 + compressed_package_size: lu64 + hash: ByteArray + is_premium: bool + pack_type: u8 + +packet_resource_pack_chunk_data: + !id: 0x53 + !server: true + !client: false + package_id: string + chunk_index: lu32 + progress: lu64 + payload: ByteArray + +packet_resource_pack_chunk_request: + !id: 0x54 + !server: false + !client: true + package_id: string + chunk_index: lu32 + +packet_transfer: + !id: 0x55 + !server: true + !client: false + server_address: string + port: lu16 + +packet_play_sound: + !id: 0x56 + !server: true + !client: false + name: string + coordinates: BlockCoordinates + volume: lf32 + pitch: lf32 + +packet_stop_sound: + !id: 0x57 + !server: true + !client: false + name: string + stop_all: bool + +packet_set_title: + !id: 0x58 + !server: true + !client: false + type: zigzag32 + text: string + fade_in_time: zigzag32 + stay_time: zigzag32 + fade_out_time: zigzag32 + +packet_add_behavior_tree: + !id: 0x59 + !server: true + !client: false + behaviortree: string + +packet_structure_block_update: + !id: 0x5a + !server: true + !client: false + +packet_show_store_offer: + !id: 0x5b + !server: true + !client: false + unknown0: string + unknown1: bool + +packet_purchase_receipt: + !id: 0x5c + !server: false + !client: true + +packet_player_skin: + !id: 0x5d + !server: true + !client: true + uuid: uuid + skin: Skin + skin_name: string + old_skin_name: string + is_verified: bool + +packet_sub_client_login: + !id: 0x5e + !server: true + !client: false + +packet_initiate_web_socket_connection: + !id: 0x5f + !server: true + !client: false + server: string + +packet_set_last_hurt_by: + !id: 0x60 + !server: true + !client: false + unknown: varint + +packet_book_edit: + !id: 0x61 + !server: true + !client: false + +packet_npc_request: + !id: 0x62 + !server: true + !client: true + runtime_entity_id: varint + unknown0: u8 + unknown1: string + unknown2: u8 + +packet_photo_transfer: + !id: 0x63 + !server: false + !client: true + file_name: string + image_data: string + unknown2: string + +packet_modal_form_request: + !id: 0x64 + !server: true + !client: false + form_id: varint + data: string + +packet_modal_form_response: + !id: 0x65 + !server: false + !client: true + form_id: varint + data: string + +packet_server_settings_request: + !id: 0x66 + !server: false + !client: true + +packet_server_settings_response: + !id: 0x67 + !server: true + !client: false + form_id: varint + data: string + +packet_show_profile: + !id: 0x68 + !server: true + !client: false + xuid: string + +packet_set_default_game_type: + !id: 0x69 + !server: true + !client: false + gamemode: varint + +packet_remove_objective: + !id: 0x6a + !server: true + !client: false + objective_name: string + +packet_set_display_objective: + !id: 0x6b + !server: true + !client: false + display_slot: string + objective_name: string + display_name: string + criteria_name: string + sort_order: zigzag32 + +packet_set_score: + !id: 0x6c + !server: true + !client: false + entries: ScoreEntries + +packet_lab_table: + !id: 0x6d + !server: true + !client: true + useless_byte: u8 + lab_table_x: varint + lab_table_y: varint + lab_table_z: varint + reaction_type: u8 + +packet_update_block_synced: + !id: 0x6e + !server: true + !client: false + coordinates: BlockCoordinates + block_runtime_id: varint + block_priority: varint + data_layer_id: varint + unknown0: varint + unknown1: varint + +packet_move_entity_delta: + !id: 0x6f + !server: true + !client: false + runtime_entity_id: varint + flags: lu16 + +packet_set_scoreboard_identity: + !id: 0x70 + !server: true + !client: false + entries: ScoreboardIdentityEntries + +packet_set_local_player_as_initialized: + !id: 0x71 + !server: false + !client: true + runtime_entity_id: varint + +packet_update_soft_enum: + !id: 0x72 + !server: true + !client: false + +packet_network_stack_latency: + !id: 0x73 + !server: true + !client: true + timestamp: lu64 + unknown_flag: u8 + +packet_script_custom_event: + !id: 0x75 + !server: true + !client: true + event_name: string + event_data: string + +packet_spawn_particle_effect: + !id: 0x76 + !server: true + !client: false + dimension_id: u8 + entity_id: zigzag64 + position: vec3f + particle_name: string + +packet_available_entity_identifiers: + !id: 0x77 + !server: true + !client: false + nbt: nbt + +packet_level_sound_event_v2: + !id: 0x78 + !server: true + !client: true + sound_id: u8 + position: vec3f + block_id: zigzag32 + entity_type: string + is_baby_mob: bool + is_global: bool + +packet_network_chunk_publisher_update: + !id: 0x79 + !server: true + !client: false + coordinates: BlockCoordinates + radius: varint + +packet_biome_definition_list: + !id: 0x7a + !server: true + !client: false + nbt: nbt + +packet_level_sound_event: + !id: 0x7b + !server: true + !client: true + sound_id: varint + position: vec3f + block_id: zigzag32 + entity_type: string + is_baby_mob: bool + is_global: bool + +packet_level_event_generic: + !id: 0x7c + !server: true + !client: false + +packet_lectern_update: + !id: 0x7d + !server: true + !client: false + +packet_video_stream_connect: + !id: 0x7e + !server: true + !client: false + server_uri: string + frame_send_frequency: lf32 + action: u8 + resolution_x: li32 + resolution_y: li32 + +packet_client_cache_status: + !id: 0x81 + !server: true + !client: true + enabled: bool + +packet_on_screen_texture_animation: + !id: 0x82 + !server: true + !client: false + +packet_map_create_locked_copy: + !id: 0x83 + !server: true + !client: false + +packet_structure_template_data_export_request: + !id: 0x84 + !server: true + !client: false + +packet_structure_template_data_export_response: + !id: 0x85 + !server: true + !client: false + +packet_update_block_properties: + !id: 0x86 + !server: true + !client: false + nbt: nbt + +packet_client_cache_blob_status: + !id: 0x87 + !server: true + !client: false + +packet_client_cache_miss_response: + !id: 0x88 + !server: true + !client: false + +packet_network_settings: + !id: 0x8f + !server: true + !client: true + unknown: u8 + compression_threshold: u8 + +packet_creative_content: + !id: 0x91 + !server: true + !client: false + items: ItemStacks + +packet_player_enchant_options: + !id: 0x92 + !server: true + !client: false + enchant_options: EnchantOptions + +packet_item_stack_request: + !id: 0x93 + !server: false + !client: true + requests: ItemStackRequests + +packet_item_stack_response: + !id: 0x94 + !server: true + !client: false + responses: ItemStackResponses + +packet_update_player_game_type: + !id: 0x97 + !server: false + !client: true + +packet_packet_violation_warning: + !id: 0x9c + !server: false + !client: true + violation_type: zigzag32 + severity: zigzag32 + packet_id: zigzag32 + reason: string + +packet_item_component: + !id: 0xa2 + !server: true + !client: false + entries: ItemComponentList + +packet_filter_text_packet: + !id: 0xa3 + !server: true + !client: false + text: string + from_server: bool diff --git a/data/new/types.yaml b/data/new/types.yaml new file mode 100644 index 0000000..c84339c --- /dev/null +++ b/data/new/types.yaml @@ -0,0 +1,457 @@ +BehaviourPackInfos: []li16 + uuid: string + version: string + size: lu64 + content_key: string + sub_pack_name: string + content_identity: string + has_scripts: bool + +TexturePackInfos: []li16 + uuid: string + version: string + size: lu64 + content_key: string + sub_pack_name: string + content_identity: string + has_scripts: bool + rtx_enabled: bool + +ResourcePackIdVersions: []varint + uuid: string + version: string + name: string + +ResourcePackIds: string[]varint + +Experiment: + name: string + enabled: bool + +Experiments: Experiment[]varint + +GameRule: + name: string + type: varint => + 1: bool + 2: int + 3: float + value: type? + if bool: bool + if int: varint + if float: lf32 + +GameRules: GameRule[]varint + +Chunks: + cache_enabled: bool + _: cache_enabled? + if true: void # TODO + if false: void + + +BlockPalette: []varint + name: string + state: nbt + +Itemstates: []varint + name: string + runtime_id: li16 + component_based: bool + +Item: + network_id: zigzag32 + _: network_id? + if 0: void + default: + auxiliary_value: zigzag32 + has_nbt: lu16 => + 0xffff: '1' + 0x0000: '0' + _: has_nbt? + if 1: + nbt_version: u8 + nbt: nbt + default: void + can_place_on: string[]zigzag32 + can_destroy: string[]zigzag32 + _: network_id? + if 355: + blocking_tick: zigzag64 + +vec3i: + x: zigzag32 + y: zigzag32 + z: zigzag32 + +vec3u: + x: varint + y: varint + z: varint + +vec3f: + x: lf32 + y: lf32 + z: lf32 + +vec2f: + x: lf32 + z: lf32 + +MetadataDictionary: []varint + key: varint + type: varint => + 0: BYTE + 1: SHORT + 2: INT + 3: FLOAT + 4: STRING + 5: COMPOUND_TAG + 6: POS + 7: LONG + 8: VECTOR3F + value: type? + if BYTE: i8 + if SHORT: li16 + if INT: zigzag32 + if FLOAT: lf32 + if STRING: string + if COMPOUND_TAG: nbt + if POS: vec3i + if LONG: zigzag64 + if VECTOR3F: li32 + +Links: []varint + ridden_entity_id: zigzag64 + rider_entity_id: zigzag64 + type: u8 + immediate: bool + rider_initiated: bool + +EntityAttributes: []varint + name: string + min: lf32 + value: lf32 + max: lf32 + +Rotation: + yaw: byterot + pitch: byterot + head_yaw: byterot + +BlockCoordinates: # mojang... + x: zigzag32 + y: varint + z: zigzag32 + +PlayerAttributes: []varint + min: lf32 + max: lf32 + current: lf32 + default: lf32 + name: string + +Transaction: + legacy_request_id: zigzag32 + legacy_transactions: legacy_request_id? + if 0: void + default: []varint + container_id: u8 + changed_slots: []varint + slot_id: u8 + transaction_type: varint => + 0: TYPE_NORMAL + 1: TYPE_INVENTORY_MISMATCH + 2: TYPE_ITEM_USE + 3: TYPE_ITEM_USE_ON_ENTITY + 4: TYPE_ITEM_RELEASE + has_network_ids: bool + inventory_actions: []varint + source_type: varint => + "0": "INV_SOURCE_TYPE_CONTAINER" + "1": "INV_SOURCE_TYPE_GLOBAL" + "2": "INV_SOURCE_TYPE_WORLD_INTERACTION" + "3": "INV_SOURCE_TYPE_CREATIVE" + "100": "INV_SOURCE_TYPE_CRAFT_SLOT" + "99999": "INV_SOURCE_TYPE_CRAFT" + _: source_type? + if INV_SOURCE_TYPE_CONTAINER or INV_SOURCE_TYPE_CREATIVE: + inventory_id: varint + if INV_SOURCE_TYPE_WORLD_INTERACTION: + flags: varint + if INV_SOURCE_TYPE_CRAFT or INV_SOURCE_TYPE_CRAFT_SLOT: + action: varint + default: void + slot: varint + old_item: Item + new_item: Item + new_item_stack_id: has_network_ids? + if true: zigzag32 + default: void + transaction_data: transaction_type? + if TYPE_NORMAL or TYPE_INVENTORY_MISMATCH: void + if TYPE_ITEM_USE: + action_type: varint + face: varint + hotbar_slot: varint + item_in_hand: Item + player_pos: vec3f + click_pos: vec3f + block_runtime_id: varint + if TYPE_ITEM_USE_ON_ENTITY: + entity_runtime_id: varint64 + action_type: varint + hotbar_slot: zigzag32 + item_in_hand: Item + player_pos: vec3f + click_pos: vec3f + if TYPE_ITEM_RELEASE: + action_type: varint + hotbar_slot: zigzag32 + item_in_hand: Item + head_pos: vec3f + +ItemStacks: []varint + runtime_id: zigzag32 + item: Item + +RecipeIngredient: + network_id: zigzag32 + _: network_id? + if 0: void + default: + network_data: zigzag32 + count: zigzag32 + +PotionTypeRecipes: []varint + input_item_id: zigzag32 + input_item_meta: zigzag32 + ingredient_id: zigzag32 + ingredient_meta: zigzag32 + output_item_id: zigzag32 + output_item_meta: zigzag32 + +PotionContainerChangeRecipes: []varint + input_item_id: zigzag32 + ingredient_id: zigzag32 + output_item_id: zigzag32 + +Recipes: []varint + type: varint => + '0': 'shapeless' #'ENTRY_SHAPELESS', + '1': 'shaped' #'ENTRY_SHAPED', + '2': 'furnace' # 'ENTRY_FURNACE', + # `furnace_with_metadata` is a recipe specifically used for furnace-type crafting stations. It is equal to + # `furnace`, except it has an input item with a specific metadata value, instead of any metadata value. + '3': 'furnace_with_metadata' # 'ENTRY_FURNACE_DATA', // has metadata + '4': 'multi' #'ENTRY_MULTI', //TODO + '5': 'shapeless' #'ENTRY_SHULKER_BOX', //TODO + '6': 'shapeless' #'ENTRY_SHAPELESS_CHEMISTRY', //TODO + '7': 'shaped' #'ENTRY_SHAPED_CHEMISTRY', //TODO + recipe: type? + if shapeless: + recipe_id: string + input: RecipeIngredient[]varint + output: Item[]varint + uuid: uuid + block: string + priority: zigzag32 + network_id: zigzag32 + if shaped: + recipe_id: string + width: zigzag32 + height: zigzag32 + # todo: can this become + # RecipeIngredient[$height][$width] or RecipeIngredient[]$height[]$width ? + input: []$width + _: RecipeIngredient[]$height + output: Item[]varint + uuid: uuid + block: string + priority: zigzag32 + network_id: zigzag32 + if furnace: + input_id: zigzag32 + output: Item + block: string + if furnace_with_metadata: + input_id: zigzag32 + input_meta: zigzag32 + output: Item + block: string + if multi: + uuid: uuid + network_id: zigzag32 + +SkinImage: + width: li32 + height: li32 + data: string + +Skin: + skin_id: string + skin_resource_pack: string + skin_data: SkinImage + animations: []li32 + skin_image: SkinImage + animation_type: li32 + animation_frames: lf32 + expression_type: lf32 + cape_data: SkinImage + geometry_data: string + animation_data: string + premium: string + persona: bool + cape_on_classic: bool + cape_id: string + full_skin_id: string + arm_size: string + skin_color: string + personal_pieces: []li32 + piece_id: string + piece_type: string + pack_id: string + is_default_piece: bool + product_id: string + piece_tint_colors: []li32 + piece_type: string + colors: string[]li32 + +PlayerRecords: + type: u8 => + 0: add + 1: remove + records_count: varint + records: []$records_count + _: type? + if add: + uuid: uuid + entity_unique_id: zigzag64 + username: string + xbox_user_id: string + platform_chat_id: string + build_platform: li32 + skin_data: Skin + is_teacher: bool + is_host: bool + if remove: + uuid: uuid + uuid: type? + if add: uuid + default: void + verified: bool[]$records_count + +ScoreEntries: + type: u8 => + 0: change + 1: remove + entries: []varint + scoreboard_id: zigzag64 + objective_name: string + score: li32 + _: type? + if remove: + entry_type: i8 => + 1: player + 2: entity + 3: fake_player + _: entry_type? + if player or entity: + entity_unique_id: zigzag64 + if fake_player: + custom_name: string + +ScoreboardIdentityEntries: + type: i8 => + 0: TYPE_REGISTER_IDENTITY + 1: TYPE_CLEAR_IDENTITY + entries: []varint + scoreboard_id: zigzag64 + entity_unique_id: type ? + if TYPE_REGISTER_IDENTITY: zigzag64 + default: void + +Enchant: + id: u8 + level: u8 + +EnchantOptions: []varint + cost: varint + slot_flags: li32 + equip_enchants: Enchant[]varint + held_enchants: Enchant[]varint + self_enchants: Enchant[]varint + name: string + option_id: zigzag32 + + +StackRequestSlotInfo: + container_id: u8 + slot_id: u8 + stack_id: zigzag32 + +# + +ItemStackRequests: []varint + request_id: zigzag32 + actions: []varint + type_id: u8 => + '0': 'TAKE' + '1': 'PLACE' + '2': 'SWAP' + '3': 'DROP' + '4': 'DESTROY' + '5': 'CRAFTING_CONSUME_INPUT' + '6': 'create' + '7': 'LAB_TABLE_COMBINE' + '8': 'BEACON_PAYMENT' + '9': 'CRAFTING_RECIPE' + '10': 'CRAFTING_RECIPE_AUTO' #recipe book? + '11': 'CREATIVE_CREATE' + '12': 'CRAFTING_NON_IMPLEMENTED_DEPRECATED' #anvils aren't fully implemented yet + '13': 'CRAFTING_RESULTS_DEPRECATED' #no idea what this is for + _: type_id ? + if TAKE or PLACE: + count: u8 + source: StackRequestSlotInfo + destination: StackRequestSlotInfo + if SWAP: + source: StackRequestSlotInfo + destination: StackRequestSlotInfo + if DROP: + count: u8 + source: StackRequestSlotInfo + randomly: bool + if DESTROY or CRAFTING_CONSUME_INPUT: + count: u8 + source: StackRequestSlotInfo + if create: + result_slot_id: u8 + if BEACON_PAYMENT: + primary_effect: varint + secondary_effect: varint + if CRAFTING_RECIPE or CRAFTING_RECIPE_AUTO: + recipe_network_id: varint32 + if CREATIVE_CREATE: + creative_item_network_id: varint32 + if CRAFTING_NON_IMPLEMENTED_DEPRECATED: void + if CRAFTING_RESULTS_DEPRECATED: + result_items: ItemStacks + times_crafted: u8 + + +ItemStackResponses: []varint + result: u8 + request_id: varint32 + containers: []varint + container_id: u8 + slots: []varint + slot: u8 + hotbar_slot: u8 + count: u8 + item_stack_id: varint32 + custom_name: string + +ItemComponentList: []varint + name: string + nbt: nbt \ No newline at end of file diff --git a/data/newproto.json b/data/newproto.json index 3a166bf..13ffeaf 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -1,23 +1,5 @@ { "types": { - "string": [ - "pstring", - { - "countType": "varint" - } - ], - "ByteArray": [ - "buffer", - { - "countType": "varint" - } - ], - "LittleString": [ - "pstring", - { - "countType": "li32" - } - ], "varint32": "varint", "varint64": "varint", "bool": "native", @@ -164,11 +146,21 @@ [ { "name": "name", - "type": "varint" + "type": "string" }, { "name": "type", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "1": "bool", + "2": "int", + "3": "float" + } + } + ] }, { "name": "value", @@ -177,10 +169,11 @@ { "compareTo": "type", "fields": { - "1": "bool", - "2": "varint", - "3": "lf32" - } + "bool": "bool", + "int": "varint", + "float": "lf32" + }, + "default": "void" } ] } @@ -209,13 +202,10 @@ "fields": { "true": "void", "false": "void" - } + }, + "default": "void" } ] - }, - { - "name": "data", - "type": "string" } ] ], @@ -251,7 +241,7 @@ }, { "name": "runtime_id", - "type": "i16" + "type": "li16" }, { "name": "component_based", @@ -292,7 +282,7 @@ "type": "lu16", "mappings": { "0": "0", - "0xffff": "1" + "65535": "1" } } ] @@ -441,103 +431,44 @@ "type": [ "container", [ - { - "name": "key", - "type": "varint" - }, { "name": "type", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "BYTE", + "1": "SHORT", + "2": "INT", + "3": "FLOAT", + "4": "STRING", + "5": "COMPOUND_TAG", + "6": "POS", + "7": "LONG", + "8": "VECTOR3F" + } + } + ] }, { - "anon": true, + "name": "value", "type": [ "switch", { "compareTo": "type", "fields": { - "0": [ - "container", - [ - { - "name": "value", - "type": "i8" - } - ] - ], - "1": [ - "container", - [ - { - "name": "value", - "type": "li16" - } - ] - ], - "2": [ - "container", - [ - { - "name": "value", - "type": "zigzag32" - } - ] - ], - "3": [ - "container", - [ - { - "name": "value", - "type": "lf32" - } - ] - ], - "4": [ - "container", - [ - { - "name": "value", - "type": "string" - } - ] - ], - "5": [ - "container", - [ - { - "name": "value", - "type": "nbt" - } - ] - ], - "6": [ - "container", - [ - { - "name": "value", - "type": "vec3i" - } - ] - ], - "7": [ - "container", - [ - { - "name": "value", - "type": "zigzag64" - } - ] - ], - "8": [ - "container", - [ - { - "name": "value", - "type": "li32" - } - ] - ] - } + "BYTE": "i8", + "SHORT": "li16", + "INT": "zigzag32", + "FLOAT": "lf32", + "STRING": "string", + "COMPOUND_TAG": "nbt", + "POS": "vec3i", + "LONG": "zigzag64", + "VECTOR3F": "li32" + }, + "default": "void" } ] } @@ -743,211 +674,113 @@ { "name": "inventory_actions", "type": [ - "switch", + "array", { - "compareTo": "has_network_ids", - "fields": { - "true": [ - "array", + "countType": "varint", + "type": [ + "container", + [ { - "countType": "varint", + "name": "source_type", "type": [ - "container", - [ - { - "name": "source_type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "INV_SOURCE_TYPE_CONTAINER", - "1": "INV_SOURCE_TYPE_GLOBAL", - "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", - "3": "INV_SOURCE_TYPE_CREATIVE", - "100": "INV_SOURCE_TYPE_CRAFT_SLOT", - "99999": "INV_SOURCE_TYPE_CRAFT" - } - } - ] - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "source_type", - "fields": { - "INV_SOURCE_TYPE_CONTAINER": [ - "container", - [ - { - "name": "inventory_id", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_WORLD_INTERACTION": [ - "container", - [ - { - "name": "flags", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CREATIVE": [ - "container", - [ - { - "name": "inventory_id", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CRAFT": [ - "container", - [ - { - "name": "action", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CRAFT_SLOT": [ - "container", - [ - { - "name": "action", - "type": "varint" - } - ] - ] - } - } - ] - }, - { - "name": "slot", - "type": "varint" - }, - { - "name": "old_item", - "type": "Item" - }, - { - "name": "new_item", - "type": "Item" - }, - { - "name": "new_item_stack_id", - "type": "zigzag32" + "mapper", + { + "type": "varint", + "mappings": { + "0": "INV_SOURCE_TYPE_CONTAINER", + "1": "INV_SOURCE_TYPE_GLOBAL", + "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", + "3": "INV_SOURCE_TYPE_CREATIVE", + "100": "INV_SOURCE_TYPE_CRAFT_SLOT", + "99999": "INV_SOURCE_TYPE_CRAFT" } - ] + } ] - } - ], - "false": [ - "array", + }, { - "countType": "varint", + "anon": true, "type": [ - "container", - [ - { - "name": "source_type", - "type": [ - "mapper", - { - "type": "varint", - "mappings": { - "0": "INV_SOURCE_TYPE_CONTAINER", - "1": "INV_SOURCE_TYPE_GLOBAL", - "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", - "3": "INV_SOURCE_TYPE_CREATIVE", - "100": "INV_SOURCE_TYPE_CRAFT_SLOT", - "99999": "INV_SOURCE_TYPE_CRAFT" + "switch", + { + "compareTo": "source_type", + "fields": { + "INV_SOURCE_TYPE_CONTAINER": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" } - } + ] + ], + "INV_SOURCE_TYPE_CREATIVE": [ + "container", + [ + { + "name": "inventory_id", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_WORLD_INTERACTION": [ + "container", + [ + { + "name": "flags", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] + ], + "INV_SOURCE_TYPE_CRAFT_SLOT": [ + "container", + [ + { + "name": "action", + "type": "varint" + } + ] ] }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "source_type", - "fields": { - "INV_SOURCE_TYPE_CONTAINER": [ - "container", - [ - { - "name": "inventory_id", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_WORLD_INTERACTION": [ - "container", - [ - { - "name": "flags", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CREATIVE": [ - "container", - [ - { - "name": "inventory_id", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CRAFT": [ - "container", - [ - { - "name": "action", - "type": "varint" - } - ] - ], - "INV_SOURCE_TYPE_CRAFT_SLOT": [ - "container", - [ - { - "name": "action", - "type": "varint" - } - ] - ] - } - } - ] + "default": "void" + } + ] + }, + { + "name": "slot", + "type": "varint" + }, + { + "name": "old_item", + "type": "Item" + }, + { + "name": "new_item", + "type": "Item" + }, + { + "name": "new_item_stack_id", + "type": [ + "switch", + { + "compareTo": "../has_network_ids", + "fields": { + "true": "zigzag32" }, - { - "name": "slot", - "type": "varint" - }, - { - "name": "old_item", - "type": "Item" - }, - { - "name": "new_item", - "type": "Item" - }, - { - "name": "new_item_stack_id", - "type": "void" - } - ] + "default": "void" + } ] } ] - } + ] } ] }, @@ -1043,7 +876,8 @@ } ] ] - } + }, + "default": "void" } ] } @@ -1348,7 +1182,8 @@ } ] ] - } + }, + "default": "void" } ] } @@ -1381,7 +1216,7 @@ "type": "string" }, { - "name": "skin_resource_pach", + "name": "skin_resource_pack", "type": "string" }, { @@ -1551,7 +1386,7 @@ "type": [ "switch", { - "compareTo": "type", + "compareTo": "../type", "fields": { "add": [ "container", @@ -1603,28 +1438,21 @@ } ] ] - } + }, + "default": "void" } ] } ] }, { - "anon": true, + "name": "uuid", "type": [ "switch", { "compareTo": "type", "fields": { - "add": [ - "container", - [ - { - "name": "uuid", - "type": "uuid" - } - ] - ] + "add": "uuid" }, "default": "void" } @@ -1659,139 +1487,98 @@ ] }, { - "anon": true, + "name": "entries", "type": [ - "switch", + "array", { - "compareTo": "type", - "fields": { - "remove": [ - "container", - [ - { - "name": "entries", - "type": [ - "array", - { - "countType": "varint", - "type": [ + "countType": "varint", + "type": [ + "container", + [ + { + "name": "scoreboard_id", + "type": "zigzag64" + }, + { + "name": "objective_name", + "type": "string" + }, + { + "name": "score", + "type": "li32" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "../type", + "fields": { + "remove": [ "container", [ { - "name": "scoreboard_id", - "type": "zigzag64" - }, - { - "name": "objective_name", - "type": "string" - }, - { - "name": "score", - "type": "li32" + "name": "entry_type", + "type": [ + "mapper", + { + "type": "i8", + "mappings": { + "1": "player", + "2": "entity", + "3": "fake_player" + } + } + ] }, { "anon": true, "type": [ - "container", - [ - { - "name": "entry_type", - "type": [ - "mapper", - { - "type": "i8", - "mappings": { - "1": "player", - "2": "entity", - "3": "fake_player" + "switch", + { + "compareTo": "entry_type", + "fields": { + "player": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" } - } + ] + ], + "entity": [ + "container", + [ + { + "name": "entity_unique_id", + "type": "zigzag64" + } + ] + ], + "fake_player": [ + "container", + [ + { + "name": "custom_name", + "type": "string" + } + ] ] }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "entry_type", - "fields": { - "player": [ - "container", - [ - { - "name": "entity_unique_id", - "type": "zigzag64" - } - ] - ], - "entity": [ - "container", - [ - { - "name": "entity_unique_id", - "type": "zigzag64" - } - ] - ], - "fake_player": [ - "container", - [ - { - "name": "custom_name", - "type": "string" - } - ] - ] - } - } - ] - } - ] + "default": "void" + } ] } ] ] - } - ] - } - ] - ], - "change": [ - "container", - [ - { - "name": "entries", - "type": [ - "array", - { - "countType": "varint", - "type": [ - "container", - [ - { - "name": "scoreboard_id", - "type": "zigzag64" - }, - { - "name": "objective_name", - "type": "string" - }, - { - "name": "score", - "type": "li32" - }, - { - "anon": true, - "type": "void" - } - ] - ] - } - ] - } - ] + }, + "default": "void" + } + ] + } ] - } + ] } ] } @@ -1814,67 +1601,33 @@ ] }, { - "anon": true, + "name": "entries", "type": [ - "switch", + "array", { - "compareTo": "type", - "fields": { - "TYPE_REGISTER_IDENTITY": [ - "container", - [ - { - "name": "entries", - "type": [ - "array", - { - "countType": "varint", - "type": [ - "container", - [ - { - "name": "scoreboard_id", - "type": "zigzag64" - }, - { - "name": "entity_unique_id", - "type": "zigzag64" - } - ] - ] - } - ] - } - ] - ], - "TYPE_CLEAR_IDENTITY": [ - "container", - [ - { - "name": "entries", - "type": [ - "array", - { - "countType": "varint", - "type": [ - "container", - [ - { - "name": "scoreboard_id", - "type": "zigzag64" - }, - { - "anon": true, - "type": "void" - } - ] - ] - } - ] - } - ] + "countType": "varint", + "type": [ + "container", + [ + { + "name": "scoreboard_id", + "type": "zigzag64" + }, + { + "name": "entity_unique_id", + "type": [ + "switch", + { + "compareTo": "../type", + "fields": { + "TYPE_REGISTER_IDENTITY": "zigzag64" + }, + "default": "void" + } + ] + } ] - } + ] } ] } @@ -2172,7 +1925,8 @@ } ] ] - } + }, + "default": "void" } ] } @@ -2285,145 +2039,145 @@ { "type": "varint", "mappings": { - "0x01": "login", - "0x02": "play_status", - "0x03": "server_to_client_handshake", - "0x04": "client_to_server_handshake", - "0x05": "disconnect", - "0x06": "resource_packs_info", - "0x07": "resource_pack_stack", - "0x08": "resource_pack_client_response", - "0x09": "text", - "0x0a": "set_time", - "0x0b": "start_game", - "0x0c": "add_player", - "0x0d": "add_entity", - "0x0e": "remove_entity", - "0x0f": "add_item_entity", - "0x11": "take_item_entity", - "0x12": "move_entity", - "0x13": "move_player", - "0x14": "rider_jump", - "0x15": "update_block", - "0x16": "add_painting", - "0x17": "tick_sync", - "0x18": "level_sound_event_old", - "0x19": "level_event", - "0x1a": "block_event", - "0x1b": "entity_event", - "0x1c": "mob_effect", - "0x1d": "update_attributes", - "0x1e": "inventory_transaction", - "0x1f": "mob_equipment", - "0x20": "mob_armor_equipment", - "0x21": "interact", - "0x22": "block_pick_request", - "0x23": "entity_pick_request", - "0x24": "player_action", - "0x26": "hurt_armor", - "0x27": "set_entity_data", - "0x28": "set_entity_motion", - "0x29": "set_entity_link", - "0x2a": "set_health", - "0x2b": "set_spawn_position", - "0x2c": "animate", - "0x2d": "respawn", - "0x2e": "container_open", - "0x2f": "container_close", - "0x30": "player_hotbar", - "0x31": "inventory_content", - "0x32": "inventory_slot", - "0x33": "container_set_data", - "0x34": "crafting_data", - "0x35": "crafting_event", - "0x36": "gui_data_pick_item", - "0x37": "adventure_settings", - "0x38": "block_entity_data", - "0x39": "player_input", - "0x3a": "level_chunk", - "0x3b": "set_commands_enabled", - "0x3c": "set_difficulty", - "0x3d": "change_dimension", - "0x3e": "set_player_game_type", - "0x3f": "player_list", - "0x40": "simple_event", - "0x42": "spawn_experience_orb", - "0x43": "clientbound_map_item_data_", - "0x44": "map_info_request", - "0x45": "request_chunk_radius", - "0x46": "chunk_radius_update", - "0x47": "item_frame_drop_item", - "0x48": "game_rules_changed", - "0x49": "camera", - "0x4a": "boss_event", - "0x4b": "show_credits", - "0x4c": "available_commands", - "0x4d": "command_request", - "0x4e": "command_block_update", - "0x4f": "command_output", - "0x50": "update_trade", - "0x51": "update_equipment", - "0x52": "resource_pack_data_info", - "0x53": "resource_pack_chunk_data", - "0x54": "resource_pack_chunk_request", - "0x55": "transfer", - "0x56": "play_sound", - "0x57": "stop_sound", - "0x58": "set_title", - "0x59": "add_behavior_tree", - "0x5a": "structure_block_update", - "0x5b": "show_store_offer", - "0x5c": "purchase_receipt", - "0x5d": "player_skin", - "0x5e": "sub_client_login", - "0x5f": "initiate_web_socket_connection", - "0x60": "set_last_hurt_by", - "0x61": "book_edit", - "0x62": "npc_request", - "0x63": "photo_transfer", - "0x64": "modal_form_request", - "0x65": "modal_form_response", - "0x66": "server_settings_request", - "0x67": "server_settings_response", - "0x68": "show_profile", - "0x69": "set_default_game_type", - "0x6a": "remove_objective", - "0x6b": "set_display_objective", - "0x6c": "set_score", - "0x6d": "lab_table", - "0x6e": "update_block_synced", - "0x6f": "move_entity_delta", - "0x70": "set_scoreboard_identity", - "0x71": "set_local_player_as_initialized", - "0x72": "update_soft_enum", - "0x73": "network_stack_latency", - "0x75": "script_custom_event", - "0x76": "spawn_particle_effect", - "0x77": "available_entity_identifiers", - "0x78": "level_sound_event_v2", - "0x79": "network_chunk_publisher_update", - "0x7a": "biome_definition_list", - "0x7b": "level_sound_event", - "0x7c": "level_event_generic", - "0x7d": "lectern_update", - "0x7e": "video_stream_connect", - "0x81": "client_cache_status", - "0x82": "on_screen_texture_animation", - "0x83": "map_create_locked_copy", - "0x84": "structure_template_data_export_request", - "0x85": "structure_template_data_export_response", - "0x86": "update_block_properties", - "0x87": "client_cache_blob_status", - "0x88": "client_cache_miss_response", - "0x8f": "network_settings", - "0x91": "creative_content", - "0x92": "player_enchant_options", - "0x93": "item_stack_request", - "0x94": "item_stack_response", - "0x97": "update_player_game_type", - "0x9c": "packet_violation_warning", - "0xa2": "item_component", - "0xa3": "filter_text_packet" + "1": "login", + "2": "play_status", + "3": "server_to_client_handshake", + "4": "client_to_server_handshake", + "5": "disconnect", + "6": "resource_packs_info", + "7": "resource_pack_stack", + "8": "resource_pack_client_response", + "9": "text", + "10": "set_time", + "11": "start_game", + "12": "add_player", + "13": "add_entity", + "14": "remove_entity", + "15": "add_item_entity", + "17": "take_item_entity", + "18": "move_entity", + "19": "move_player", + "20": "rider_jump", + "21": "update_block", + "22": "add_painting", + "23": "tick_sync", + "24": "level_sound_event_old", + "25": "level_event", + "26": "block_event", + "27": "entity_event", + "28": "mob_effect", + "29": "update_attributes", + "30": "inventory_transaction", + "31": "mob_equipment", + "32": "mob_armor_equipment", + "33": "interact", + "34": "block_pick_request", + "35": "entity_pick_request", + "36": "player_action", + "38": "hurt_armor", + "39": "set_entity_data", + "40": "set_entity_motion", + "41": "set_entity_link", + "42": "set_health", + "43": "set_spawn_position", + "44": "animate", + "45": "respawn", + "46": "container_open", + "47": "container_close", + "48": "player_hotbar", + "49": "inventory_content", + "50": "inventory_slot", + "51": "container_set_data", + "52": "crafting_data", + "53": "crafting_event", + "54": "gui_data_pick_item", + "55": "adventure_settings", + "56": "block_entity_data", + "57": "player_input", + "58": "level_chunk", + "59": "set_commands_enabled", + "60": "set_difficulty", + "61": "change_dimension", + "62": "set_player_game_type", + "63": "player_list", + "64": "simple_event", + "66": "spawn_experience_orb", + "67": "clientbound_map_item_data", + "68": "map_info_request", + "69": "request_chunk_radius", + "70": "chunk_radius_update", + "71": "item_frame_drop_item", + "72": "game_rules_changed", + "73": "camera", + "74": "boss_event", + "75": "show_credits", + "76": "available_commands", + "77": "command_request", + "78": "command_block_update", + "79": "command_output", + "80": "update_trade", + "81": "update_equipment", + "82": "resource_pack_data_info", + "83": "resource_pack_chunk_data", + "84": "resource_pack_chunk_request", + "85": "transfer", + "86": "play_sound", + "87": "stop_sound", + "88": "set_title", + "89": "add_behavior_tree", + "90": "structure_block_update", + "91": "show_store_offer", + "92": "purchase_receipt", + "93": "player_skin", + "94": "sub_client_login", + "95": "initiate_web_socket_connection", + "96": "set_last_hurt_by", + "97": "book_edit", + "98": "npc_request", + "99": "photo_transfer", + "100": "modal_form_request", + "101": "modal_form_response", + "102": "server_settings_request", + "103": "server_settings_response", + "104": "show_profile", + "105": "set_default_game_type", + "106": "remove_objective", + "107": "set_display_objective", + "108": "set_score", + "109": "lab_table", + "110": "update_block_synced", + "111": "move_entity_delta", + "112": "set_scoreboard_identity", + "113": "set_local_player_as_initialized", + "114": "update_soft_enum", + "115": "network_stack_latency", + "117": "script_custom_event", + "118": "spawn_particle_effect", + "119": "available_entity_identifiers", + "120": "level_sound_event_v2", + "121": "network_chunk_publisher_update", + "122": "biome_definition_list", + "123": "level_sound_event", + "124": "level_event_generic", + "125": "lectern_update", + "126": "video_stream_connect", + "129": "client_cache_status", + "130": "on_screen_texture_animation", + "131": "map_create_locked_copy", + "132": "structure_template_data_export_request", + "133": "structure_template_data_export_response", + "134": "update_block_properties", + "135": "client_cache_blob_status", + "136": "client_cache_miss_response", + "143": "network_settings", + "145": "creative_content", + "146": "player_enchant_options", + "147": "item_stack_request", + "148": "item_stack_response", + "151": "update_player_game_type", + "156": "packet_violation_warning", + "162": "item_component", + "163": "filter_text_packet" } } ] @@ -2498,7 +2252,7 @@ "player_list": "packet_player_list", "simple_event": "packet_simple_event", "spawn_experience_orb": "packet_spawn_experience_orb", - "clientbound_map_item_data_": "packet_clientbound_map_item_data_", + "clientbound_map_item_data": "packet_clientbound_map_item_data", "map_info_request": "packet_map_info_request", "request_chunk_radius": "packet_request_chunk_radius", "chunk_radius_update": "packet_chunk_radius_update", @@ -2574,7 +2328,8 @@ "packet_violation_warning": "packet_packet_violation_warning", "item_component": "packet_item_component", "filter_text_packet": "packet_filter_text_packet" - } + }, + "default": "void" } ] } @@ -4029,7 +3784,7 @@ } ] ], - "packet_clientbound_map_item_data_": [ + "packet_clientbound_map_item_data": [ "container", [ { @@ -4587,7 +4342,15 @@ } ] ], - "packet_set_score": "ScoreEntries", + "packet_set_score": [ + "container", + [ + { + "name": "entries", + "type": "ScoreEntries" + } + ] + ], "packet_lab_table": [ "container", [ @@ -4983,6 +4746,24 @@ "type": "bool" } ] + ], + "string": [ + "pstring", + { + "countType": "varint" + } + ], + "ByteArray": [ + "buffer", + { + "countType": "varint" + } + ], + "LittleString": [ + "pstring", + { + "countType": "li32" + } ] } } \ No newline at end of file From da85b80c591194cb1aed391473e8d7c28c387236 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 7 Feb 2021 05:28:03 -0500 Subject: [PATCH 081/106] server player extends connection --- src/auth/{jwt.js => chains.js} | 18 ++++-- src/auth/encryption.js | 28 ++++++++- src/connection.js | 107 ++++++++++++++++++++++++++++++++ src/server.js | 109 +-------------------------------- 4 files changed, 148 insertions(+), 114 deletions(-) rename src/auth/{jwt.js => chains.js} (92%) create mode 100644 src/connection.js diff --git a/src/auth/jwt.js b/src/auth/chains.js similarity index 92% rename from src/auth/jwt.js rename to src/auth/chains.js index 155f7fb..5208b9f 100644 --- a/src/auth/jwt.js +++ b/src/auth/chains.js @@ -80,7 +80,18 @@ function decodeLoginJWT(authTokens, skinTokens) { return { key, userData: data, skinData } } -function test() { +function encodeLoginJWT(localChain, mojangChain) { + const chains = [] + chains.push(localChain) + for (const chain of mojangChain) { + chains.push(chain) + } + return chains +} + +module.exports = { encodeLoginJWT, decodeLoginJWT } + +function testServer() { const loginPacket = require('./login.json') // console.log(loginPacket) @@ -95,10 +106,7 @@ function test() { } console.log('Authed') - // console.log(loginPacket) } -module.exports = { decodeLoginJWT } - -// test() \ No newline at end of file +// testServer() \ No newline at end of file diff --git a/src/auth/encryption.js b/src/auth/encryption.js index a487f3e..f32bc69 100644 --- a/src/auth/encryption.js +++ b/src/auth/encryption.js @@ -4,15 +4,19 @@ const { Ber } = require('asn1') const ec_pem = require('ec-pem') const SALT = '🧂' +const curve = 'secp384r1' function Encrypt(client, options) { + client.ecdhKeyPair = crypto.createECDH(curve) + client.ecdhKeyPair.generateKeys() + + createClientChain(client) + function startClientboundEncryption(publicKey) { console.warn('[encrypt] Pub key base64: ', publicKey) const pubKeyBuf = readX509PublicKey(publicKey.key) - const curve = 'secp384r1' - const alice = crypto.createECDH(curve) - alice.generateKeys() + const alice = client.ecdhKeyPair const alicePEM = ec_pem(alice, curve) // https://github.com/nodejs/node/issues/15116#issuecomment-384790125 const alicePEMPrivate = alicePEM.encodePrivateKey() // Shared secret from bob's public key + our private key @@ -47,9 +51,27 @@ function Encrypt(client, options) { client.startEncryption(initial) } + function startServerboundEncryption() { + + } + client.on('server.client_handshake', startClientboundEncryption) } +function createClientChain(client) { + const alice = client.ecdhKeyPair + const alicePEM = ec_pem(alice, curve) // https://github.com/nodejs/node/issues/15116#issuecomment-384790125 + const alicePEMPrivate = alicePEM.encodePrivateKey() + const x509 = writeX509PublicKey(alice.getPublicKey()) + + const token = JWT.sign({ + salt: toBase64(SALT), + signedToken: alice.getPublicKey('base64') + }, alicePEMPrivate, { algorithm: 'ES384', header: { x5u: x509 } }) + + client.clientChain = token +} + function toBase64(string) { return Buffer.from(string).toString('base64') } diff --git a/src/connection.js b/src/connection.js new file mode 100644 index 0000000..9830b57 --- /dev/null +++ b/src/connection.js @@ -0,0 +1,107 @@ +const BinaryStream = require('@jsprismarine/jsbinaryutils').default +const BatchPacket = require('./BatchPacket') +const cipher = require('./transforms/encryption') +const { EventEmitter } = require('events') +const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') + + +class Connection extends EventEmitter { + startEncryption(iv) { + this.encryptionEnabled = true + + this.decrypt = cipher.createDecryptor(this, iv) + this.encrypt = cipher.createEncryptor(this, iv) + } + + write(name, params) { // TODO: Batch + console.log('Need to encode', name, params) + const batch = new BatchPacket() + const packet = this.server.serializer.createPacketBuffer({ name, params }) + batch.addEncodedPacket(packet) + + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } + } + + writeRaw(name, buffer) { // skip protodef serializaion + // temporary hard coded stuff + const batch = new BatchPacket() + if (name == 'biome_definition_list') { + // so we can send nbt straight from file without parsing + const stream = new BinaryStream() + stream.writeUnsignedVarInt(0x7a) + stream.append(buffer) + batch.addEncodedPacket(stream.getBuffer()) + // console.log('----- SENDING BIOME DEFINITIONS') + } + + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } + } + + sendDecryptedBatch(batch) { + const buf = batch.encode() + // send to raknet + const sendPacket = new EncapsulatedPacket(); + sendPacket.reliability = 0; + sendPacket.buffer = buf + + this.connection.addEncapsulatedToQueue(sendPacket) + this.connection.sendQueue() + } + + sendEncryptedBatch(batch) { + const buf = batch.stream.getBuffer() + console.log('Sending encrypted batch', batch) + this.encrypt(buf) + } + + // These are callbacks called from encryption.js + onEncryptedPacket = (buf) => { + console.log('ENC BUF', buf) + const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header + const sendPacket = new EncapsulatedPacket(); + sendPacket.reliability = 0 + sendPacket.buffer = packet + console.log('Sending wrapped encrypted batch', packet) + this.connection.addEncapsulatedToQueue(sendPacket) + } + + onDecryptedPacket = (buf) => { + console.log('Decrypted', buf) + + const stream = new BinaryStream(buf) + const packets = BatchPacket.getPackets(stream) + + for (const packet of packets) { + this.readPacket(packet) + } + } + + handle(buffer) { // handle encapsulated + if (buffer[0] == 0xfe) { // wrapper + + if (this.encryptionEnabled) { + // console.log('READING ENCRYPTED PACKET', buffer) + this.decrypt(buffer.slice(1)) + } else { + const stream = new BinaryStream(buffer) + const batch = new BatchPacket(stream) + batch.decode() + const packets = batch.getPackets() + console.log('Reading ', packets.length, 'packets') + for (var packet of packets) { + this.readPacket(packet) + } + } + } + } +} + +module.exports = { Connection } \ No newline at end of file diff --git a/src/server.js b/src/server.js index 636f104..af25535 100644 --- a/src/server.js +++ b/src/server.js @@ -1,14 +1,9 @@ -const BinaryStream = require('@jsprismarine/jsbinaryutils').default const Listener = require('@jsprismarine/raknet/listener') const { ProtoDef, Parser, Serializer } = require('protodef') -const BatchPacket = require('./BatchPacket') const { EventEmitter } = require('events') -const cipher = require('./transforms/encryption') const { Encrypt } = require('./auth/encryption') - -const { decodeLoginJWT } = require('./auth/jwt') -const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') - +const { decodeLoginJWT } = require('./auth/chains') +const { Connection } = require('./connection') var protocol = require('../data/newproto.json').types; @@ -41,7 +36,7 @@ const PLAY_STATUS = { 'LoginFailedServerFull': 7 } -class Player extends EventEmitter { +class Player extends Connection { constructor(server, connection, options) { super() this.server = server @@ -100,84 +95,6 @@ class Player extends EventEmitter { this.emit('join') } - startEncryption(iv) { - this.encryptionEnabled = true - - this.decrypt = cipher.createDecryptor(this, iv) - this.encrypt = cipher.createEncryptor(this, iv) - } - - write(name, params) { // TODO: Batch - console.log('Need to encode', name, params) - const batch = new BatchPacket() - const packet = this.server.serializer.createPacketBuffer({ name, params }) - batch.addEncodedPacket(packet) - - if (this.encryptionEnabled) { - this.sendEncryptedBatch(batch) - } else { - this.sendDecryptedBatch(batch) - } - } - - writeRaw(name, buffer) { // skip protodef serializaion - // temporary hard coded stuff - const batch = new BatchPacket() - if (name == 'biome_definition_list') { - // so we can send nbt straight from file without parsing - const stream = new BinaryStream() - stream.writeUnsignedVarInt(0x7a) - stream.append(buffer) - batch.addEncodedPacket(stream.getBuffer()) - // console.log('----- SENDING BIOME DEFINITIONS') - } - - if (this.encryptionEnabled) { - this.sendEncryptedBatch(batch) - } else { - this.sendDecryptedBatch(batch) - } - } - - sendDecryptedBatch(batch) { - const buf = batch.encode() - // send to raknet - const sendPacket = new EncapsulatedPacket(); - sendPacket.reliability = 0; - sendPacket.buffer = buf - - this.connection.addEncapsulatedToQueue(sendPacket) - this.connection.sendQueue() - } - - sendEncryptedBatch(batch) { - const buf = batch.stream.getBuffer() - console.log('Sending encrypted batch', batch) - this.encrypt(buf) - } - - // These are callbacks called from encryption.js - onEncryptedPacket = (buf) => { - console.log('ENC BUF', buf) - const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header - const sendPacket = new EncapsulatedPacket(); - sendPacket.reliability = 0 - sendPacket.buffer = packet - console.log('Sending wrapped encrypted batch', packet) - this.connection.addEncapsulatedToQueue(sendPacket) - } - - onDecryptedPacket = (buf) => { - console.log('Decrypted', buf) - - const stream = new BinaryStream(buf) - const packets = BatchPacket.getPackets(stream) - - for (const packet of packets) { - this.readPacket(packet) - } - } - readPacket(packet) { console.log('packet', packet) const des = this.server.deserializer.parsePacketBuffer(packet) @@ -193,26 +110,6 @@ class Player extends EventEmitter { console.log('ignoring, unhandled') } this.emit(des.data.name, des.data.params) - - } - - handle(buffer) { // handle encapsulated - if (buffer[0] == 0xfe) { // wrapper - - if (this.encryptionEnabled) { - // console.log('READING ENCRYPTED PACKET', buffer) - this.decrypt(buffer.slice(1)) - } else { - const stream = new BinaryStream(buffer) - const batch = new BatchPacket(stream) - batch.decode() - const packets = batch.getPackets() - console.log('Reading ', packets.length, 'packets') - for (var packet of packets) { - this.readPacket(packet) - } - } - } } } From 51214fcf2993c0c70a9e6b9d015f0178015ba261 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 7 Feb 2021 16:47:07 -0500 Subject: [PATCH 082/106] seperate packet map from proto.yml --- data/new/compile.js | 2 +- data/new/packet_map.yml | 283 ++++++++++++++++ data/new/proto.yml | 701 ++++++++-------------------------------- 3 files changed, 424 insertions(+), 562 deletions(-) create mode 100644 data/new/packet_map.yml diff --git a/data/new/compile.js b/data/new/compile.js index 8a3b575..2800ba8 100644 --- a/data/new/compile.js +++ b/data/new/compile.js @@ -2,7 +2,7 @@ const fs = require('fs') let compile try { - compile = require('protodef-yaml/compiler') + compile = require('protodef-yaml/compiler').compile } catch (e) { require('child_process').execSync('npx protodef-yaml proto.yml protocol.json') } diff --git a/data/new/packet_map.yml b/data/new/packet_map.yml new file mode 100644 index 0000000..6f698c9 --- /dev/null +++ b/data/new/packet_map.yml @@ -0,0 +1,283 @@ + +!import: types.yaml +mcpe_packet: + name: varint => + 0x01: login + 0x02: play_status + 0x03: server_to_client_handshake + 0x04: client_to_server_handshake + 0x05: disconnect + 0x06: resource_packs_info + 0x07: resource_pack_stack + 0x08: resource_pack_client_response + 0x09: text + 0x0a: set_time + 0x0b: start_game + 0x0c: add_player + 0x0d: add_entity + 0x0e: remove_entity + 0x0f: add_item_entity + 0x11: take_item_entity + 0x12: move_entity + 0x13: move_player + 0x14: rider_jump + 0x15: update_block + 0x16: add_painting + 0x17: tick_sync + 0x18: level_sound_event_old + 0x19: level_event + 0x1a: block_event + 0x1b: entity_event + 0x1c: mob_effect + 0x1d: update_attributes + 0x1e: inventory_transaction + 0x1f: mob_equipment + 0x20: mob_armor_equipment + 0x21: interact + 0x22: block_pick_request + 0x23: entity_pick_request + 0x24: player_action + 0x26: hurt_armor + 0x27: set_entity_data + 0x28: set_entity_motion + 0x29: set_entity_link + 0x2a: set_health + 0x2b: set_spawn_position + 0x2c: animate + 0x2d: respawn + 0x2e: container_open + 0x2f: container_close + 0x30: player_hotbar + 0x31: inventory_content + 0x32: inventory_slot + 0x33: container_set_data + 0x34: crafting_data + 0x35: crafting_event + 0x36: gui_data_pick_item + 0x37: adventure_settings + 0x38: block_entity_data + 0x39: player_input + 0x3a: level_chunk + 0x3b: set_commands_enabled + 0x3c: set_difficulty + 0x3d: change_dimension + 0x3e: set_player_game_type + 0x3f: player_list + 0x40: simple_event + 0x42: spawn_experience_orb + 0x43: clientbound_map_item_data + 0x44: map_info_request + 0x45: request_chunk_radius + 0x46: chunk_radius_update + 0x47: item_frame_drop_item + 0x48: game_rules_changed + 0x49: camera + 0x4a: boss_event + 0x4b: show_credits + 0x4c: available_commands + 0x4d: command_request + 0x4e: command_block_update + 0x4f: command_output + 0x50: update_trade + 0x51: update_equipment + 0x52: resource_pack_data_info + 0x53: resource_pack_chunk_data + 0x54: resource_pack_chunk_request + 0x55: transfer + 0x56: play_sound + 0x57: stop_sound + 0x58: set_title + 0x59: add_behavior_tree + 0x5a: structure_block_update + 0x5b: show_store_offer + 0x5c: purchase_receipt + 0x5d: player_skin + 0x5e: sub_client_login + 0x5f: initiate_web_socket_connection + 0x60: set_last_hurt_by + 0x61: book_edit + 0x62: npc_request + 0x63: photo_transfer + 0x64: modal_form_request + 0x65: modal_form_response + 0x66: server_settings_request + 0x67: server_settings_response + 0x68: show_profile + 0x69: set_default_game_type + 0x6a: remove_objective + 0x6b: set_display_objective + 0x6c: set_score + 0x6d: lab_table + 0x6e: update_block_synced + 0x6f: move_entity_delta + 0x70: set_scoreboard_identity + 0x71: set_local_player_as_initialized + 0x72: update_soft_enum + 0x73: network_stack_latency + 0x75: script_custom_event + 0x76: spawn_particle_effect + 0x77: available_entity_identifiers + 0x78: level_sound_event_v2 + 0x79: network_chunk_publisher_update + 0x7a: biome_definition_list + 0x7b: level_sound_event + 0x7c: level_event_generic + 0x7d: lectern_update + 0x7e: video_stream_connect + 0x81: client_cache_status + 0x82: on_screen_texture_animation + 0x83: map_create_locked_copy + 0x84: structure_template_data_export_request + 0x85: structure_template_data_export_response + 0x86: update_block_properties + 0x87: client_cache_blob_status + 0x88: client_cache_miss_response + 0x8f: network_settings + 0x91: creative_content + 0x92: player_enchant_options + 0x93: item_stack_request + 0x94: item_stack_response + 0x97: update_player_game_type + 0x9c: packet_violation_warning + 0xa2: item_component + 0xa3: filter_text_packet + params: name ? + if login: packet_login + if play_status: packet_play_status + if server_to_client_handshake: packet_server_to_client_handshake + if client_to_server_handshake: packet_client_to_server_handshake + if disconnect: packet_disconnect + if resource_packs_info: packet_resource_packs_info + if resource_pack_stack: packet_resource_pack_stack + if resource_pack_client_response: packet_resource_pack_client_response + if text: packet_text + if set_time: packet_set_time + if start_game: packet_start_game + if add_player: packet_add_player + if add_entity: packet_add_entity + if remove_entity: packet_remove_entity + if add_item_entity: packet_add_item_entity + if take_item_entity: packet_take_item_entity + if move_entity: packet_move_entity + if move_player: packet_move_player + if rider_jump: packet_rider_jump + if update_block: packet_update_block + if add_painting: packet_add_painting + if tick_sync: packet_tick_sync + if level_sound_event_old: packet_level_sound_event_old + if level_event: packet_level_event + if block_event: packet_block_event + if entity_event: packet_entity_event + if mob_effect: packet_mob_effect + if update_attributes: packet_update_attributes + if inventory_transaction: packet_inventory_transaction + if mob_equipment: packet_mob_equipment + if mob_armor_equipment: packet_mob_armor_equipment + if interact: packet_interact + if block_pick_request: packet_block_pick_request + if entity_pick_request: packet_entity_pick_request + if player_action: packet_player_action + if hurt_armor: packet_hurt_armor + if set_entity_data: packet_set_entity_data + if set_entity_motion: packet_set_entity_motion + if set_entity_link: packet_set_entity_link + if set_health: packet_set_health + if set_spawn_position: packet_set_spawn_position + if animate: packet_animate + if respawn: packet_respawn + if container_open: packet_container_open + if container_close: packet_container_close + if player_hotbar: packet_player_hotbar + if inventory_content: packet_inventory_content + if inventory_slot: packet_inventory_slot + if container_set_data: packet_container_set_data + if crafting_data: packet_crafting_data + if crafting_event: packet_crafting_event + if gui_data_pick_item: packet_gui_data_pick_item + if adventure_settings: packet_adventure_settings + if block_entity_data: packet_block_entity_data + if player_input: packet_player_input + if level_chunk: packet_level_chunk + if set_commands_enabled: packet_set_commands_enabled + if set_difficulty: packet_set_difficulty + if change_dimension: packet_change_dimension + if set_player_game_type: packet_set_player_game_type + if player_list: packet_player_list + if simple_event: packet_simple_event + if spawn_experience_orb: packet_spawn_experience_orb + if clientbound_map_item_data: packet_clientbound_map_item_data + if map_info_request: packet_map_info_request + if request_chunk_radius: packet_request_chunk_radius + if chunk_radius_update: packet_chunk_radius_update + if item_frame_drop_item: packet_item_frame_drop_item + if game_rules_changed: packet_game_rules_changed + if camera: packet_camera + if boss_event: packet_boss_event + if show_credits: packet_show_credits + if available_commands: packet_available_commands + if command_request: packet_command_request + if command_block_update: packet_command_block_update + if command_output: packet_command_output + if update_trade: packet_update_trade + if update_equipment: packet_update_equipment + if resource_pack_data_info: packet_resource_pack_data_info + if resource_pack_chunk_data: packet_resource_pack_chunk_data + if resource_pack_chunk_request: packet_resource_pack_chunk_request + if transfer: packet_transfer + if play_sound: packet_play_sound + if stop_sound: packet_stop_sound + if set_title: packet_set_title + if add_behavior_tree: packet_add_behavior_tree + if structure_block_update: packet_structure_block_update + if show_store_offer: packet_show_store_offer + if purchase_receipt: packet_purchase_receipt + if player_skin: packet_player_skin + if sub_client_login: packet_sub_client_login + if initiate_web_socket_connection: packet_initiate_web_socket_connection + if set_last_hurt_by: packet_set_last_hurt_by + if book_edit: packet_book_edit + if npc_request: packet_npc_request + if photo_transfer: packet_photo_transfer + if modal_form_request: packet_modal_form_request + if modal_form_response: packet_modal_form_response + if server_settings_request: packet_server_settings_request + if server_settings_response: packet_server_settings_response + if show_profile: packet_show_profile + if set_default_game_type: packet_set_default_game_type + if remove_objective: packet_remove_objective + if set_display_objective: packet_set_display_objective + if set_score: packet_set_score + if lab_table: packet_lab_table + if update_block_synced: packet_update_block_synced + if move_entity_delta: packet_move_entity_delta + if set_scoreboard_identity: packet_set_scoreboard_identity + if set_local_player_as_initialized: packet_set_local_player_as_initialized + if update_soft_enum: packet_update_soft_enum + if network_stack_latency: packet_network_stack_latency + if script_custom_event: packet_script_custom_event + if spawn_particle_effect: packet_spawn_particle_effect + if available_entity_identifiers: packet_available_entity_identifiers + if level_sound_event_v2: packet_level_sound_event_v2 + if network_chunk_publisher_update: packet_network_chunk_publisher_update + if biome_definition_list: packet_biome_definition_list + if level_sound_event: packet_level_sound_event + if level_event_generic: packet_level_event_generic + if lectern_update: packet_lectern_update + if video_stream_connect: packet_video_stream_connect + if client_cache_status: packet_client_cache_status + if on_screen_texture_animation: packet_on_screen_texture_animation + if map_create_locked_copy: packet_map_create_locked_copy + if structure_template_data_export_request: packet_structure_template_data_export_request + if structure_template_data_export_response: packet_structure_template_data_export_response + if update_block_properties: packet_update_block_properties + if client_cache_blob_status: packet_client_cache_blob_status + if client_cache_miss_response: packet_client_cache_miss_response + if network_settings: packet_network_settings + if creative_content: packet_creative_content + if player_enchant_options: packet_player_enchant_options + if item_stack_request: packet_item_stack_request + if item_stack_response: packet_item_stack_response + if update_player_game_type: packet_update_player_game_type + if packet_violation_warning: packet_packet_violation_warning + if item_component: packet_item_component + if filter_text_packet: packet_filter_text_packet \ No newline at end of file diff --git a/data/new/proto.yml b/data/new/proto.yml index 37f7f0a..737c70e 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -12,294 +12,11 @@ byterot: native MapInfo: native nbt: native -!import: types.yaml - -mcpe_packet: - name: varint => - 0x01: login - 0x02: play_status - 0x03: server_to_client_handshake - 0x04: client_to_server_handshake - 0x05: disconnect - 0x06: resource_packs_info - 0x07: resource_pack_stack - 0x08: resource_pack_client_response - 0x09: text - 0x0a: set_time - 0x0b: start_game - 0x0c: add_player - 0x0d: add_entity - 0x0e: remove_entity - 0x0f: add_item_entity - 0x11: take_item_entity - 0x12: move_entity - 0x13: move_player - 0x14: rider_jump - 0x15: update_block - 0x16: add_painting - 0x17: tick_sync - 0x18: level_sound_event_old - 0x19: level_event - 0x1a: block_event - 0x1b: entity_event - 0x1c: mob_effect - 0x1d: update_attributes - 0x1e: inventory_transaction - 0x1f: mob_equipment - 0x20: mob_armor_equipment - 0x21: interact - 0x22: block_pick_request - 0x23: entity_pick_request - 0x24: player_action - 0x26: hurt_armor - 0x27: set_entity_data - 0x28: set_entity_motion - 0x29: set_entity_link - 0x2a: set_health - 0x2b: set_spawn_position - 0x2c: animate - 0x2d: respawn - 0x2e: container_open - 0x2f: container_close - 0x30: player_hotbar - 0x31: inventory_content - 0x32: inventory_slot - 0x33: container_set_data - 0x34: crafting_data - 0x35: crafting_event - 0x36: gui_data_pick_item - 0x37: adventure_settings - 0x38: block_entity_data - 0x39: player_input - 0x3a: level_chunk - 0x3b: set_commands_enabled - 0x3c: set_difficulty - 0x3d: change_dimension - 0x3e: set_player_game_type - 0x3f: player_list - 0x40: simple_event - 0x42: spawn_experience_orb - 0x43: clientbound_map_item_data - 0x44: map_info_request - 0x45: request_chunk_radius - 0x46: chunk_radius_update - 0x47: item_frame_drop_item - 0x48: game_rules_changed - 0x49: camera - 0x4a: boss_event - 0x4b: show_credits - 0x4c: available_commands - 0x4d: command_request - 0x4e: command_block_update - 0x4f: command_output - 0x50: update_trade - 0x51: update_equipment - 0x52: resource_pack_data_info - 0x53: resource_pack_chunk_data - 0x54: resource_pack_chunk_request - 0x55: transfer - 0x56: play_sound - 0x57: stop_sound - 0x58: set_title - 0x59: add_behavior_tree - 0x5a: structure_block_update - 0x5b: show_store_offer - 0x5c: purchase_receipt - 0x5d: player_skin - 0x5e: sub_client_login - 0x5f: initiate_web_socket_connection - 0x60: set_last_hurt_by - 0x61: book_edit - 0x62: npc_request - 0x63: photo_transfer - 0x64: modal_form_request - 0x65: modal_form_response - 0x66: server_settings_request - 0x67: server_settings_response - 0x68: show_profile - 0x69: set_default_game_type - 0x6a: remove_objective - 0x6b: set_display_objective - 0x6c: set_score - 0x6d: lab_table - 0x6e: update_block_synced - 0x6f: move_entity_delta - 0x70: set_scoreboard_identity - 0x71: set_local_player_as_initialized - 0x72: update_soft_enum - 0x73: network_stack_latency - 0x75: script_custom_event - 0x76: spawn_particle_effect - 0x77: available_entity_identifiers - 0x78: level_sound_event_v2 - 0x79: network_chunk_publisher_update - 0x7a: biome_definition_list - 0x7b: level_sound_event - 0x7c: level_event_generic - 0x7d: lectern_update - 0x7e: video_stream_connect - 0x81: client_cache_status - 0x82: on_screen_texture_animation - 0x83: map_create_locked_copy - 0x84: structure_template_data_export_request - 0x85: structure_template_data_export_response - 0x86: update_block_properties - 0x87: client_cache_blob_status - 0x88: client_cache_miss_response - 0x8f: network_settings - 0x91: creative_content - 0x92: player_enchant_options - 0x93: item_stack_request - 0x94: item_stack_response - 0x97: update_player_game_type - 0x9c: packet_violation_warning - 0xa2: item_component - 0xa3: filter_text_packet - params: name ? - if login: packet_login - if play_status: packet_play_status - if server_to_client_handshake: packet_server_to_client_handshake - if client_to_server_handshake: packet_client_to_server_handshake - if disconnect: packet_disconnect - if resource_packs_info: packet_resource_packs_info - if resource_pack_stack: packet_resource_pack_stack - if resource_pack_client_response: packet_resource_pack_client_response - if text: packet_text - if set_time: packet_set_time - if start_game: packet_start_game - if add_player: packet_add_player - if add_entity: packet_add_entity - if remove_entity: packet_remove_entity - if add_item_entity: packet_add_item_entity - if take_item_entity: packet_take_item_entity - if move_entity: packet_move_entity - if move_player: packet_move_player - if rider_jump: packet_rider_jump - if update_block: packet_update_block - if add_painting: packet_add_painting - if tick_sync: packet_tick_sync - if level_sound_event_old: packet_level_sound_event_old - if level_event: packet_level_event - if block_event: packet_block_event - if entity_event: packet_entity_event - if mob_effect: packet_mob_effect - if update_attributes: packet_update_attributes - if inventory_transaction: packet_inventory_transaction - if mob_equipment: packet_mob_equipment - if mob_armor_equipment: packet_mob_armor_equipment - if interact: packet_interact - if block_pick_request: packet_block_pick_request - if entity_pick_request: packet_entity_pick_request - if player_action: packet_player_action - if hurt_armor: packet_hurt_armor - if set_entity_data: packet_set_entity_data - if set_entity_motion: packet_set_entity_motion - if set_entity_link: packet_set_entity_link - if set_health: packet_set_health - if set_spawn_position: packet_set_spawn_position - if animate: packet_animate - if respawn: packet_respawn - if container_open: packet_container_open - if container_close: packet_container_close - if player_hotbar: packet_player_hotbar - if inventory_content: packet_inventory_content - if inventory_slot: packet_inventory_slot - if container_set_data: packet_container_set_data - if crafting_data: packet_crafting_data - if crafting_event: packet_crafting_event - if gui_data_pick_item: packet_gui_data_pick_item - if adventure_settings: packet_adventure_settings - if block_entity_data: packet_block_entity_data - if player_input: packet_player_input - if level_chunk: packet_level_chunk - if set_commands_enabled: packet_set_commands_enabled - if set_difficulty: packet_set_difficulty - if change_dimension: packet_change_dimension - if set_player_game_type: packet_set_player_game_type - if player_list: packet_player_list - if simple_event: packet_simple_event - if spawn_experience_orb: packet_spawn_experience_orb - if clientbound_map_item_data: packet_clientbound_map_item_data - if map_info_request: packet_map_info_request - if request_chunk_radius: packet_request_chunk_radius - if chunk_radius_update: packet_chunk_radius_update - if item_frame_drop_item: packet_item_frame_drop_item - if game_rules_changed: packet_game_rules_changed - if camera: packet_camera - if boss_event: packet_boss_event - if show_credits: packet_show_credits - if available_commands: packet_available_commands - if command_request: packet_command_request - if command_block_update: packet_command_block_update - if command_output: packet_command_output - if update_trade: packet_update_trade - if update_equipment: packet_update_equipment - if resource_pack_data_info: packet_resource_pack_data_info - if resource_pack_chunk_data: packet_resource_pack_chunk_data - if resource_pack_chunk_request: packet_resource_pack_chunk_request - if transfer: packet_transfer - if play_sound: packet_play_sound - if stop_sound: packet_stop_sound - if set_title: packet_set_title - if add_behavior_tree: packet_add_behavior_tree - if structure_block_update: packet_structure_block_update - if show_store_offer: packet_show_store_offer - if purchase_receipt: packet_purchase_receipt - if player_skin: packet_player_skin - if sub_client_login: packet_sub_client_login - if initiate_web_socket_connection: packet_initiate_web_socket_connection - if set_last_hurt_by: packet_set_last_hurt_by - if book_edit: packet_book_edit - if npc_request: packet_npc_request - if photo_transfer: packet_photo_transfer - if modal_form_request: packet_modal_form_request - if modal_form_response: packet_modal_form_response - if server_settings_request: packet_server_settings_request - if server_settings_response: packet_server_settings_response - if show_profile: packet_show_profile - if set_default_game_type: packet_set_default_game_type - if remove_objective: packet_remove_objective - if set_display_objective: packet_set_display_objective - if set_score: packet_set_score - if lab_table: packet_lab_table - if update_block_synced: packet_update_block_synced - if move_entity_delta: packet_move_entity_delta - if set_scoreboard_identity: packet_set_scoreboard_identity - if set_local_player_as_initialized: packet_set_local_player_as_initialized - if update_soft_enum: packet_update_soft_enum - if network_stack_latency: packet_network_stack_latency - if script_custom_event: packet_script_custom_event - if spawn_particle_effect: packet_spawn_particle_effect - if available_entity_identifiers: packet_available_entity_identifiers - if level_sound_event_v2: packet_level_sound_event_v2 - if network_chunk_publisher_update: packet_network_chunk_publisher_update - if biome_definition_list: packet_biome_definition_list - if level_sound_event: packet_level_sound_event - if level_event_generic: packet_level_event_generic - if lectern_update: packet_lectern_update - if video_stream_connect: packet_video_stream_connect - if client_cache_status: packet_client_cache_status - if on_screen_texture_animation: packet_on_screen_texture_animation - if map_create_locked_copy: packet_map_create_locked_copy - if structure_template_data_export_request: packet_structure_template_data_export_request - if structure_template_data_export_response: packet_structure_template_data_export_response - if update_block_properties: packet_update_block_properties - if client_cache_blob_status: packet_client_cache_blob_status - if client_cache_miss_response: packet_client_cache_miss_response - if network_settings: packet_network_settings - if creative_content: packet_creative_content - if player_enchant_options: packet_player_enchant_options - if item_stack_request: packet_item_stack_request - if item_stack_response: packet_item_stack_response - if update_player_game_type: packet_update_player_game_type - if packet_violation_warning: packet_packet_violation_warning - if item_component: packet_item_component - if filter_text_packet: packet_filter_text_packet +!import: packet_map.yml packet_login: !id: 0x01 - !server: false - !client: true + !bound: client protocol_version: i32 payload_size: varint chain: LittleString @@ -307,32 +24,27 @@ packet_login: packet_play_status: !id: 0x02 - !server: true - !client: false + !bound: server status: i32 packet_server_to_client_handshake: !id: 0x03 - !server: true - !client: false + !bound: server token: string packet_client_to_server_handshake: !id: 0x04 - !server: false - !client: true + !bound: client packet_disconnect: !id: 0x05 - !server: true - !client: false + !bound: server hide_disconnect_reason: bool message: string packet_resource_packs_info: !id: 0x06 - !server: true - !client: false + !bound: server must_accept: bool has_scripts: bool behaviour_packs: BehaviourPackInfos @@ -340,8 +52,7 @@ packet_resource_packs_info: packet_resource_pack_stack: !id: 0x07 - !server: true - !client: false + !bound: server must_accept: bool behavior_packs: ResourcePackIdVersions resource_packs: ResourcePackIdVersions @@ -351,27 +62,23 @@ packet_resource_pack_stack: packet_resource_pack_client_response: !id: 0x08 - !server: false - !client: true + !bound: client response_status: u8 resourcepackids: ResourcePackIds packet_text: !id: 0x09 - !server: true - !client: true + !bound: both type: u8 packet_set_time: !id: 0x0a - !server: true - !client: false + !bound: server time: zigzag32 packet_start_game: !id: 0x0b - !server: true - !client: false + !bound: server entity_id: zigzag64 runtime_entity_id: varint player_gamemode: zigzag32 @@ -434,8 +141,7 @@ packet_start_game: packet_add_player: !id: 0x0c - !server: true - !client: false + !bound: server uuid: uuid username: string entity_id_self: zigzag64 @@ -464,8 +170,7 @@ packet_add_player: packet_add_entity: !id: 0x0d - !server: true - !client: false + !bound: server entity_id_self: zigzag64 runtime_entity_id: varint entity_type: string @@ -484,14 +189,12 @@ packet_add_entity: packet_remove_entity: !id: 0x0e - !server: true - !client: false + !bound: server entity_id_self: zigzag64 packet_add_item_entity: !id: 0x0f - !server: true - !client: false + !bound: server entity_id_self: zigzag64 runtime_entity_id: varint item: Item @@ -506,15 +209,13 @@ packet_add_item_entity: packet_take_item_entity: !id: 0x11 - !server: true - !client: false + !bound: server runtime_entity_id: varint target: varint packet_move_entity: !id: 0x12 - !server: true - !client: true + !bound: both runtime_entity_id: varint flags: u8 position: vec3f @@ -522,8 +223,7 @@ packet_move_entity: packet_move_player: !id: 0x13 - !server: true - !client: true + !bound: both runtime_entity_id: varint x: lf32 y: lf32 @@ -537,14 +237,12 @@ packet_move_player: packet_rider_jump: !id: 0x14 - !server: true - !client: true + !bound: both unknown: zigzag32 packet_update_block: !id: 0x15 - !server: true - !client: false + !bound: server coordinates: BlockCoordinates block_runtime_id: varint block_priority: varint @@ -552,8 +250,7 @@ packet_update_block: packet_add_painting: !id: 0x16 - !server: true - !client: false + !bound: server entity_id_self: zigzag64 runtime_entity_id: varint coordinates: BlockCoordinates @@ -562,15 +259,13 @@ packet_add_painting: packet_tick_sync: !id: 0x17 - !server: true - !client: true + !bound: both request_time: li64 response_time: li64 packet_level_sound_event_old: !id: 0x18 - !server: true - !client: true + !bound: both sound_id: u8 position: vec3f block_id: zigzag32 @@ -580,32 +275,28 @@ packet_level_sound_event_old: packet_level_event: !id: 0x19 - !server: true - !client: false + !bound: server event_id: zigzag32 position: vec3f data: zigzag32 packet_block_event: !id: 0x1a - !server: true - !client: false + !bound: server coordinates: BlockCoordinates case_1: zigzag32 case_2: zigzag32 packet_entity_event: !id: 0x1b - !server: true - !client: true + !bound: both runtime_entity_id: varint event_id: u8 data: zigzag32 packet_mob_effect: !id: 0x1c - !server: true - !client: false + !bound: server runtime_entity_id: varint event_id: u8 effect_id: zigzag32 @@ -615,22 +306,19 @@ packet_mob_effect: packet_update_attributes: !id: 0x1d - !server: true - !client: false + !bound: server runtime_entity_id: varint attributes: PlayerAttributes tick: varint packet_inventory_transaction: !id: 0x1e - !server: true - !client: true + !bound: both transaction: Transaction packet_mob_equipment: !id: 0x1f - !server: true - !client: true + !bound: both runtime_entity_id: varint item: Item slot: u8 @@ -639,8 +327,7 @@ packet_mob_equipment: packet_mob_armor_equipment: !id: 0x20 - !server: true - !client: true + !bound: both runtime_entity_id: varint helmet: Item chestplate: Item @@ -649,15 +336,13 @@ packet_mob_armor_equipment: packet_interact: !id: 0x21 - !server: true - !client: true + !bound: both action_id: u8 target_runtime_entity_id: varint packet_block_pick_request: !id: 0x22 - !server: false - !client: true + !bound: client x: zigzag32 y: zigzag32 z: zigzag32 @@ -666,15 +351,13 @@ packet_block_pick_request: packet_entity_pick_request: !id: 0x23 - !server: false - !client: true + !bound: client runtime_entity_id: lu64 selected_slot: u8 packet_player_action: !id: 0x24 - !server: false - !client: true + !bound: client runtime_entity_id: varint action_id: zigzag32 coordinates: BlockCoordinates @@ -682,29 +365,25 @@ packet_player_action: packet_hurt_armor: !id: 0x26 - !server: true - !client: false + !bound: server health: zigzag32 packet_set_entity_data: !id: 0x27 - !server: true - !client: true + !bound: both runtime_entity_id: varint metadata: MetadataDictionary tick: varint packet_set_entity_motion: !id: 0x28 - !server: true - !client: true + !bound: both runtime_entity_id: varint velocity: vec3f packet_set_entity_link: !id: 0x29 - !server: true - !client: false + !bound: server ridden_id: zigzag64 rider_id: zigzag64 link_type: u8 @@ -712,14 +391,12 @@ packet_set_entity_link: packet_set_health: !id: 0x2a - !server: true - !client: false + !bound: server health: zigzag32 packet_set_spawn_position: !id: 0x2b - !server: true - !client: false + !bound: server spawn_type: zigzag32 coordinates: BlockCoordinates dimension: zigzag32 @@ -727,15 +404,13 @@ packet_set_spawn_position: packet_animate: !id: 0x2c - !server: true - !client: true + !bound: both action_id: zigzag32 runtime_entity_id: varint packet_respawn: !id: 0x2d - !server: true - !client: true + !bound: both x: lf32 y: lf32 z: lf32 @@ -744,8 +419,7 @@ packet_respawn: packet_container_open: !id: 0x2e - !server: true - !client: false + !bound: server window_id: u8 type: u8 coordinates: BlockCoordinates @@ -753,30 +427,26 @@ packet_container_open: packet_container_close: !id: 0x2f - !server: true - !client: true + !bound: both window_id: u8 server: bool packet_player_hotbar: !id: 0x30 - !server: true - !client: true + !bound: both selected_slot: varint window_id: u8 select_slot_: bool packet_inventory_content: !id: 0x31 - !server: true - !client: true + !bound: both inventory_id: varint input: ItemStacks packet_inventory_slot: !id: 0x32 - !server: true - !client: true + !bound: both inventory_id: varint slot: varint uniqueid: zigzag32 @@ -784,16 +454,14 @@ packet_inventory_slot: packet_container_set_data: !id: 0x33 - !server: true - !client: false + !bound: server window_id: u8 property: zigzag32 value: zigzag32 packet_crafting_data: !id: 0x34 - !server: true - !client: false + !bound: server recipes: Recipes potion_type_recipes: PotionTypeRecipes potion_container_recipes: PotionContainerChangeRecipes @@ -801,8 +469,7 @@ packet_crafting_data: packet_crafting_event: !id: 0x35 - !server: true - !client: true + !bound: both window_id: u8 recipe_type: zigzag32 recipe_id: uuid @@ -811,13 +478,11 @@ packet_crafting_event: packet_gui_data_pick_item: !id: 0x36 - !server: true - !client: false + !bound: server packet_adventure_settings: !id: 0x37 - !server: true - !client: true + !bound: both flags: varint command_permission: varint action_permissions: varint @@ -827,15 +492,13 @@ packet_adventure_settings: packet_block_entity_data: !id: 0x38 - !server: true - !client: true + !bound: both coordinates: BlockCoordinates nbt: nbt packet_player_input: !id: 0x39 - !server: false - !client: true + !bound: client motion_x: lf32 motion_z: lf32 jumping: bool @@ -843,8 +506,7 @@ packet_player_input: packet_level_chunk: !id: 0x3a - !server: true - !client: false + !bound: server chunk_x: zigzag32 chunk_z: zigzag32 sub_chunk_count: varint @@ -852,115 +514,97 @@ packet_level_chunk: packet_set_commands_enabled: !id: 0x3b - !server: true - !client: false + !bound: server enabled: bool packet_set_difficulty: !id: 0x3c - !server: true - !client: false + !bound: server difficulty: varint packet_change_dimension: !id: 0x3d - !server: true - !client: false + !bound: server dimension: zigzag32 position: vec3f respawn: bool packet_set_player_game_type: !id: 0x3e - !server: true - !client: true + !bound: both gamemode: zigzag32 packet_player_list: !id: 0x3f - !server: true - !client: false + !bound: server records: PlayerRecords packet_simple_event: !id: 0x40 - !server: true - !client: false + !bound: server event_type: lu16 packet_spawn_experience_orb: !id: 0x42 - !server: true - !client: false + !bound: server position: vec3f count: zigzag32 packet_clientbound_map_item_data: !id: 0x43 - !server: true - !client: false + !bound: server mapinfo: MapInfo packet_map_info_request: !id: 0x44 - !server: true - !client: true + !bound: both map_id: zigzag64 packet_request_chunk_radius: !id: 0x45 - !server: true - !client: true + !bound: both chunk_radius: zigzag32 packet_chunk_radius_update: !id: 0x46 - !server: true - !client: false + !bound: server chunk_radius: zigzag32 packet_item_frame_drop_item: !id: 0x47 - !server: true - !client: true + !bound: both coordinates: BlockCoordinates packet_game_rules_changed: !id: 0x48 - !server: true - !client: false + !bound: server rules: GameRules packet_camera: !id: 0x49 - !server: true - !client: false + !bound: server unknown1: zigzag64 unknown2: zigzag64 packet_boss_event: !id: 0x4a - !server: true - !client: false + !bound: server boss_entity_id: zigzag64 event_type: varint packet_show_credits: !id: 0x4b - !server: true - !client: false + !bound: server runtime_entity_id: varint status: zigzag32 packet_available_commands: !id: 0x4c - !server: true - !client: false + !bound: server packet_command_request: !id: 0x4d - !server: false - !client: true + !bound: client command: string command_type: varint unknown_uuid: uuid @@ -969,19 +613,16 @@ packet_command_request: packet_command_block_update: !id: 0x4e - !server: false - !client: true + !bound: client is_block: bool packet_command_output: !id: 0x4f - !server: true - !client: false + !bound: server packet_update_trade: !id: 0x50 - !server: true - !client: false + !bound: server window_id: u8 window_type: u8 unknown0: varint @@ -995,8 +636,7 @@ packet_update_trade: packet_update_equipment: !id: 0x51 - !server: true - !client: false + !bound: server window_id: u8 window_type: u8 unknown: u8 @@ -1005,8 +645,7 @@ packet_update_equipment: packet_resource_pack_data_info: !id: 0x52 - !server: true - !client: false + !bound: server package_id: string max_chunk_size: lu32 chunk_count: lu32 @@ -1017,8 +656,7 @@ packet_resource_pack_data_info: packet_resource_pack_chunk_data: !id: 0x53 - !server: true - !client: false + !bound: server package_id: string chunk_index: lu32 progress: lu64 @@ -1026,22 +664,19 @@ packet_resource_pack_chunk_data: packet_resource_pack_chunk_request: !id: 0x54 - !server: false - !client: true + !bound: client package_id: string chunk_index: lu32 packet_transfer: !id: 0x55 - !server: true - !client: false + !bound: server server_address: string port: lu16 packet_play_sound: !id: 0x56 - !server: true - !client: false + !bound: server name: string coordinates: BlockCoordinates volume: lf32 @@ -1049,15 +684,13 @@ packet_play_sound: packet_stop_sound: !id: 0x57 - !server: true - !client: false + !bound: server name: string stop_all: bool packet_set_title: !id: 0x58 - !server: true - !client: false + !bound: server type: zigzag32 text: string fade_in_time: zigzag32 @@ -1066,31 +699,26 @@ packet_set_title: packet_add_behavior_tree: !id: 0x59 - !server: true - !client: false + !bound: server behaviortree: string packet_structure_block_update: !id: 0x5a - !server: true - !client: false + !bound: server packet_show_store_offer: !id: 0x5b - !server: true - !client: false + !bound: server unknown0: string unknown1: bool packet_purchase_receipt: !id: 0x5c - !server: false - !client: true + !bound: client packet_player_skin: !id: 0x5d - !server: true - !client: true + !bound: both uuid: uuid skin: Skin skin_name: string @@ -1099,30 +727,25 @@ packet_player_skin: packet_sub_client_login: !id: 0x5e - !server: true - !client: false + !bound: server packet_initiate_web_socket_connection: !id: 0x5f - !server: true - !client: false + !bound: server server: string packet_set_last_hurt_by: !id: 0x60 - !server: true - !client: false + !bound: server unknown: varint packet_book_edit: !id: 0x61 - !server: true - !client: false + !bound: server packet_npc_request: !id: 0x62 - !server: true - !client: true + !bound: both runtime_entity_id: varint unknown0: u8 unknown1: string @@ -1130,60 +753,51 @@ packet_npc_request: packet_photo_transfer: !id: 0x63 - !server: false - !client: true + !bound: client file_name: string image_data: string unknown2: string packet_modal_form_request: !id: 0x64 - !server: true - !client: false + !bound: server form_id: varint data: string packet_modal_form_response: !id: 0x65 - !server: false - !client: true + !bound: client form_id: varint data: string packet_server_settings_request: !id: 0x66 - !server: false - !client: true + !bound: client packet_server_settings_response: !id: 0x67 - !server: true - !client: false + !bound: server form_id: varint data: string packet_show_profile: !id: 0x68 - !server: true - !client: false + !bound: server xuid: string packet_set_default_game_type: !id: 0x69 - !server: true - !client: false + !bound: server gamemode: varint packet_remove_objective: !id: 0x6a - !server: true - !client: false + !bound: server objective_name: string packet_set_display_objective: !id: 0x6b - !server: true - !client: false + !bound: server display_slot: string objective_name: string display_name: string @@ -1192,14 +806,12 @@ packet_set_display_objective: packet_set_score: !id: 0x6c - !server: true - !client: false + !bound: server entries: ScoreEntries packet_lab_table: !id: 0x6d - !server: true - !client: true + !bound: both useless_byte: u8 lab_table_x: varint lab_table_y: varint @@ -1208,8 +820,7 @@ packet_lab_table: packet_update_block_synced: !id: 0x6e - !server: true - !client: false + !bound: server coordinates: BlockCoordinates block_runtime_id: varint block_priority: varint @@ -1219,46 +830,39 @@ packet_update_block_synced: packet_move_entity_delta: !id: 0x6f - !server: true - !client: false + !bound: server runtime_entity_id: varint flags: lu16 packet_set_scoreboard_identity: !id: 0x70 - !server: true - !client: false + !bound: server entries: ScoreboardIdentityEntries packet_set_local_player_as_initialized: !id: 0x71 - !server: false - !client: true + !bound: client runtime_entity_id: varint packet_update_soft_enum: !id: 0x72 - !server: true - !client: false + !bound: server packet_network_stack_latency: !id: 0x73 - !server: true - !client: true + !bound: both timestamp: lu64 unknown_flag: u8 packet_script_custom_event: !id: 0x75 - !server: true - !client: true + !bound: both event_name: string event_data: string packet_spawn_particle_effect: !id: 0x76 - !server: true - !client: false + !bound: server dimension_id: u8 entity_id: zigzag64 position: vec3f @@ -1266,14 +870,12 @@ packet_spawn_particle_effect: packet_available_entity_identifiers: !id: 0x77 - !server: true - !client: false + !bound: server nbt: nbt packet_level_sound_event_v2: !id: 0x78 - !server: true - !client: true + !bound: both sound_id: u8 position: vec3f block_id: zigzag32 @@ -1283,21 +885,18 @@ packet_level_sound_event_v2: packet_network_chunk_publisher_update: !id: 0x79 - !server: true - !client: false + !bound: server coordinates: BlockCoordinates radius: varint packet_biome_definition_list: !id: 0x7a - !server: true - !client: false + !bound: server nbt: nbt packet_level_sound_event: !id: 0x7b - !server: true - !client: true + !bound: both sound_id: varint position: vec3f block_id: zigzag32 @@ -1307,18 +906,15 @@ packet_level_sound_event: packet_level_event_generic: !id: 0x7c - !server: true - !client: false + !bound: server packet_lectern_update: !id: 0x7d - !server: true - !client: false + !bound: server packet_video_stream_connect: !id: 0x7e - !server: true - !client: false + !bound: server server_uri: string frame_send_frequency: lf32 action: u8 @@ -1327,86 +923,71 @@ packet_video_stream_connect: packet_client_cache_status: !id: 0x81 - !server: true - !client: true + !bound: both enabled: bool packet_on_screen_texture_animation: !id: 0x82 - !server: true - !client: false + !bound: server packet_map_create_locked_copy: !id: 0x83 - !server: true - !client: false + !bound: server packet_structure_template_data_export_request: !id: 0x84 - !server: true - !client: false + !bound: server packet_structure_template_data_export_response: !id: 0x85 - !server: true - !client: false + !bound: server packet_update_block_properties: !id: 0x86 - !server: true - !client: false + !bound: server nbt: nbt packet_client_cache_blob_status: !id: 0x87 - !server: true - !client: false + !bound: server packet_client_cache_miss_response: !id: 0x88 - !server: true - !client: false + !bound: server packet_network_settings: !id: 0x8f - !server: true - !client: true + !bound: both unknown: u8 compression_threshold: u8 packet_creative_content: !id: 0x91 - !server: true - !client: false + !bound: server items: ItemStacks packet_player_enchant_options: !id: 0x92 - !server: true - !client: false + !bound: server enchant_options: EnchantOptions packet_item_stack_request: !id: 0x93 - !server: false - !client: true + !bound: client requests: ItemStackRequests packet_item_stack_response: !id: 0x94 - !server: true - !client: false + !bound: server responses: ItemStackResponses packet_update_player_game_type: !id: 0x97 - !server: false - !client: true + !bound: client packet_packet_violation_warning: !id: 0x9c - !server: false - !client: true + !bound: client violation_type: zigzag32 severity: zigzag32 packet_id: zigzag32 @@ -1414,13 +995,11 @@ packet_packet_violation_warning: packet_item_component: !id: 0xa2 - !server: true - !client: false + !bound: server entries: ItemComponentList packet_filter_text_packet: !id: 0xa3 - !server: true - !client: false + !bound: server text: string from_server: bool From 1a7205b3d18fc8d6f7b1611d0942a63ff4622eb9 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 7 Feb 2021 19:45:46 -0500 Subject: [PATCH 083/106] update protocol, add some doc --- data/new/proto.yml | 240 ++++++++++++++++++++++++++++++++++++++++++-- data/new/types.yaml | 5 + data/newproto.json | 238 +++++++++++++++++++++++++++++++++++++++---- src/server.js | 19 +--- src/serverTest.js | 2 +- 5 files changed, 456 insertions(+), 48 deletions(-) diff --git a/data/new/proto.yml b/data/new/proto.yml index 737c70e..5bf4498 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -14,138 +14,356 @@ nbt: native !import: packet_map.yml +!StartDocs: Packets + +# # Login Sequence +# The login process is as follows: +# +# C→S: [Login](#packet_login) +# S→C: [Server To Client Handshake](#packet_server_to_client_handshake) +# C→S: [Client To Server Handshake](#packet_client_to_server_handshake) +# S→C: [Play Status (Login success)](#packet_play_status) +# To spawn, the following packets should be sent, in order, after the ones above: +# +# S→C: [Resource Packs Info](#packet_resource_packs_info) +# C→S: [Resource Pack Client Response](#packet_resource_pack_client_response) +# S→C: [Resource Pack Stack](#packet_resource_pack_stack) +# C→S: [Resource Pack Client Response](#packet_resource_pack_client_response) +# S→C: [Start Game](#packet_start_game) +# S→C: [Creative Content](#packet_creative_content) +# S→C: [Biome Definition List](#packet_biome_definition_list) +# S→C: [Chunks](#packet_level_chunk) +# S→C: [Play Status (Player spawn)](#packet_play_status) +# If there are no resource packs being sent, a Resource Pack Stack can be sent directly +# after Resource Packs Info to avoid the client responses. + + packet_login: !id: 0x01 !bound: client protocol_version: i32 + # The combined size of the `chain` and `client_data` payload_size: varint + # JSON array of JWT data: contains the display name, UUID and XUID + # It should be signed by the Mojang public key chain: LittleString + # Skin related data client_data: LittleString packet_play_status: !id: 0x02 !bound: server - status: i32 + status: i32 => + # Sent after Login has been successfully decoded and the player has logged in + 0: login_success + # Displays "Could not connect: Outdated client!" + 1: failed_client + # Displays "Could not connect: Outdated server!" + 2: failed_spawn + # Sent after world data to spawn the player + 3: player_spawn + # Displays "Unable to connect to world. Your school does not have access to this server." + 4: failed_invalid_tenant + # Displays "The server is not running Minecraft: Education Edition. Failed to connect." + 5: failed_vanilla_edu + # Displays "The server is running an incompatible edition of Minecraft. Failed to connect." + 6: failed_edu_vanilla + # Displays "Wow this server is popular! Check back later to see if space opens up. Server Full" + 7: failed_server_full + packet_server_to_client_handshake: !id: 0x03 !bound: server + # Contains the salt to complete the Diffie-Hellman key exchange token: string + +# Sent by the client in response to a Server To Client Handshake packet +# sent by the server. It is the first encrypted packet in the login handshake +# and serves as a confirmation that encryption is correctly initialized client side. +# It has no fields. packet_client_to_server_handshake: !id: 0x04 !bound: client +# Sent by the server to disconnect a client. packet_disconnect: !id: 0x05 !bound: server + # Specifies if the disconnection screen should be hidden when the client is disconnected, + # meaning it will be sent directly to the main menu. hide_disconnect_reason: bool + # An optional message to show when disconnected. message: string + packet_resource_packs_info: !id: 0x06 !bound: server + # If the resource pack requires the client accept it. must_accept: bool + # If scripting is enabled. has_scripts: bool + # A list of behaviour packs that the client needs to download before joining the server. + # All of these behaviour packs will be applied together. behaviour_packs: BehaviourPackInfos + # A list of resource packs that the client needs to download before joining the server. + # The order of these resource packs is not relevant in this packet. It is however important in the Resource Pack Stack packet. texture_packs: TexturePackInfos packet_resource_pack_stack: !id: 0x07 !bound: server + # If the resource pack must be accepted for the player to join the server. must_accept: bool + # [inline] behavior_packs: ResourcePackIdVersions + # [inline] resource_packs: ResourcePackIdVersions game_version: string - experiments: Experiments - experiments_previously_toggled: bool + experiments: Experiments # ??? such random fields + experiments_previously_used: bool packet_resource_pack_client_response: !id: 0x08 !bound: client - response_status: u8 + response_status: u8 => + 0: none + 1: refused + 2: send_packs + 3: have_all_packs + 4: completed + # All of the pack IDs. resourcepackids: ResourcePackIds +# Sent by the client to the server to send chat messages, and by the server to the client +# to forward or send messages, which may be chat, popups, tips etc. +## https://github.com/pmmp/PocketMine-MP/blob/a43b46a93cb127f037c879b5d8c29cda251dd60c/src/pocketmine/network/mcpe/protocol/TextPacket.php +## https://github.com/Sandertv/gophertunnel/blob/05ac3f843dd60d48b9ca0ab275cda8d9e85d8c43/minecraft/protocol/packet/text.go packet_text: !id: 0x09 !bound: both - type: u8 + type: u8 => + 0: raw + 1: chat + 2: translation + 3: popup + 4: jukebox_popup + 5: tip + 6: system + 7: whisper + 8: announcement + 9: json_whisper + 10: json + # NeedsTranslation specifies if any of the messages need to be translated. It seems that where % is found + # in translatable text types, these are translated regardless of this bool. Translatable text types + # include TextTypeTip, TextTypePopup and TextTypeJukeboxPopup. + needs_translation: bool + _: type? + if chat or whisper or announcement: + sourceName: string + if raw or tip or system or json_whisper or json: + message: string + if translation or popup or jukebox_popup: + message: string + paramaters: string[]varint + # The XUID of the player who sent this message. + xuid: string + # PlatformChatID is an identifier only set for particular platforms when chatting (presumably only for + # Nintendo Switch). It is otherwise an empty string, and is used to decide which players are able to + # chat with each other. + platform_chat_id: string +# For additional information and examples of all the chat types above, see here: https://imgur.com/a/KhcFscg + +# Sent by the server to update the current time client-side. The client actually advances time +# client-side by itself, so this packet does not need to be sent each tick. It is merely a means +# of synchronizing time between server and client. packet_set_time: !id: 0x0a !bound: server + # Time is the current time. The time is not limited to 24000 (time of day), but continues + # progressing after that. time: zigzag32 +# Sent by the server to send information about the world the player will be spawned in. packet_start_game: !id: 0x0b !bound: server + # The unique ID of the player. The unique ID is a value that remains consistent across + # different sessions of the same world, but most unofficial servers simply fill the + # runtime ID of the entity out for this field. entity_id: zigzag64 + # The runtime ID of the player. The runtime ID is unique for each world session, + # and entities are generally identified in packets using this runtime ID. runtime_entity_id: varint player_gamemode: zigzag32 + # The spawn position of the player in the world. In servers this is often the same as the + # world's spawn position found below. spawn: vec3f + # The pitch and yaw of the player rotation: vec3f + # The seed used to generate the world. Unlike in Java edition, the seed is a 32bit Integer here. seed: zigzag32 biome_type: li16 biome_name: string + # Dimension is the ID of the dimension that the player spawns in. It is a value from 0-2, + # with 0 being the overworld, 1 being the nether and 2 being the end. dimension: zigzag32 + # Generator is the generator used for the world. It is a value from 0-4, with 0 being old + # limited worlds, 1 being infinite worlds, 2 being flat worlds, 3 being nether worlds and + # 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you + # send beyond the world limit. generator: zigzag32 + # The game mode that a player gets when it first spawns in the world. It is shown in the + # settings and is used if the Player Gamemode is set to 5. gamemode: zigzag32 + # Difficulty is the difficulty of the world. It is a value from 0-3, with 0 being peaceful, + # 1 being easy, 2 being normal and 3 being hard. difficulty: zigzag32 - x: zigzag32 - y: varint - z: zigzag32 + # The block on which the world spawn of the world. This coordinate has no effect on the place + # that the client spawns, but it does have an effect on the direction that a compass poInts. + spawn_position: BlockCoordinates + # Defines if achievements are disabled in the world. The client crashes if this value is set + # to true while the player's or the world's game mode is creative, and it's recommended to simply + # always set this to false as a server. has_achievements_disabled: bool + # The time at which the day cycle was locked if the day cycle is disabled using the respective + # game rule. The client will maIntain this time as Boolean as the day cycle is disabled. day_cycle_stop_time: zigzag32 + # Some Minecraft: Education Edition field that specifies what 'region' the world was from, + # with 0 being None, 1 being RestOfWorld, and 2 being China. The actual use of this field is unknown. edu_offer: zigzag32 + # Specifies if the world has education edition features enabled, such as the blocks or entities + # specific to education edition. has_edu_features_enabled: bool edu_product_uuid_: string + # The level specifying the Intensity of the rain falling. When set to 0, no rain falls at all. rain_level: lf32 lightning_level: lf32 + # The level specifying the Intensity of the thunder. This may actually be set independently + # from the rain level, meaning dark clouds can be produced without rain. has_confirmed_platform_locked_content: bool + # Specifies if the world is a multi-player game. This should always be set to true for servers. is_multiplayer: bool + # Specifies if LAN broadcast was Intended to be enabled for the world. broadcast_to_lan: bool + # The mode used to broadcast the joined game across XBOX Live. xbox_live_broadcast_mode: varint + # The mode used to broadcast the joined game across the platform. platform_broadcast_mode: varint + # If commands are enabled for the player. It is recommended to always set this to true on the + # server, as setting it to false means the player cannot, under any circumstance, use a command. enable_commands: bool + # Specifies if the texture pack the world might hold is required, meaning the client was + # forced to download it before joining. is_texturepacks_required: bool + # Defines game rules currently active with their respective values. The value of these game + # rules may be either 'bool', 'Int32' or 'Float32'. Some game rules are server side only, + # and don't necessarily need to be sent to the client. gamerules: GameRules experiments: Experiments - experiments_previously_toggled: bool + experiments_previously_used: bool + # Specifies if the world had the bonus map setting enabled when generating it. + # It does not have any effect client-side. bonus_chest: bool + # Specifies if the world has the start with map setting enabled, meaning each + # joining player obtains a map. This should always be set to false, because the + # client obtains a map all on its own accord if this is set to true. map_enabled: bool + # The permission level of the player. It is a value from 0-3, with 0 being visitor, + # 1 being member, 2 being operator and 3 being custom. permission_level: zigzag32 + # The radius around the player in which chunks are ticked. Most servers set this value + # to a fixed number, as it does not necessarily affect anything client-side. server_chunk_tick_range: li32 + # Specifies if the texture pack of the world is locked, meaning it cannot be disabled + # from the world. This is typically set for worlds on the marketplace that have a dedicated + # texture pack. has_locked_behavior_pack: bool + # Specifies if the texture pack of the world is locked, meaning it cannot be disabled from the + # world. This is typically set for worlds on the marketplace that have a dedicated texture pack. has_locked_resource_pack: bool + # Specifies if the world from the server was from a locked world template. + # For servers this should always be set to false. is_from_locked_world_template: bool msa_gamertags_only: bool + # Specifies if the world from the server was from a locked world template. + # For servers this should always be set to false. is_from_world_template: bool + # Specifies if the world was a template that locks all settings that change properties + # above in the settings GUI. It is recommended to set this to true for servers that + # do not allow things such as setting game rules through the GUI. is_world_template_option_locked: bool + # A hack that Mojang put in place to preserve backwards compatibility with old villagers. + # The his never actually read though, so it has no functionality. only_spawn_v1_villagers: bool + # The version of the game from which Vanilla features will be used. + # The exact function of this field isn't clear. game_version: string limited_world_width_: li32 limited_world_length_: li32 is_new_nether_: bool experimental_gameplay_override: bool + # A base64 encoded world ID that is used to identify the world. level_id: string + # The name of the world that the player is joining. Note that this field shows up + # above the player list for the rest of the game session, and cannot be changed. + # Setting the server name to this field is recommended. world_name: string + # A UUID specific to the premium world template that might have been used to + # generate the world. Servers should always fill out an empty String for this. premium_world_template_id: string + # Specifies if the world was a trial world, meaning features are limited and there + # is a time limit on the world. is_trial: bool - movement_type: zigzag32 + # Specifies if the client or server is authoritative over the movement of the player, + # meaning it controls the movement of it. + ## https://github.com/pmmp/PocketMine-MP/blob/a43b46a93cb127f037c879b5d8c29cda251dd60c/src/pocketmine/network/mcpe/protocol/types/PlayerMovementType.php#L26 + movement_authority: zigzag32 => + 0: client + 1: server + # PlayerAuthInputPacket + a bunch of junk that solves a nonexisting problem + 2: server_v2_rewind + # The total time in ticks that has elapsed since the start of the world. current_tick: li64 + # The seed used to seed the random used to produce enchantments in the enchantment table. + # Note that the exact correct random implementation must be used to produce the correct + # results both client- and server-side. enchantment_seed: zigzag32 - block_palette: BlockPalette + + ## This is not sent anymore in protocol versions > 419 (Bedrock Edition v1.16.100) + ## A list of all blocks registered on the server. + ## block_palette: BlockPalette + # A list of all items with their legacy IDs which are available in the game. + # Failing to send any of the items that are in the game will crash mobile clients. itemstates: Itemstates + # A unique ID specifying the multi-player session of the player. + # A random UUID should be filled out for this field. multiplayer_correlation_id: string server_authoritative_inventory: bool packet_add_player: !id: 0x0c !bound: server + # UUID is the UUID of the player. It is the same UUID that the client sent in the + # Login packet at the start of the session. A player with this UUID must exist + # in the player list (built up using the Player List packet) for it to show up in-game. uuid: uuid + # Username is the name of the player. This username is the username that will be + # set as the initial name tag of the player. username: string + # The unique ID of the player. The unique ID is a value that remains consistent + # across different sessions of the same world, but most unoffical servers simply + # fill the runtime ID of the player out for this field. entity_id_self: zigzag64 + # The runtime ID of the player. The runtime ID is unique for each world session, + # and entities are generally identified in packets using this runtime ID. runtime_entity_id: varint + # An identifier only set for particular platforms when chatting (presumably only for + # Nintendo Switch). It is otherwise an empty string, and is used to decide which players + # are able to chat with each other. platform_chat_id: string x: lf32 y: lf32 diff --git a/data/new/types.yaml b/data/new/types.yaml index c84339c..6e32afe 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -1,3 +1,5 @@ +!StartDocs: Types + BehaviourPackInfos: []li16 uuid: string version: string @@ -18,8 +20,11 @@ TexturePackInfos: []li16 rtx_enabled: bool ResourcePackIdVersions: []varint + # The ID of the resource pack. uuid: string + # The version of the resource pack. version: string + # The subpack name of the resource pack. name: string ResourcePackIds: string[]varint diff --git a/data/newproto.json b/data/newproto.json index 13ffeaf..5424284 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -2361,7 +2361,22 @@ [ { "name": "status", - "type": "i32" + "type": [ + "mapper", + { + "type": "i32", + "mappings": { + "0": "login_success", + "1": "failed_client", + "2": "failed_spawn", + "3": "player_spawn", + "4": "failed_invalid_tenant", + "5": "failed_vanilla_edu", + "6": "failed_edu_vanilla", + "7": "failed_server_full" + } + } + ] } ] ], @@ -2436,7 +2451,7 @@ "type": "Experiments" }, { - "name": "experiments_previously_toggled", + "name": "experiments_previously_used", "type": "bool" } ] @@ -2446,7 +2461,19 @@ [ { "name": "response_status", - "type": "u8" + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "none", + "1": "refused", + "2": "send_packs", + "3": "have_all_packs", + "4": "completed" + } + } + ] }, { "name": "resourcepackids", @@ -2459,7 +2486,178 @@ [ { "name": "type", - "type": "u8" + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "raw", + "1": "chat", + "2": "translation", + "3": "popup", + "4": "jukebox_popup", + "5": "tip", + "6": "system", + "7": "whisper", + "8": "announcement", + "9": "json_whisper", + "10": "json" + } + } + ] + }, + { + "name": "needs_translation", + "type": "bool" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "chat": [ + "container", + [ + { + "name": "sourceName", + "type": "string" + } + ] + ], + "whisper": [ + "container", + [ + { + "name": "sourceName", + "type": "string" + } + ] + ], + "announcement": [ + "container", + [ + { + "name": "sourceName", + "type": "string" + } + ] + ], + "raw": [ + "container", + [ + { + "name": "message", + "type": "string" + } + ] + ], + "tip": [ + "container", + [ + { + "name": "message", + "type": "string" + } + ] + ], + "system": [ + "container", + [ + { + "name": "message", + "type": "string" + } + ] + ], + "json_whisper": [ + "container", + [ + { + "name": "message", + "type": "string" + } + ] + ], + "json": [ + "container", + [ + { + "name": "message", + "type": "string" + } + ] + ], + "translation": [ + "container", + [ + { + "name": "message", + "type": "string" + }, + { + "name": "paramaters", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + } + ] + ], + "popup": [ + "container", + [ + { + "name": "message", + "type": "string" + }, + { + "name": "paramaters", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + } + ] + ], + "jukebox_popup": [ + "container", + [ + { + "name": "message", + "type": "string" + }, + { + "name": "paramaters", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + } + ] + ] + }, + "default": "void" + } + ] + }, + { + "name": "xuid", + "type": "string" + }, + { + "name": "platform_chat_id", + "type": "string" } ] ], @@ -2524,16 +2722,8 @@ "type": "zigzag32" }, { - "name": "x", - "type": "zigzag32" - }, - { - "name": "y", - "type": "varint" - }, - { - "name": "z", - "type": "zigzag32" + "name": "spawn_position", + "type": "BlockCoordinates" }, { "name": "has_achievements_disabled", @@ -2600,7 +2790,7 @@ "type": "Experiments" }, { - "name": "experiments_previously_toggled", + "name": "experiments_previously_used", "type": "bool" }, { @@ -2684,8 +2874,18 @@ "type": "bool" }, { - "name": "movement_type", - "type": "zigzag32" + "name": "movement_authority", + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "client", + "1": "server", + "2": "server_v2_rewind" + } + } + ] }, { "name": "current_tick", @@ -2695,10 +2895,6 @@ "name": "enchantment_seed", "type": "zigzag32" }, - { - "name": "block_palette", - "type": "BlockPalette" - }, { "name": "itemstates", "type": "Itemstates" diff --git a/src/server.js b/src/server.js index af25535..13fa23b 100644 --- a/src/server.js +++ b/src/server.js @@ -25,17 +25,6 @@ function createDeserializer() { return new Parser(proto, 'mcpe_packet'); } -const PLAY_STATUS = { - 'LoginSuccess': 0, - 'LoginFailedClient': 1, - 'LoginFailedServer': 2, - 'PlayerSpawn': 3, - 'LoginFailedInvalidTenant': 4, - 'LoginFailedVanillaEdu': 5, - 'LoginFailedEduVanilla': 6, - 'LoginFailedServerFull': 7 -} - class Player extends Connection { constructor(server, connection, options) { super() @@ -55,11 +44,11 @@ class Player extends Connection { const clientVer = body.protocol_version if (this.server.options.version) { if (this.server.options.version < clientVer) { - this.sendDisconnectStatus(PLAY_STATUS.LoginFailedClient) + this.sendDisconnectStatus(failed_client) return } } else if (clientVer < MIN_VERSION) { - this.sendDisconnectStatus(PLAY_STATUS.LoginFailedClient) + this.sendDisconnectStatus(failed_client) return } @@ -91,7 +80,7 @@ class Player extends Connection { // Client to Server handshake response. This indicates successful encryption onHandshake() { // https://wiki.vg/Bedrock_Protocol#Play_Status - this.write('play_status', { status: PLAY_STATUS.LoginSuccess }) + this.write('play_status', { status: 'login_success' }) this.emit('join') } @@ -181,4 +170,4 @@ class Server extends EventEmitter { } } -module.exports = { Server, Player, PLAY_STATUS } \ No newline at end of file +module.exports = { Server, Player } \ No newline at end of file diff --git a/src/serverTest.js b/src/serverTest.js index aa356fc..7dccb65 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -33,7 +33,7 @@ server.on('connect', ({ client }) => { 'resource_packs': [], 'game_version': '', 'experiments': [], - 'experiments_previously_toggled': false + 'experiments_previously_used': false }) client.once('resource_pack_client_response', async (packet) => { From 60e57fad44f199720e1b8e154cc674963c6c76d6 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 10 Feb 2021 01:32:54 -0500 Subject: [PATCH 084/106] protocol updates, use ProtoDef compiler --- data/new/compile.js | 23 +++++- data/new/types.yaml | 33 ++++---- data/newproto.json | 78 ++++++++---------- package.json | 2 +- src/datatypes/compiler-minecraft.js | 39 +++++++++ src/options.js | 12 +++ src/server.js | 47 +++-------- src/serverTest.js | 14 ++-- src/transforms/serializer.js | 52 ++++++++---- test/serialization.js | 119 ++++++++++++++++++++++++++++ 10 files changed, 298 insertions(+), 121 deletions(-) create mode 100644 src/datatypes/compiler-minecraft.js create mode 100644 src/options.js create mode 100644 test/serialization.js diff --git a/data/new/compile.js b/data/new/compile.js index 2800ba8..6df30d9 100644 --- a/data/new/compile.js +++ b/data/new/compile.js @@ -1,4 +1,5 @@ const fs = require('fs') +const { ProtoDefCompiler } = require('protodef').Compiler let compile try { @@ -11,5 +12,23 @@ if (compile) { compile('./proto.yml', 'protocol.json') } -fs.writeFileSync( '../newproto.json', JSON.stringify({ types: require('./protocol.json') }, null, 2) ) -fs.unlinkSync('./protocol.json') //remove temp file \ No newline at end of file +fs.writeFileSync('../newproto.json', JSON.stringify({ types: require('./protocol.json') }, null, 2)) +fs.unlinkSync('./protocol.json') //remove temp file + +function createProtocol() { + const compiler = new ProtoDefCompiler() + const protocol = require('../newproto.json').types + compiler.addTypesToCompile(protocol) + compiler.addTypes(require('../../src/datatypes/compiler-minecraft')) + compiler.addTypes(require('prismarine-nbt/compiler-zigzag')) + + fs.writeFileSync('../read.js', 'module.exports = ' + compiler.readCompiler.generate()) + fs.writeFileSync('../write.js', 'module.exports = ' + compiler.writeCompiler.generate()) + fs.writeFileSync('../size.js', 'module.exports = ' + compiler.sizeOfCompiler.generate()) + + const compiledProto = compiler.compileProtoDefSync() + return compiledProto +} + +console.log('Generating JS...') +createProtocol() \ No newline at end of file diff --git a/data/new/types.yaml b/data/new/types.yaml index 6e32afe..2168098 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -1,9 +1,9 @@ -!StartDocs: Types +# !StartDocs: Types BehaviourPackInfos: []li16 uuid: string version: string - size: lu64 + length: lu64 content_key: string sub_pack_name: string content_identity: string @@ -12,7 +12,7 @@ BehaviourPackInfos: []li16 TexturePackInfos: []li16 uuid: string version: string - size: lu64 + length: lu64 content_key: string sub_pack_name: string content_identity: string @@ -71,11 +71,11 @@ Item: default: auxiliary_value: zigzag32 has_nbt: lu16 => - 0xffff: '1' - 0x0000: '0' - _: has_nbt? - if 1: - nbt_version: u8 + 0xffff: 'true' + 0x0000: 'false' + nbt: has_nbt? + if true: + version: u8 nbt: nbt default: void can_place_on: string[]zigzag32 @@ -150,10 +150,10 @@ BlockCoordinates: # mojang... z: zigzag32 PlayerAttributes: []varint - min: lf32 - max: lf32 - current: lf32 - default: lf32 + min_value: lf32 + max_value: lf32 + current_value: lf32 + default_value: lf32 name: string Transaction: @@ -360,11 +360,10 @@ ScoreEntries: 1: player 2: entity 3: fake_player - _: entry_type? - if player or entity: - entity_unique_id: zigzag64 - if fake_player: - custom_name: string + entity_unique_id: entry_type? + if player or entity: zigzag64 + custom_name: entry_type? + if fake_player: string ScoreboardIdentityEntries: type: i8 => diff --git a/data/newproto.json b/data/newproto.json index 5424284..e520a62 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -25,7 +25,7 @@ "type": "string" }, { - "name": "size", + "name": "length", "type": "lu64" }, { @@ -64,7 +64,7 @@ "type": "string" }, { - "name": "size", + "name": "length", "type": "lu64" }, { @@ -281,24 +281,24 @@ { "type": "lu16", "mappings": { - "0": "0", - "65535": "1" + "0": "false", + "65535": "true" } } ] }, { - "anon": true, + "name": "nbt", "type": [ "switch", { "compareTo": "has_nbt", "fields": { - "1": [ + "true": [ "container", [ { - "name": "nbt_version", + "name": "version", "type": "u8" }, { @@ -431,6 +431,10 @@ "type": [ "container", [ + { + "name": "key", + "type": "varint" + }, { "name": "type", "type": [ @@ -576,19 +580,19 @@ "container", [ { - "name": "min", + "name": "min_value", "type": "lf32" }, { - "name": "max", + "name": "max_value", "type": "lf32" }, { - "name": "current", + "name": "current_value", "type": "lf32" }, { - "name": "default", + "name": "default_value", "type": "lf32" }, { @@ -771,7 +775,7 @@ "type": [ "switch", { - "compareTo": "../has_network_ids", + "compareTo": "has_network_ids", "fields": { "true": "zigzag32" }, @@ -1386,7 +1390,7 @@ "type": [ "switch", { - "compareTo": "../type", + "compareTo": "type", "fields": { "add": [ "container", @@ -1512,7 +1516,7 @@ "type": [ "switch", { - "compareTo": "../type", + "compareTo": "type", "fields": { "remove": [ "container", @@ -1532,39 +1536,27 @@ ] }, { - "anon": true, + "name": "entity_unique_id", "type": [ "switch", { "compareTo": "entry_type", "fields": { - "player": [ - "container", - [ - { - "name": "entity_unique_id", - "type": "zigzag64" - } - ] - ], - "entity": [ - "container", - [ - { - "name": "entity_unique_id", - "type": "zigzag64" - } - ] - ], - "fake_player": [ - "container", - [ - { - "name": "custom_name", - "type": "string" - } - ] - ] + "player": "zigzag64", + "entity": "zigzag64" + }, + "default": "void" + } + ] + }, + { + "name": "custom_name", + "type": [ + "switch", + { + "compareTo": "entry_type", + "fields": { + "fake_player": "string" }, "default": "void" } @@ -1618,7 +1610,7 @@ "type": [ "switch", { - "compareTo": "../type", + "compareTo": "type", "fields": { "TYPE_REGISTER_IDENTITY": "zigzag64" }, diff --git a/package.json b/package.json index 6c7aa73..30346b0 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "jwt-simple": "^0.5.6", "lodash.merge": "^4.4.0", "prismarine-nbt": "github:extremeheat/prismarine-nbt#le", - "protodef": "github:extremeheat/node-protodef#big", + "protodef": "github:extremeheat/node-protodef#compiler", "raknet": "git+https://github.com/mhsjlw/node-raknet.git#master", "uuid-1345": "^0.99.7" }, diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js new file mode 100644 index 0000000..f8fa767 --- /dev/null +++ b/src/datatypes/compiler-minecraft.js @@ -0,0 +1,39 @@ +const UUID = require('uuid-1345') +const minecraft = require('./minecraft') + +module.exports = { + Read: { + UUID: ['native', (buffer, offset) => { + return { + value: UUID.stringify(buffer.slice(offset, 16 + offset)), + size: 16 + } + }], + restBuffer: ['native', (buffer, offset) => { + return { + value: buffer.slice(offset), + size: buffer.length - offset + } + }], + nbt: ['native', minecraft.nbt[0]] + }, + Write: { + UUID: ['native', (value, buffer, offset) => { + const buf = UUID.parse(value) + buf.copy(buffer, offset) + return offset + 16 + }], + restBuffer: ['native', (value, buffer, offset) => { + value.copy(buffer, offset) + return offset + value.length + }], + nbt: ['native', minecraft.nbt[1]] + }, + SizeOf: { + UUID: ['native', 16], + restBuffer: ['native', (value) => { + return value.length + }], + nbt: ['native', minecraft.nbt[2]] + } +} diff --git a/src/options.js b/src/options.js new file mode 100644 index 0000000..dc329ea --- /dev/null +++ b/src/options.js @@ -0,0 +1,12 @@ +// Minimum supported version (< will be kicked) +const MIN_VERSION = 422 +// Currently supported verson +const CURRENT_VERSION = 422 + + +const defaultOptions = { + // https://minecraft.gamepedia.com/Protocol_version#Bedrock_Edition_2 + version: CURRENT_VERSION +} + +module.exports = { defaultOptions, MIN_VERSION, CURRENT_VERSION } \ No newline at end of file diff --git a/src/server.js b/src/server.js index 13fa23b..8223f4f 100644 --- a/src/server.js +++ b/src/server.js @@ -1,29 +1,12 @@ const Listener = require('@jsprismarine/raknet/listener') -const { ProtoDef, Parser, Serializer } = require('protodef') const { EventEmitter } = require('events') +const { createDeserializer, createSerializer } = require('./transforms/serializer') const { Encrypt } = require('./auth/encryption') const { decodeLoginJWT } = require('./auth/chains') const { Connection } = require('./connection') +const Options = require('./options') -var protocol = require('../data/newproto.json').types; - -function createProtocol() { - var proto = new ProtoDef(); - proto.addTypes(require('./datatypes/minecraft')); - proto.addTypes(protocol); - - return proto; -} - -function createSerializer() { - var proto = createProtocol() - return new Serializer(proto, 'mcpe_packet'); -} - -function createDeserializer() { - var proto = createProtocol() - return new Parser(proto, 'mcpe_packet'); -} +const log = (...args) => console.log(...args) class Player extends Connection { constructor(server, connection, options) { @@ -102,20 +85,10 @@ class Player extends Connection { } } -// Minimum supported version (< will be kicked) -const MIN_VERSION = 422 -// Currently supported verson -const CURRENT_VERSION = 422 - -const defaultServerOptions = { - // https://minecraft.gamepedia.com/Protocol_version#Bedrock_Edition_2 - version: CURRENT_VERSION, -} - class Server extends EventEmitter { constructor(options) { super() - this.options = { ...defaultServerOptions, options } + this.options = { ...Options.defaultOptions, options } this.serializer = createSerializer() this.deserializer = createDeserializer() this.clients = {} @@ -123,8 +96,8 @@ class Server extends EventEmitter { } validateOptions() { - if (this.options.version < defaultServerOptions.version) { - throw new Error(`Unsupported protocol version < ${defaultServerOptions.version}: ${this.options.version}`) + if (this.options.version < Options.MIN_VERSION) { + throw new Error(`Unsupported protocol version < ${Options.MIN_VERSION} : ${this.options.version}`) } } @@ -133,7 +106,7 @@ class Server extends EventEmitter { } onOpenConnection = (conn) => { - console.log('Got connection', conn) + log('new connection', conn) const player = new Player(this, conn) this.clients[this.getAddrHash(conn.address)] = player @@ -141,12 +114,12 @@ class Server extends EventEmitter { } onCloseConnection = (inetAddr, reason) => { - console.log('Close connection', inetAddr, reason) + log('close connection', inetAddr, reason) delete this.clients[this.getAddrHash(inetAddr)] } onEncapsulated = (encapsulated, inetAddr) => { - console.log('Encapsulated', encapsulated, inetAddr) + log(inetAddr.address, ': Encapsulated', encapsulated) const buffer = encapsulated.buffer const client = this.clients[this.getAddrHash(inetAddr)] if (!client) { @@ -158,7 +131,7 @@ class Server extends EventEmitter { async create(serverIp, port) { this.listener = new Listener(this) this.raknet = await this.listener.listen(serverIp, port) - console.log('Listening on', serverIp, port) + log('Listening on', serverIp, port) this.raknet.on('openConnection', this.onOpenConnection) this.raknet.on('closeConnection', this.onCloseConnection) diff --git a/src/serverTest.js b/src/serverTest.js index 7dccb65..a02ac35 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -42,21 +42,23 @@ server.on('connect', ({ client }) => { let ids = 0 for (var item of CreativeItems) { let creativeitem = { runtime_id: items.length } + const has_nbt = !!item.nbt_b64 if (item.id != 0) { - const hasNbt = !!item.nbt_b64 creativeitem.item = { network_id: item.id, auxiliary_value: item.damage || 0, - has_nbt: hasNbt|0, - nbt_version: 1, + has_nbt, + nbt: { + version: 1, + }, blocking_tick: 0, can_destroy: [], can_place_on: [] } - if (hasNbt) { + if (has_nbt) { let nbtBuf = Buffer.from(item.nbt_b64, 'base64') - let { result } = await NBT.parse(nbtBuf, 'little') - creativeitem.item.nbt = result + let { parsed } = await NBT.parse(nbtBuf, 'little') + creativeitem.item.nbt.nbt = parsed } } items.push(creativeitem) diff --git a/src/transforms/serializer.js b/src/transforms/serializer.js index 010e850..e07b63c 100644 --- a/src/transforms/serializer.js +++ b/src/transforms/serializer.js @@ -1,30 +1,52 @@ -'use strict'; -var ProtoDef = require('protodef').ProtoDef; -var Serializer = require('protodef').Serializer; -var Parser = require('protodef').Parser; - -var protocol = require('../../data/protocol.json').types; +const { ProtoDefCompiler, CompiledProtodef } = require('protodef').Compiler +const { FullPacketParser, Serializer } = require('protodef') function createProtocol() { - var proto = new ProtoDef(); - proto.addTypes(require('../datatypes/minecraft')); - proto.addTypes(protocol); + const protocol = require('../../data/newproto.json').types + console.log('Proto', protocol) + var compiler = new ProtoDefCompiler() + compiler.addTypesToCompile(protocol) + compiler.addTypes(require('../datatypes/compiler-minecraft')) + compiler.addTypes(require('prismarine-nbt/compiler-zigzag')) - return proto; + const compiledProto = compiler.compileProtoDefSync() + return compiledProto +} + + +function getProtocol() { + const compiler = new ProtoDefCompiler() + compiler.addTypes(require('../datatypes/compiler-minecraft')) + compiler.addTypes(require('prismarine-nbt/compiler-zigzag')) + + const compile = (compiler, file) => { + global.native = compiler.native // eslint-disable-line + const { PartialReadError } = require('protodef/src/utils') // eslint-disable-line + return require(file)() // eslint-disable-line + } + + return new CompiledProtodef( + compile(compiler.sizeOfCompiler, '../../data/size.js'), + compile(compiler.writeCompiler, '../../data/write.js'), + compile(compiler.readCompiler, '../../data/read.js') + // compiler.sizeOfCompiler.compile(fs.readFileSync(__dirname + '/../../data/size.js', 'utf-8')), + // compiler.writeCompiler.compile(fs.readFileSync(__dirname + '/../../data/write.js', 'utf-8')), + // compiler.readCompiler.compile(fs.readFileSync(__dirname + '/../../data/read.js', 'utf-8')) + ) } function createSerializer() { - var proto = createProtocol(); - return new Serializer(proto, 'packet'); + var proto = getProtocol() + return new Serializer(proto, 'mcpe_packet'); } function createDeserializer() { - var proto = createProtocol(); - return new Parser(proto, 'packet'); + var proto = getProtocol() + return new FullPacketParser(proto, 'mcpe_packet'); } module.exports = { createDeserializer: createDeserializer, createSerializer: createSerializer, createProtocol: createProtocol -}; +} \ No newline at end of file diff --git a/test/serialization.js b/test/serialization.js new file mode 100644 index 0000000..c7588ca --- /dev/null +++ b/test/serialization.js @@ -0,0 +1,119 @@ +const { createDeserializer, createSerializer } = require('../src/transforms/serializer') + +function test() { + const serializer = createSerializer() + const deserializer = createDeserializer() + + function write(name, params) { + const packet = serializer.createPacketBuffer({ name, params }) + console.log('Encoded', packet) + return packet + } + + function read(packet) { + const des = deserializer.parsePacketBuffer(packet) + return des + } + + async function creativeTest() { + let CreativeItems = require('../../data/creativeitems.json') + + let items = [] + let ids = 0 + for (var item of CreativeItems) { + let creativeitem = { runtime_id: items.length } + if (item.id != 0) { + const hasNbt = !!item.nbt_b64 + creativeitem.item = { + network_id: item.id, + auxiliary_value: item.damage || 0, + has_nbt: hasNbt, + nbt: { version: 1 }, + blocking_tick: 0, + can_destroy: [], + can_place_on: [] + } + if (hasNbt) { + let nbtBuf = Buffer.from(item.nbt_b64, 'base64') + let { result } = await NBT.parse(nbtBuf, 'little') + + const buf = NBT.writeUncompressed(result, 'littleVarint') + + console.log(nbtBuf, buf, JSON.stringify(result)) + + console.log('\n') + + let res2 = await NBT.parse(buf, 'littleVarint') + console.log(JSON.stringify(result), JSON.stringify(res2.result)) + console.assert(JSON.stringify(result) == JSON.stringify(res2.result), JSON.stringify(result), JSON.stringify(res2.result)) + + console.log('\n') + + creativeitem.item.nbt.nbt = result + } + } + + items.push(creativeitem) + console.log(JSON.stringify(creativeitem)) + // console.log(JSON.stringify(creativeitem)) + + var s = write('creative_content', { items: [creativeitem] }) + var d = read(s).data.params + + // console.log(JSON.stringify(d), JSON.stringify(s)) + // if (JSON.stringify(d) != JSON.stringify(creative_content)) throw 'mismatch' + } + } + + async function creativeTst() { + var creativeitem = { + "runtime_id": 1166, + "item": { + "network_id": 403, + "auxiliary_value": 0, + "has_nbt": true, + "nbt": { + "version": 1, + "nbt": { + "type": "compound", + "name": "", + "value": { + "ench": { + "type": "list", + "value": { + "type": "compound", + "value": [ + { + "id": { + "type": "short", + "value": 0 + }, + "lvl": { + "type": "short", + "value": 1 + } + } + ] + } + } + } + } + }, + "blocking_tick": 0, + "can_destroy": [], + "can_place_on": [] + } + } + + var s = write('creative_content', { items: [creativeitem] }) + var d = read(s).data.params + console.log(JSON.stringify(d)) + } + + + creativeTst() +} + +if (!module.parent) { + test() +} \ No newline at end of file From 49cff40097c8cccdac46570c0088a7ec626b827b Mon Sep 17 00:00:00 2001 From: extremeheat Date: Wed, 10 Feb 2021 05:04:10 -0500 Subject: [PATCH 085/106] cliet auth --- .gitignore | 3 +- package.json | 6 +- src/client.js | 112 ++++++++++++++ src/client/auth.js | 104 +++++++++++++ src/client/authConstants.js | 4 + src/client/authFlow.js | 131 ++++++++++++++++ src/client/tokens.js | 299 ++++++++++++++++++++++++++++++++++++ src/clientTest.js | 11 ++ src/connection.js | 3 +- src/server.js | 1 + 10 files changed, 670 insertions(+), 4 deletions(-) create mode 100644 src/client.js create mode 100644 src/client/auth.js create mode 100644 src/client/authConstants.js create mode 100644 src/client/authFlow.js create mode 100644 src/client/tokens.js create mode 100644 src/clientTest.js diff --git a/.gitignore b/.gitignore index 20c7123..570a59b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ npm-debug.log -__* \ No newline at end of file +__* +data/*.js \ No newline at end of file diff --git a/package.json b/package.json index 30346b0..f0cd2f0 100644 --- a/package.json +++ b/package.json @@ -14,19 +14,23 @@ ], "license": "MIT", "dependencies": { + "@azure/msal-node": "^1.0.0-beta.6", "@babel/core": "^7.5.4", "@babel/preset-env": "^7.5.4", "@babel/preset-typescript": "^7.3.3", "@babel/register": "^7.4.4", "@jsprismarine/jsbinaryutils": "^2.1.8", - "@jsprismarine/raknet": "github:extremeheat/raknet", + "@jsprismarine/raknet": "github:extremeheat/raknet#client", + "@xboxreplay/xboxlive-auth": "^3.3.3", "aes-js": "^3.1.2", "asn1": "^0.2.4", "bn.js": "^4.11.4", + "debug": "^4.3.1", "ec-pem": "^0.18.0", "jsonwebtoken": "^8.5.1", "jwt-simple": "^0.5.6", "lodash.merge": "^4.4.0", + "minecraft-folder-path": "^1.1.0", "prismarine-nbt": "github:extremeheat/prismarine-nbt#le", "protodef": "github:extremeheat/node-protodef#compiler", "raknet": "git+https://github.com/mhsjlw/node-raknet.git#master", diff --git a/src/client.js b/src/client.js new file mode 100644 index 0000000..8e20275 --- /dev/null +++ b/src/client.js @@ -0,0 +1,112 @@ +const RakClient = require('@jsprismarine/raknet/client') +const { Connection } = require('./connection') +const { createDeserializer, createSerializer } = require('./transforms/serializer') +const { Encrypt } = require('./auth/encryption') +const auth = require('./client/auth') +const Options = require('./options') + +class Client extends Connection { + constructor(options) { + super() + this.options = { ...Options.defaultOptions, options } + this.serializer = createSerializer() + this.deserializer = createDeserializer() + this.validateOptions() + + Encrypt(this, null, options) + + if (options.password) { + auth.authenticatePassword(this, options) + } else { + auth.authenticateDeviceCode(this, options) + } + + this.on('session', this.connect) + } + + validateOptions() { + if (this.options.version < Options.MIN_VERSION) { + throw new Error(`Unsupported protocol version < ${Options.MIN_VERSION} : ${this.options.version}`) + } + } + + onEncapsulated = (encapsulated, inetAddr) => { + log(inetAddr.address, ': Encapsulated', encapsulated) + const buffer = encapsulated.buffer + this.handle(buffer) + } + + connect = async (sessionData) => { + console.log('Got session data', sessionData) + + if (this.raknet) return + + this.raknet = new RakClient('localhost', 19132) + await this.raknet.connect() + + this.raknet.on('connecting', () => { + // console.log(`[client] connecting to ${hostname}/${port}`) + }) + this.raknet.on('connected', (connection) => { + console.log(`[client] connected!`) + this.connection = connection + this.sendLogin() + }) + + this.raknet.on('encapsulated', this.onEncapsulated) + + this.raknet.on('raw', (buffer, inetAddr) => { + console.log('Raw packet', buffer, inetAddr) + }) + } + + sendLogin() { + + const chain = [ + this.clientChain, // JWT we generated for auth + ...this.accessToken // Mojang + Xbox JWT from auth + ] + + const encodedChain = JSON.stringify({ chain }) + const skinChain = JSON.stringify({}) + + const bodyLength = skinChain.length + encodedChain.length + 8 + + console.log('Auth chain', chain) + + this.write('login', { + protocol_version: this.options.version, + payload_size: bodyLength, + chain: encodedChain, + client_data: skinChain + }) + } + + // After sending Server to Client Handshake, this handles the client's + // Client to Server handshake response. This indicates successful encryption + onHandshake() { + // https://wiki.vg/Bedrock_Protocol#Play_Status + this.write('play_status', { status: PLAY_STATUS.LoginSuccess }) + this.emit('join') + } + + readPacket(packet) { + console.log('packet', packet) + const des = this.server.deserializer.parsePacketBuffer(packet) + console.log('->', des) + switch (des.data.name) { + case 'login': + console.log(des) + this.onLogin(des) + return + case 'client_to_server_handshake': + this.onHandshake() + default: + console.log('ignoring, unhandled') + } + this.emit(des.data.name, des.data.params) + + } +} + +module.exports = { Client } \ No newline at end of file diff --git a/src/client/auth.js b/src/client/auth.js new file mode 100644 index 0000000..696cf30 --- /dev/null +++ b/src/client/auth.js @@ -0,0 +1,104 @@ +const XboxLiveAuth = require('@xboxreplay/xboxlive-auth') +const debug = require('debug')('minecraft-protocol') +const fetch = require('node-fetch') +const authConstants = require('./authConstants') +const { MsAuthFlow } = require('./authFlow.js') + +const getFetchOptions = { + headers: { + 'Content-Type': 'application/json', + 'User-Agent': 'node-minecraft-protocol' + } +} + +/** + * Obtains Minecaft profile data using a Minecraft access token and starts the join sequence + * @param {object} client - The client passed to protocol + * @param {object} options - Client Options + * @param {string} chains - Minecraft JWTs to send to server + */ +async function postAuthenticate (client, options, chains) { + // First chain is Mojang stuff, second is Xbox profile data used by mc + const jwt = chains[1] + const [header, payload, signature] = jwt.split('.').map(k => Buffer.from(k, 'base64')) + const xboxProfile = JSON.parse(String(payload)) + + // This profile / session here could be simplified down to where it just passes the uuid of the player to encrypt.js + // That way you could remove some lines of code. It accesses client.session.selectedProfile.id so /shrug. + // - Kashalls + const profile = { + name: xboxProfile?.extraData?.displayName || 'Player', + uuid: xboxProfile?.extraData?.identity || 'adfcf5ca-206c-404a-aec4-f59fff264c9b', //random + xuid: xboxProfile?.extraData?.XUID || 0 + } + + client.profile = profile + client.username = profile.name + client.accessToken = chains + client.emit('session', profile) + client.connect() +} + +/** + * Authenticates with Mincrosoft through user credentials, then + * with Xbox Live, Minecraft, checks entitlements and returns profile + * + * @function + * @param {object} client - The client passed to protocol + * @param {object} options - Client Options + */ +async function authenticatePassword (client, options) { + throw Error('Not implemented') +} + +/** + * Authenticates to Minecraft via device code based Microsoft auth, + * then connects to the specified server in Client Options + * + * @function + * @param {object} client - The client passed to protocol + * @param {object} options - Client Options + */ +async function authenticateDeviceCode (client, options) { + try { + const flow = new MsAuthFlow(options.username, options.profilesFolder, options.onMsaCode) + + const chain = await flow.getMinecraftToken(client.clientChain) + + await postAuthenticate(client, options, chain) + } catch (err) { + console.error(err) + client.emit('error', err) + } +} + +function checkStatus (res) { + if (res.ok) { // res.status >= 200 && res.status < 300 + return res.json() + } else { + throw Error(res.statusText) + } +} + +module.exports = { + authenticatePassword, + authenticateDeviceCode +} + +async function msaTest () { + // MsAuthFlow.resetTokenCaches() + + await authenticateDeviceCode({ + connect(...args) { + console.log('Connecting', args) + }, + emit(...e) { + console.log('Event', e) + } + }, {}) +} + +// debug with node microsoftAuth.js +if (!module.parent) { + msaTest() +} diff --git a/src/client/authConstants.js b/src/client/authConstants.js new file mode 100644 index 0000000..26e052d --- /dev/null +++ b/src/client/authConstants.js @@ -0,0 +1,4 @@ +module.exports = { + XSTSRelyingParty: 'https://multiplayer.minecraft.net/', + MinecraftAuth: 'https://multiplayer.minecraft.net/authentication' +} diff --git a/src/client/authFlow.js b/src/client/authFlow.js new file mode 100644 index 0000000..8caab8d --- /dev/null +++ b/src/client/authFlow.js @@ -0,0 +1,131 @@ +const crypto = require('crypto') +const path = require('path') +const fs = require('fs') +const debug = require('debug')('minecraft-protocol') +const mcDefaultFolderPath = require('minecraft-folder-path') +const authConstants = require('./authConstants') +const { MsaTokenManager, XboxTokenManager, MinecraftTokenManager } = require('./tokens') + +// Initialize msal +// Docs: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/docs/request.md#public-apis-1 +const msalConfig = { + auth: { + // the minecraft client: + // clientId: "000000004C12AE6F", + clientId: '389b1b32-b5d5-43b2-bddc-84ce938d6737', // token from https://github.com/microsoft/Office365APIEditor + authority: 'https://login.microsoftonline.com/consumers', + } +} + +async function retry (methodFn, beforeRety, times) { + while (times--) { + if (times !== 0) { + try { return await methodFn() } catch (e) { debug(e) } + await beforeRety() + } else { + return await methodFn() + } + } +} + +class MsAuthFlow { + constructor (username, cacheDir, codeCallback) { + this.initTokenCaches(username, cacheDir) + this.codeCallback = codeCallback + } + + initTokenCaches (username, cacheDir) { + const hash = sha1(username).substr(0, 6) + + let cachePath = cacheDir || mcDefaultFolderPath + try { + if (!fs.existsSync(cachePath + '/nmp-cache')) { + fs.mkdirSync(cachePath + '/nmp-cache') + } + cachePath += '/nmp-cache' + } catch (e) { + console.log('Failed to open cache dir', e) + cachePath = __dirname + } + + const cachePaths = { + msa: path.join(cachePath, `./${hash}_msa-cache.json`), + xbl: path.join(cachePath, `./${hash}_xbl-cache.json`), + bed: path.join(cachePath, `./${hash}_bed-cache.json`) + } + + const scopes = ['XboxLive.signin', 'offline_access'] + this.msa = new MsaTokenManager(msalConfig, scopes, cachePaths.msa) + this.xbl = new XboxTokenManager(authConstants.XSTSRelyingParty, cachePaths.xbl) + this.mca = new MinecraftTokenManager(cachePaths.bed) + } + + static resetTokenCaches (cacheDir) { + let cachePath = cacheDir || mcDefaultFolderPath + try { + if (fs.existsSync(cachePath + '/nmp-cache')) { + cachePath += '/nmp-cache' + fs.rmdirSync(cachePath, { recursive: true }) + return true + } + } catch (e) { + console.log('Failed to clear cache dir', e) + return false + } + } + + async getMsaToken () { + if (await this.msa.verifyTokens()) { + debug('[msa] Using existing tokens') + return this.msa.getAccessToken().token + } else { + debug('[msa] No valid cached tokens, need to sign in') + const ret = await this.msa.authDeviceCode((response) => { + console.info('[msa] First time signing in. Please authenticate now:') + console.info(response.message) + if (this.codeCallback) this.codeCallback(response) + }) + + console.info(`[msa] Signed in as ${ret.account.username}`) + + debug('[msa] got auth result', ret) + return ret.accessToken + } + } + + async getXboxToken () { + if (await this.xbl.verifyTokens()) { + debug('[xbl] Using existing tokens') + return this.xbl.getCachedXstsToken().data + } else { + debug('[xbl] Need to obtain tokens') + return await retry(async () => { + const msaToken = await this.getMsaToken() + const ut = await this.xbl.getUserToken(msaToken) + const xsts = await this.xbl.getXSTSToken(ut) + return xsts + }, () => { this.msa.forceRefresh = true }, 2) + } + } + + async getMinecraftToken (publicKey) { + if (await this.mca.verifyTokens()) { + debug('[mc] Using existing tokens') + return this.mca.getCachedAccessToken().chain + } else { + if (!publicKey) throw new Error('Need to specifiy a ECDH x509 URL encoded public key') + debug('[mc] Need to obtain tokens') + return await retry(async () => { + const xsts = await this.getXboxToken() + debug('[xbl] xsts data', xsts) + return this.mca.getAccessToken(publicKey, xsts).chain + }, () => { this.xbl.forceRefresh = true }, 2) + } + } +} + +function sha1 (data) { + return crypto.createHash('sha1').update(data || '', 'binary').digest('hex') +} + +module.exports = { MsAuthFlow } diff --git a/src/client/tokens.js b/src/client/tokens.js new file mode 100644 index 0000000..aeae166 --- /dev/null +++ b/src/client/tokens.js @@ -0,0 +1,299 @@ +const msal = require('@azure/msal-node') +const XboxLiveAuth = require('@xboxreplay/xboxlive-auth') +const debug = require('debug')('minecraft-protocol') +const fs = require('fs') +const path = require('path') +const fetch = require('node-fetch') +const authConstants = require('./authConstants') + +// Manages Microsoft account tokens +class MsaTokenManager { + constructor(msalConfig, scopes, cacheLocation) { + this.msaClientId = msalConfig.auth.clientId + this.scopes = scopes + this.cacheLocation = cacheLocation || path.join(__dirname, './msa-cache.json') + + try { + this.msaCache = require(this.cacheLocation) + } catch (e) { + this.msaCache = {} + fs.writeFileSync(this.cacheLocation, JSON.stringify(this.msaCache)) + } + + const beforeCacheAccess = async (cacheContext) => { + cacheContext.tokenCache.deserialize(await fs.promises.readFile(this.cacheLocation, 'utf-8')) + } + + const afterCacheAccess = async (cacheContext) => { + if (cacheContext.cacheHasChanged) { + await fs.promises.writeFile(this.cacheLocation, cacheContext.tokenCache.serialize()) + } + } + + const cachePlugin = { + beforeCacheAccess, + afterCacheAccess + } + + msalConfig.cache = { + cachePlugin + } + this.msalApp = new msal.PublicClientApplication(msalConfig) + this.msalConfig = msalConfig + } + + getUsers() { + const accounts = this.msaCache.Account + const users = [] + if (!accounts) return users + for (const account of Object.values(accounts)) { + users.push(account) + } + return users + } + + getAccessToken() { + const tokens = this.msaCache.AccessToken + if (!tokens) return + const account = Object.values(tokens).filter(t => t.client_id === this.msaClientId)[0] + if (!account) { + debug('[msa] No valid access token found', tokens) + return + } + const until = new Date(account.expires_on * 1000) - Date.now() + const valid = until > 1000 + return { valid, until: until, token: account.secret } + } + + getRefreshToken() { + const tokens = this.msaCache.RefreshToken + if (!tokens) return + const account = Object.values(tokens).filter(t => t.client_id === this.msaClientId)[0] + if (!account) { + debug('[msa] No valid refresh token found', tokens) + return + } + return { token: account.secret } + } + + async refreshTokens() { + const rtoken = this.getRefreshToken() + if (!rtoken) { + throw new Error('Cannot refresh without refresh token') + } + const refreshTokenRequest = { + refreshToken: rtoken.token, + scopes: this.scopes + } + + return new Promise((resolve, reject) => { + this.msalApp.acquireTokenByRefreshToken(refreshTokenRequest).then((response) => { + debug('[msa] refreshed token', JSON.stringify(response)) + resolve(response) + }).catch((error) => { + debug('[msa] failed to refresh', JSON.stringify(error)) + reject(error) + }) + }) + } + + async verifyTokens() { + const at = this.getAccessToken() + const rt = this.getRefreshToken() + if (!at || !rt || this.forceRefresh) { + return false + } + debug('[msa] have at, rt', at, rt) + if (at.valid && rt) { + return true + } else { + try { + await this.refreshTokens() + return true + } catch (e) { + return false + } + } + } + + // Authenticate with device_code flow + async authDeviceCode(dataCallback) { + const deviceCodeRequest = { + deviceCodeCallback: (resp) => { + debug('[msa] device_code response: ', resp) + dataCallback(resp) + }, + scopes: this.scopes + } + + return new Promise((resolve, reject) => { + this.msalApp.acquireTokenByDeviceCode(deviceCodeRequest).then((response) => { + debug('[msa] device_code resp', JSON.stringify(response)) + if (!this.msaCache.Account) this.msaCache.Account = { '': response.account } + resolve(response) + }).catch((error) => { + console.warn('[msa] Error getting device code') + console.debug(JSON.stringify(error)) + reject(error) + }) + }) + } +} + +// Manages Xbox Live tokens for xboxlive.com +class XboxTokenManager { + constructor(relyingParty, cacheLocation) { + this.relyingParty = relyingParty + this.cacheLocation = cacheLocation || path.join(__dirname, './xbl-cache.json') + try { + this.cache = require(this.cacheLocation) + } catch (e) { + this.cache = {} + } + } + + getCachedUserToken() { + const token = this.cache.userToken + if (!token) return + const until = new Date(token.NotAfter) + const dn = Date.now() + const remainingMs = until - dn + const valid = remainingMs > 1000 + return { valid, token: token.Token, data: token } + } + + getCachedXstsToken() { + const token = this.cache.xstsToken + if (!token) return + const until = new Date(token.expiresOn) + const dn = Date.now() + const remainingMs = until - dn + const valid = remainingMs > 1000 + return { valid, token: token.XSTSToken, data: token } + } + + setCachedUserToken(data) { + this.cache.userToken = data + fs.writeFileSync(this.cacheLocation, JSON.stringify(this.cache)) + } + + setCachedXstsToken(data) { + this.cache.xstsToken = data + fs.writeFileSync(this.cacheLocation, JSON.stringify(this.cache)) + } + + async verifyTokens() { + const ut = this.getCachedUserToken() + const xt = this.getCachedXstsToken() + if (!ut || !xt || this.forceRefresh) { + return false + } + debug('[xbl] have user, xsts', ut, xt) + if (ut.valid && xt.valid) { + return true + } else if (ut.valid && !xt.valid) { + try { + await this.getXSTSToken(ut.data) + return true + } catch (e) { + return false + } + } + return false + } + + async getUserToken(msaAccessToken) { + debug('[xbl] obtaining xbox token with ms token', msaAccessToken) + if (!msaAccessToken.startsWith('d=')) { msaAccessToken = 'd=' + msaAccessToken } + const xblUserToken = await XboxLiveAuth.exchangeRpsTicketForUserToken(msaAccessToken) + this.setCachedUserToken(xblUserToken) + debug('[xbl] user token:', xblUserToken) + return xblUserToken + } + + async getXSTSToken(xblUserToken) { + debug('[xbl] obtaining xsts token with xbox user token', xblUserToken.Token) + const xsts = await XboxLiveAuth.exchangeUserTokenForXSTSIdentity( + xblUserToken.Token, { XSTSRelyingParty: this.relyingParty, raw: false } + ) + this.setCachedXstsToken(xsts) + debug('[xbl] xsts', xsts) + return xsts + } +} + +// Manages Minecraft tokens for sessionserver.mojang.com +class MinecraftTokenManager { + constructor(clientPublicKey, cacheLocation) { + this.clientPublicKey = clientPublicKey + this.cacheLocation = cacheLocation || path.join(__dirname, './bed-cache.json') + try { + this.cache = require(this.cacheLocation) + } catch (e) { + this.cache = {} + } + } + + getCachedAccessToken() { + const token = this.cache.mca + debug('[mc] token cache', this.cache) + if (!token) return + console.log('TOKEN', token) + const jwt = token.chain[0] + const [header, payload, signature] = jwt.split('.').map(k => Buffer.from(k, 'base64')) + + const body = JSON.parse(String(payload)) + const expires = new Date(body.exp * 1000) + const remainingMs = expires - Date.now() + const valid = remainingMs > 1000 + return { valid, until: expires, chain: token.chain } + } + + setCachedAccessToken(data) { + data.obtainedOn = Date.now() + this.cache.mca = data + fs.writeFileSync(this.cacheLocation, JSON.stringify(this.cache)) + } + + async verifyTokens() { + const at = this.getCachedAccessToken() + if (!at || this.forceRefresh) { + return false + } + debug('[mc] have user access token', at) + if (at.valid) { + return true + } + return false + } + + async getAccessToken(clientPublicKey, xsts) { + debug('[mc] authing to minecraft', xsts) + const getFetchOptions = { + headers: { + 'Content-Type': 'application/json', + 'User-Agent': 'node-minecraft-protocol', + 'Authorization': `XBL3.0 x=${xsts.userHash};${xsts.XSTSToken}` + } + } + const MineServicesResponse = await fetch(authConstants.MinecraftAuth, { + method: 'post', + ...getFetchOptions, + body: JSON.stringify({ identityPublicKey: clientPublicKey }) + }).then(checkStatus) + + debug('[mc] mc auth response', MineServicesResponse) + this.setCachedAccessToken(MineServicesResponse) + return MineServicesResponse + } +} + +function checkStatus(res) { + if (res.ok) { // res.status >= 200 && res.status < 300 + return res.json() + } else { + throw Error(res.statusText) + } +} + +module.exports = { MsaTokenManager, XboxTokenManager, MinecraftTokenManager } diff --git a/src/clientTest.js b/src/clientTest.js new file mode 100644 index 0000000..4c4eb43 --- /dev/null +++ b/src/clientTest.js @@ -0,0 +1,11 @@ +process.env.DEBUG = 'minecraft-protocol raknet' +const { Client } = require('./client') + + +async function test() { + const client = new Client({ + + }) +} + +test() \ No newline at end of file diff --git a/src/connection.js b/src/connection.js index 9830b57..3712a0f 100644 --- a/src/connection.js +++ b/src/connection.js @@ -16,7 +16,7 @@ class Connection extends EventEmitter { write(name, params) { // TODO: Batch console.log('Need to encode', name, params) const batch = new BatchPacket() - const packet = this.server.serializer.createPacketBuffer({ name, params }) + const packet = this.serializer.createPacketBuffer({ name, params }) batch.addEncodedPacket(packet) if (this.encryptionEnabled) { @@ -86,7 +86,6 @@ class Connection extends EventEmitter { handle(buffer) { // handle encapsulated if (buffer[0] == 0xfe) { // wrapper - if (this.encryptionEnabled) { // console.log('READING ENCRYPTED PACKET', buffer) this.decrypt(buffer.slice(1)) diff --git a/src/server.js b/src/server.js index 8223f4f..7db207d 100644 --- a/src/server.js +++ b/src/server.js @@ -12,6 +12,7 @@ class Player extends Connection { constructor(server, connection, options) { super() this.server = server + this.serializer = server.serializer this.connection = connection Encrypt(this, server, options) } From 233f0d33a660153f3005e6b2b1a7bb061f60ce37 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 13 Feb 2021 18:42:43 -0500 Subject: [PATCH 086/106] workingish client connection to server Joining a vanilla server is still broken (related to encryption), but minet connects --- data/new/proto.yml | 14 ++-- data/new/types.yaml | 25 +++--- data/newproto.json | 51 ++++++------- src/auth/encryption.js | 113 ++++++++++++++++++++++++---- src/client.js | 42 +++++++---- src/client/auth.js | 4 +- src/client/authFlow.js | 7 +- src/client/tokens.js | 2 +- src/clientTest.js | 11 ++- src/connection.js | 4 +- src/datatypes/compiler-minecraft.js | 6 +- src/serverTest.js | 2 +- src/transforms/encryption.js | 53 ++++++++++--- 13 files changed, 231 insertions(+), 103 deletions(-) diff --git a/data/new/proto.yml b/data/new/proto.yml index 5bf4498..a3fe763 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -197,13 +197,13 @@ packet_start_game: entity_id: zigzag64 # The runtime ID of the player. The runtime ID is unique for each world session, # and entities are generally identified in packets using this runtime ID. - runtime_entity_id: varint + runtime_entity_id: varint64 player_gamemode: zigzag32 # The spawn position of the player in the world. In servers this is often the same as the # world's spawn position found below. spawn: vec3f # The pitch and yaw of the player - rotation: vec3f + rotation: vec2f # The seed used to generate the world. Unlike in Java edition, the seed is a 32bit Integer here. seed: zigzag32 biome_type: li16 @@ -302,8 +302,8 @@ packet_start_game: # The version of the game from which Vanilla features will be used. # The exact function of this field isn't clear. game_version: string - limited_world_width_: li32 - limited_world_length_: li32 + limited_world_width: li32 + limited_world_length: li32 is_new_nether_: bool experimental_gameplay_override: bool # A base64 encoded world ID that is used to identify the world. @@ -335,7 +335,7 @@ packet_start_game: ## This is not sent anymore in protocol versions > 419 (Bedrock Edition v1.16.100) ## A list of all blocks registered on the server. - ## block_palette: BlockPalette + block_palette: BlockPalette # A list of all items with their legacy IDs which are available in the game. # Failing to send any of the items that are in the game will crash mobile clients. itemstates: Itemstates @@ -525,9 +525,9 @@ packet_mob_effect: packet_update_attributes: !id: 0x1d !bound: server - runtime_entity_id: varint + runtime_entity_id: varint64 attributes: PlayerAttributes - tick: varint + tick: varint64 packet_inventory_transaction: !id: 0x1e diff --git a/data/new/types.yaml b/data/new/types.yaml index 2168098..f53f36d 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -3,7 +3,7 @@ BehaviourPackInfos: []li16 uuid: string version: string - length: lu64 + size: lu64 content_key: string sub_pack_name: string content_identity: string @@ -12,7 +12,7 @@ BehaviourPackInfos: []li16 TexturePackInfos: []li16 uuid: string version: string - length: lu64 + size: lu64 content_key: string sub_pack_name: string content_identity: string @@ -27,13 +27,13 @@ ResourcePackIdVersions: []varint # The subpack name of the resource pack. name: string -ResourcePackIds: string[]varint +ResourcePackIds: string[]li16 Experiment: name: string enabled: bool -Experiments: Experiment[]varint +Experiments: Experiment[]li32 GameRule: name: string @@ -43,7 +43,7 @@ GameRule: 3: float value: type? if bool: bool - if int: varint + if int: zigzag32 if float: lf32 GameRules: GameRule[]varint @@ -150,10 +150,10 @@ BlockCoordinates: # mojang... z: zigzag32 PlayerAttributes: []varint - min_value: lf32 - max_value: lf32 - current_value: lf32 - default_value: lf32 + min: lf32 + max: lf32 + current: lf32 + default: lf32 name: string Transaction: @@ -190,7 +190,7 @@ Transaction: slot: varint old_item: Item new_item: Item - new_item_stack_id: has_network_ids? + new_item_stack_id: ../has_network_ids? if true: zigzag32 default: void transaction_data: transaction_type? @@ -242,7 +242,7 @@ PotionContainerChangeRecipes: []varint output_item_id: zigzag32 Recipes: []varint - type: varint => + type: zigzag32 => '0': 'shapeless' #'ENTRY_SHAPELESS', '1': 'shaped' #'ENTRY_SHAPED', '2': 'furnace' # 'ENTRY_FURNACE', @@ -341,9 +341,6 @@ PlayerRecords: is_host: bool if remove: uuid: uuid - uuid: type? - if add: uuid - default: void verified: bool[]$records_count ScoreEntries: diff --git a/data/newproto.json b/data/newproto.json index e520a62..f2a320f 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -25,7 +25,7 @@ "type": "string" }, { - "name": "length", + "name": "size", "type": "lu64" }, { @@ -64,7 +64,7 @@ "type": "string" }, { - "name": "length", + "name": "size", "type": "lu64" }, { @@ -117,7 +117,7 @@ "ResourcePackIds": [ "array", { - "countType": "varint", + "countType": "li16", "type": "string" } ], @@ -137,7 +137,7 @@ "Experiments": [ "array", { - "countType": "varint", + "countType": "li32", "type": "Experiment" } ], @@ -170,7 +170,7 @@ "compareTo": "type", "fields": { "bool": "bool", - "int": "varint", + "int": "zigzag32", "float": "lf32" }, "default": "void" @@ -580,19 +580,19 @@ "container", [ { - "name": "min_value", + "name": "min", "type": "lf32" }, { - "name": "max_value", + "name": "max", "type": "lf32" }, { - "name": "current_value", + "name": "current", "type": "lf32" }, { - "name": "default_value", + "name": "default", "type": "lf32" }, { @@ -775,7 +775,7 @@ "type": [ "switch", { - "compareTo": "has_network_ids", + "compareTo": "../has_network_ids", "fields": { "true": "zigzag32" }, @@ -1010,7 +1010,7 @@ "type": [ "mapper", { - "type": "varint", + "type": "zigzag32", "mappings": { "0": "shapeless", "1": "shaped", @@ -1449,19 +1449,6 @@ } ] }, - { - "name": "uuid", - "type": [ - "switch", - { - "compareTo": "type", - "fields": { - "add": "uuid" - }, - "default": "void" - } - ] - }, { "name": "verified", "type": [ @@ -2671,7 +2658,7 @@ }, { "name": "runtime_entity_id", - "type": "varint" + "type": "varint64" }, { "name": "player_gamemode", @@ -2683,7 +2670,7 @@ }, { "name": "rotation", - "type": "vec3f" + "type": "vec2f" }, { "name": "seed", @@ -2834,11 +2821,11 @@ "type": "string" }, { - "name": "limited_world_width_", + "name": "limited_world_width", "type": "li32" }, { - "name": "limited_world_length_", + "name": "limited_world_length", "type": "li32" }, { @@ -2887,6 +2874,10 @@ "name": "enchantment_seed", "type": "zigzag32" }, + { + "name": "block_palette", + "type": "BlockPalette" + }, { "name": "itemstates", "type": "Itemstates" @@ -3390,7 +3381,7 @@ [ { "name": "runtime_entity_id", - "type": "varint" + "type": "varint64" }, { "name": "attributes", @@ -3398,7 +3389,7 @@ }, { "name": "tick", - "type": "varint" + "type": "varint64" } ] ], diff --git a/src/auth/encryption.js b/src/auth/encryption.js index f32bc69..956eede 100644 --- a/src/auth/encryption.js +++ b/src/auth/encryption.js @@ -6,11 +6,11 @@ const ec_pem = require('ec-pem') const SALT = '🧂' const curve = 'secp384r1' -function Encrypt(client, options) { +function Encrypt(client, server, options) { client.ecdhKeyPair = crypto.createECDH(curve) client.ecdhKeyPair.generateKeys() + client.clientX509 = writeX509PublicKey(client.ecdhKeyPair.getPublicKey()) - createClientChain(client) function startClientboundEncryption(publicKey) { console.warn('[encrypt] Pub key base64: ', publicKey) @@ -31,9 +31,11 @@ function Encrypt(client, options) { const secretHash = crypto.createHash('sha256') secretHash.update(SALT) secretHash.update(client.sharedSecret) + console.log('---- SHARED SECRET', client.sharedSecret) + client.secretKeyBytes = secretHash.digest() - + console.log('Hash', client.secretKeyBytes) const x509 = writeX509PublicKey(alice.getPublicKey()) const token = JWT.sign({ salt: toBase64(SALT), @@ -51,30 +53,109 @@ function Encrypt(client, options) { client.startEncryption(initial) } - function startServerboundEncryption() { + function startServerboundEncryption(token) { + console.warn('Starting serverbound encryption', token) + const jwt = token?.token + if (!jwt) { + // TODO: allow connecting to servers without encryption + throw Error('Server did not return a valid JWT, cannot start encryption!') + } + // TODO: Should we do some JWT signature validation here? Seems pointless + const alice = client.ecdhKeyPair + const [header, payload, signature] = jwt.split('.').map(k => Buffer.from(k, 'base64')) + const head = JSON.parse(String(header)) + const body = JSON.parse(String(payload)) + const serverPublicKey = readX509PublicKey(head.x5u) + client.sharedSecret = alice.computeSecret(serverPublicKey) + console.log('------ SHARED SECRET', client.sharedSecret) + const salt = Buffer.from(body.salt, 'base64') + + const secretHash = crypto.createHash('sha256') + secretHash.update(salt) + secretHash.update(client.sharedSecret) + + client.secretKeyBytes = secretHash.digest() + console.log('Hash', client.secretKeyBytes) + const initial = client.secretKeyBytes.slice(0, 16) + client.startEncryption(initial) + + // It works! First encrypted packet :) + client.write('client_to_server_handshake', {}) } client.on('server.client_handshake', startClientboundEncryption) -} -function createClientChain(client) { - const alice = client.ecdhKeyPair - const alicePEM = ec_pem(alice, curve) // https://github.com/nodejs/node/issues/15116#issuecomment-384790125 - const alicePEMPrivate = alicePEM.encodePrivateKey() - const x509 = writeX509PublicKey(alice.getPublicKey()) + client.on('client.server_handshake', startServerboundEncryption) - const token = JWT.sign({ - salt: toBase64(SALT), - signedToken: alice.getPublicKey('base64') - }, alicePEMPrivate, { algorithm: 'ES384', header: { x5u: x509 } }) + client.createClientChain = (mojangKey) => { + mojangKey = mojangKey || require('./constants').PUBLIC_KEY + const alice = client.ecdhKeyPair + const alicePEM = ec_pem(alice, curve) // https://github.com/nodejs/node/issues/15116#issuecomment-384790125 + const alicePEMPrivate = alicePEM.encodePrivateKey() - client.clientChain = token + const token = JWT.sign({ + identityPublicKey: mojangKey, + certificateAuthority: true + }, alicePEMPrivate, { algorithm: 'ES384', header: { x5u: client.clientX509 } }) + + client.clientIdentityChain = token + client.createClientUserChain(alicePEMPrivate) + } + + client.createClientUserChain = (privateKey) => { + let payload = { + ServerAddress: options.hostname, + ThirdPartyName: client.profile.name, + DeviceOS: client.session?.deviceOS || 1, + GameVersion: options.version || '1.16.201', + ClientRandomId: Date.now(), // TODO make biggeer + DeviceId: '2099de18-429a-465a-a49b-fc4710a17bb3', // TODO random + LanguageCode: 'en_GB', // TODO locale + AnimatedImageData: [], + PersonaPieces: [], + PieceTintColours: [], + SelfSignedId: '78eb38a6-950e-3ab9-b2cf-dd849e343701', + SkinId: '5eb65f73-af11-448e-82aa-1b7b165316ad.persona-e199672a8c1a87e0-0', + SkinData: 'AAAAAA==', + SkinResourcePatch: 'ewogICAiZ2VvbWV0cnkiIDogewogICAgICAiYW5pbWF0ZWRfMTI4eDEyOCIgOiAiZ2VvbWV0cnkuYW5pbWF0ZWRfMTI4eDEyOF9wZXJzb25hLWUxOTk2NzJhOGMxYTg3ZTAtMCIsCiAgICAgICJhbmltYXRlZF9mYWNlIiA6ICJnZW9tZXRyeS5hbmltYXRlZF9mYWNlX3BlcnNvbmEtZTE5OTY3MmE4YzFhODdlMC0wIiwKICAgICAgImRlZmF1bHQiIDogImdlb21ldHJ5LnBlcnNvbmFfZTE5OTY3MmE4YzFhODdlMC0wIgogICB9Cn0K', + SkinGeometryData: require('./geom'), + "SkinImageHeight": 1, + "SkinImageWidth": 1, + "ArmSize": "wide", + "CapeData": "", + "CapeId": "", + "CapeImageHeight": 0, + "CapeImageWidth": 0, + "CapeOnClassicSkin": false, + PlatformOfflineId: '', + PlatformOnlineId: '', //chat + // a bunch of meaningless junk + CurrentInputMode: 1, + DefaultInputMode: 1, + DeviceModel: '', + GuiScale: -1, + UIProfile: 0, + TenantId: '', + PremiumSkin: false, + PersonaSkin: false, + PieceTintColors: [], + SkinAnimationData: '', + ThirdPartyNameOnly: false, + "SkinColor": "#ffffcd96", + } + payload = require('./logPack.json') + const customPayload = options.userData || {} + payload = { ...payload, ...customPayload } + + client.clientUserChain = JWT.sign(payload, privateKey, + { algorithm: 'ES384', header: { x5u: client.clientX509 } }) + } } function toBase64(string) { return Buffer.from(string).toString('base64') -} +} function readX509PublicKey(key) { var reader = new Ber.Reader(Buffer.from(key, "base64")); diff --git a/src/client.js b/src/client.js index 8e20275..acba7a6 100644 --- a/src/client.js +++ b/src/client.js @@ -4,6 +4,9 @@ const { createDeserializer, createSerializer } = require('./transforms/serialize const { Encrypt } = require('./auth/encryption') const auth = require('./client/auth') const Options = require('./options') +const fs = require('fs') + +const log = console.log class Client extends Connection { constructor(options) { @@ -41,7 +44,7 @@ class Client extends Connection { if (this.raknet) return - this.raknet = new RakClient('localhost', 19132) + this.raknet = new RakClient('127.0.0.1', 19132) await this.raknet.connect() this.raknet.on('connecting', () => { @@ -61,16 +64,17 @@ class Client extends Connection { } sendLogin() { + this.createClientChain() const chain = [ - this.clientChain, // JWT we generated for auth + this.clientIdentityChain, // JWT we generated for auth ...this.accessToken // Mojang + Xbox JWT from auth ] const encodedChain = JSON.stringify({ chain }) const skinChain = JSON.stringify({}) - const bodyLength = skinChain.length + encodedChain.length + 8 + const bodyLength = this.clientUserChain.length + encodedChain.length + 8 console.log('Auth chain', chain) @@ -78,7 +82,7 @@ class Client extends Connection { protocol_version: this.options.version, payload_size: bodyLength, chain: encodedChain, - client_data: skinChain + client_data: this.clientUserChain }) } @@ -90,19 +94,31 @@ class Client extends Connection { this.emit('join') } + onDisconnectRequest(packet) { + // We're talking over UDP, so there is no connection to close, instead + // we stop communicating with the server + console.warn(`Server requested ${packet.hide_disconnect_reason ? 'silent disconnect' : 'disconnect'}: ${packet.message}`) + process.exit(1) + } + readPacket(packet) { console.log('packet', packet) - const des = this.server.deserializer.parsePacketBuffer(packet) - console.log('->', des) + const des = this.deserializer.parsePacketBuffer(packet) + console.info('->', des) switch (des.data.name) { - case 'login': - console.log(des) - this.onLogin(des) - return - case 'client_to_server_handshake': - this.onHandshake() + case 'server_to_client_handshake': + this.emit('client.server_handshake', des.data.params) + break + case 'disconnect': // Client kicked + this.onDisconnectRequest(des.data.params) + break + case 'crafting_data': + fs.writeFileSync('crafting.json', JSON.stringify(des.data.params, (k,v) => typeof v == 'bigint' ? v.toString() : v)) + break + case 'start_game': + fs.writeFileSync('start_game.json', JSON.stringify(des.data.params, (k,v) => typeof v == 'bigint' ? v.toString() : v)) default: - console.log('ignoring, unhandled') + console.log('Sending to listeners') } this.emit(des.data.name, des.data.params) diff --git a/src/client/auth.js b/src/client/auth.js index 696cf30..bb83897 100644 --- a/src/client/auth.js +++ b/src/client/auth.js @@ -63,8 +63,8 @@ async function authenticateDeviceCode (client, options) { try { const flow = new MsAuthFlow(options.username, options.profilesFolder, options.onMsaCode) - const chain = await flow.getMinecraftToken(client.clientChain) - + const chain = await flow.getMinecraftToken(client.clientX509) + // console.log('Chain', chain) await postAuthenticate(client, options, chain) } catch (err) { console.error(err) diff --git a/src/client/authFlow.js b/src/client/authFlow.js index 8caab8d..1c0325f 100644 --- a/src/client/authFlow.js +++ b/src/client/authFlow.js @@ -109,7 +109,9 @@ class MsAuthFlow { } async getMinecraftToken (publicKey) { - if (await this.mca.verifyTokens()) { + // TODO: Fix cache, in order to do cache we also need to cache the ECDH keys so disable it + // is this even a good idea to cache? + if (await this.mca.verifyTokens() && false) { debug('[mc] Using existing tokens') return this.mca.getCachedAccessToken().chain } else { @@ -118,7 +120,8 @@ class MsAuthFlow { return await retry(async () => { const xsts = await this.getXboxToken() debug('[xbl] xsts data', xsts) - return this.mca.getAccessToken(publicKey, xsts).chain + const token = await this.mca.getAccessToken(publicKey, xsts) + return token.chain }, () => { this.xbl.forceRefresh = true }, 2) } } diff --git a/src/client/tokens.js b/src/client/tokens.js index aeae166..1959211 100644 --- a/src/client/tokens.js +++ b/src/client/tokens.js @@ -268,7 +268,7 @@ class MinecraftTokenManager { } async getAccessToken(clientPublicKey, xsts) { - debug('[mc] authing to minecraft', xsts) + debug('[mc] authing to minecraft', clientPublicKey, xsts) const getFetchOptions = { headers: { 'Content-Type': 'application/json', diff --git a/src/clientTest.js b/src/clientTest.js index 4c4eb43..d0ba45f 100644 --- a/src/clientTest.js +++ b/src/clientTest.js @@ -1,10 +1,19 @@ process.env.DEBUG = 'minecraft-protocol raknet' const { Client } = require('./client') +// console.log = () => async function test() { const client = new Client({ - + hostname: '127.0.0.1', + port: 19132 + }) + + client.once('resource_packs_info', (packet) => { + client.write('resource_pack_client_response', { + response_status: 'completed', + resourcepackids: [] + }) }) } diff --git a/src/connection.js b/src/connection.js index 3712a0f..e6eef5a 100644 --- a/src/connection.js +++ b/src/connection.js @@ -8,7 +8,7 @@ const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_p class Connection extends EventEmitter { startEncryption(iv) { this.encryptionEnabled = true - + console.log('Started encryption', this.sharedSecret, iv) this.decrypt = cipher.createDecryptor(this, iv) this.encrypt = cipher.createEncryptor(this, iv) } @@ -74,7 +74,7 @@ class Connection extends EventEmitter { } onDecryptedPacket = (buf) => { - console.log('Decrypted', buf) + console.log('🟢 Decrypted', buf) const stream = new BinaryStream(buf) const packets = BatchPacket.getPackets(stream) diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js index f8fa767..7dc6ea4 100644 --- a/src/datatypes/compiler-minecraft.js +++ b/src/datatypes/compiler-minecraft.js @@ -3,7 +3,7 @@ const minecraft = require('./minecraft') module.exports = { Read: { - UUID: ['native', (buffer, offset) => { + uuid: ['native', (buffer, offset) => { return { value: UUID.stringify(buffer.slice(offset, 16 + offset)), size: 16 @@ -18,7 +18,7 @@ module.exports = { nbt: ['native', minecraft.nbt[0]] }, Write: { - UUID: ['native', (value, buffer, offset) => { + uuid: ['native', (value, buffer, offset) => { const buf = UUID.parse(value) buf.copy(buffer, offset) return offset + 16 @@ -30,7 +30,7 @@ module.exports = { nbt: ['native', minecraft.nbt[1]] }, SizeOf: { - UUID: ['native', 16], + uuid: ['native', 16], restBuffer: ['native', (value) => { return value.length }], diff --git a/src/serverTest.js b/src/serverTest.js index a02ac35..0d733f6 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -6,7 +6,7 @@ const fs = require('fs') let server = new Server({ }) -server.create('0.0.0.0', 19130) +server.create('0.0.0.0', 19132) let ran = false diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index 7aaee6b..f9cf293 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -119,28 +119,46 @@ function createDecryptor(client, iv) { const verifyChecksum = new Transform({ // verify checksum transform(chunk, encoding, cb) { - console.log('Decryptor: checking checksum', chunk) + console.log('Decryptor: checking checksum', client.receiveCounter, chunk) const packet = chunk.slice(0, chunk.length - 8); const checksum = chunk.slice(chunk.length - 8); const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) + // console.log(computedCheckSum2, computedCheckSum3) console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') client.receiveCounter++ - if (checksum.toString("hex") == computedCheckSum.toString("hex")) { + // if (checksum.toString("hex") == computedCheckSum.toString("hex")) { this.push(packet) - } else { - throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) - } + // console.log('🔵 Decriphered', checksum) + + // const inflated = Zlib.inflateRawSync(chunk, { + // chunkSize: 1024 * 1024 * 2 + // }) + // console.log('🔵 Inflated') + // client.onDecryptedPacket(inflated) + // } else { + // // console.log('🔴 Not OK') + // throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) + // } cb() } }) const inflator = new Transform({ transform(chunk, enc, cb) { - Zlib.inflateRaw(chunk, { chunkSize: 1024 * 1024 * 2 }, (err, buf) => { - if (err) throw err - this.push(buf) - cb() + console.log('🔵 Inflating') + const inflated = Zlib.inflateRawSync(chunk, { + chunkSize: 1024 * 1024 * 2 }) + console.log('🔵 Inflated') + this.push(inflated) + cb() + + // Zlib.inflateRaw(chunk, { chunkSize: 1024 * 1024 * 2 }, (err, buf) => { + // console.log('🔵 INF') + // if (err) throw err + // this.push(buf) + // cb() + // }) } }) @@ -148,11 +166,24 @@ function createDecryptor(client, iv) { .pipe(inflator) // .pipe(Zlib.createInflateRaw({ chunkSize: 1024 * 1024 * 2 })) .on('data', (...args) => client.onDecryptedPacket(...args)) - .on('end', () => console.log('Decryptor: finish pipeline')) + // .on('end', () => console.log('Decryptor: finish pipeline')) + // Not sure why, but sending two packets to the decryption pipe before + // the other is completed breaks the checksum check. + // TODO: Refactor the logic here to be async so we can await a promise + // queue + let decQ = [] + setInterval(() => { + if (decQ.length) { + let pak = decQ.shift() + console.log('🟡 DECRYPTING', pak) + client.decipher.write(pak) + } + }, 500) return (blob) => { - client.decipher.write(blob) + decQ.push(blob) + // client.decipher.write(blob) } } From b2a8d6fa2d33f1bbe44491800297527181f681a8 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 13 Feb 2021 21:04:22 -0500 Subject: [PATCH 087/106] rebasing --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a3edda2..037985b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -pocket-minecraft-protocol +pocket-minecraft-protocol [![NPM version](https://img.shields.io/npm/v/pocket-minecraft-protocol.svg)](http://npmjs.com/package/pocket-minecraft-protocol) [![Join the chat at https://gitter.im/PrismarineJS/pocket-minecraft-protocol](https://badges.gitter.im/PrismarineJS/pocket-minecraft-protocol.svg)](https://gitter.im/PrismarineJS/pocket-minecraft-protocol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ========================= -[![NPM version](https://img.shields.io/npm/v/pocket-minecraft-protocol.svg)](http://npmjs.com/package/pocket-minecraft-protocol) -[![Join the chat at https://gitter.im/mhsjlw/pocket-minecraft-protocol](https://badges.gitter.im/mhsjlw/pocket-minecraft-protocol.svg)](https://gitter.im/mhsjlw/pocket-minecraft-protocol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +> Note: **THIS IS NOT USABLE SOFTWARE!** If you're looking for experimental encryption or current support, please see the [1.1](https://github.com/PrismarineJS/pocket-minecraft-protocol/tree/1.1)+ branch -Parse and serialize Minecraft PE packets (use [this](https://github.com/filfat/MiNET-protocol-converter) to generate the protocol data). +Parse and serialize Minecraft: Pocket Edition packets ## Features @@ -16,7 +15,7 @@ Parse and serialize Minecraft PE packets (use [this](https://github.com/filfat/M ## Installation Simply run - npm install pocket-minecraft-protcol + npm install pocket-minecraft-protocol Then view our `examples` for inspiration! From 7b00432c7bcf2535f7700feb760d7877ad5d47bc Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 16 Feb 2021 03:24:25 -0500 Subject: [PATCH 088/106] protocol updates --- data/new/proto.yml | 513 ++++++++++++++++++++++++-------- data/new/types.yaml | 192 ++++++++++-- data/newproto.json | 703 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 1218 insertions(+), 190 deletions(-) diff --git a/data/new/proto.yml b/data/new/proto.yml index a3fe763..9727a76 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -40,7 +40,7 @@ nbt: native packet_login: !id: 0x01 - !bound: client + !bound: server protocol_version: i32 # The combined size of the `chain` and `client_data` payload_size: varint @@ -52,7 +52,7 @@ packet_login: packet_play_status: !id: 0x02 - !bound: server + !bound: client status: i32 => # Sent after Login has been successfully decoded and the player has logged in 0: login_success @@ -74,7 +74,7 @@ packet_play_status: packet_server_to_client_handshake: !id: 0x03 - !bound: server + !bound: client # Contains the salt to complete the Diffie-Hellman key exchange token: string @@ -85,12 +85,12 @@ packet_server_to_client_handshake: # It has no fields. packet_client_to_server_handshake: !id: 0x04 - !bound: client + !bound: server # Sent by the server to disconnect a client. packet_disconnect: !id: 0x05 - !bound: server + !bound: client # Specifies if the disconnection screen should be hidden when the client is disconnected, # meaning it will be sent directly to the main menu. hide_disconnect_reason: bool @@ -100,7 +100,7 @@ packet_disconnect: packet_resource_packs_info: !id: 0x06 - !bound: server + !bound: client # If the resource pack requires the client accept it. must_accept: bool # If scripting is enabled. @@ -114,7 +114,7 @@ packet_resource_packs_info: packet_resource_pack_stack: !id: 0x07 - !bound: server + !bound: client # If the resource pack must be accepted for the player to join the server. must_accept: bool # [inline] @@ -127,7 +127,7 @@ packet_resource_pack_stack: packet_resource_pack_client_response: !id: 0x08 - !bound: client + !bound: server response_status: u8 => 0: none 1: refused @@ -144,6 +144,8 @@ packet_resource_pack_client_response: packet_text: !id: 0x09 !bound: both + # TextType is the type of the text sent. When a client sends this to the server, it should always be + # TextTypeChat. If the server sends it, it may be one of the other text types above. type: u8 => 0: raw 1: chat @@ -162,7 +164,7 @@ packet_text: needs_translation: bool _: type? if chat or whisper or announcement: - sourceName: string + source_name: string if raw or tip or system or json_whisper or json: message: string if translation or popup or jukebox_popup: @@ -182,7 +184,7 @@ packet_text: # of synchronizing time between server and client. packet_set_time: !id: 0x0a - !bound: server + !bound: client # Time is the current time. The time is not limited to 24000 (time of day), but continues # progressing after that. time: zigzag32 @@ -190,7 +192,7 @@ packet_set_time: # Sent by the server to send information about the world the player will be spawned in. packet_start_game: !id: 0x0b - !bound: server + !bound: client # The unique ID of the player. The unique ID is a value that remains consistent across # different sessions of the same world, but most unofficial servers simply fill the # runtime ID of the entity out for this field. @@ -344,9 +346,10 @@ packet_start_game: multiplayer_correlation_id: string server_authoritative_inventory: bool + packet_add_player: !id: 0x0c - !bound: server + !bound: client # UUID is the UUID of the player. It is the same UUID that the client sent in the # Login packet at the start of the session. A player with this UUID must exist # in the player list (built up using the Player List packet) for it to show up in-game. @@ -388,7 +391,7 @@ packet_add_player: packet_add_entity: !id: 0x0d - !bound: server + !bound: client entity_id_self: zigzag64 runtime_entity_id: varint entity_type: string @@ -407,12 +410,12 @@ packet_add_entity: packet_remove_entity: !id: 0x0e - !bound: server + !bound: client entity_id_self: zigzag64 packet_add_item_entity: !id: 0x0f - !bound: server + !bound: client entity_id_self: zigzag64 runtime_entity_id: varint item: Item @@ -427,7 +430,7 @@ packet_add_item_entity: packet_take_item_entity: !id: 0x11 - !bound: server + !bound: client runtime_entity_id: varint target: varint @@ -460,7 +463,7 @@ packet_rider_jump: packet_update_block: !id: 0x15 - !bound: server + !bound: client coordinates: BlockCoordinates block_runtime_id: varint block_priority: varint @@ -468,7 +471,7 @@ packet_update_block: packet_add_painting: !id: 0x16 - !bound: server + !bound: client entity_id_self: zigzag64 runtime_entity_id: varint coordinates: BlockCoordinates @@ -493,28 +496,153 @@ packet_level_sound_event_old: packet_level_event: !id: 0x19 - !bound: server - event_id: zigzag32 + !bound: client + event: zigzag32 => + 1000: sound_click + 1001: sound_click_fail + 1002: sound_shoot + 1003: sound_door + 1004: sound_fizz + 1005: sound_ignite + 1007: sound_ghast + 1008: sound_ghast_shoot + 1009: sound_blaze_shoot + 1010: sound_door_bump + 1012: sound_door_crash + 1018: sound_enderman_teleport + 1020: sound_anvil_break + 1021: sound_anvil_use + 1022: sound_anvil_fall + 1030: sound_pop + 1032: sound_portal + 1040: sound_itemframe_add_item + 1041: sound_itemframe_remove + 1042: sound_itemframe_place + 1043: sound_itemframe_remove_item + 1044: sound_itemframe_rotate_item + 1050: sound_camera + 1051: sound_orb + 1052: sound_totem + 1060: sound_armor_stand_break + 1061: sound_armor_stand_hit + 1062: sound_armor_stand_fall + 1063: sound_armor_stand_place + 2000: particle_shoot #TODO: check 2000-2017 + 2001: particle_destroy + 2002: particle_splash + 2003: particle_eye_despawn + 2004: particle_spawn + 2006: guardian_curse + 2008: particle_block_force_field + 2009: particle_projectile_hit + 2013: particle_enderman_teleport + 2014: particle_punch_block + 3001: start_rain + 3002: start_thunder + 3003: stop_rain + 3004: stop_thunder + 3005: pause_game #data: 1 to pause, 0 to resume + 3006: pause_game_no_screen #data: 1 to pause, 0 to resume - same effect as normal pause but without screen + 3007: set_game_speed #x coordinate of pos = scale factor (default 1.0) + 3500: redstone_trigger + 3501: cauldron_explode + 3502: cauldron_dye_armor + 3503: cauldron_clean_armor + 3504: cauldron_fill_potion + 3505: cauldron_take_potion + 3506: cauldron_fill_water + 3507: cauldron_take_water + 3508: cauldron_add_dye + 3509: cauldron_clean_banner + 3600: block_start_break + 3601: block_stop_break + 4000: set_data + 9800: players_sleeping + 0x4000: add_particle_mask position: vec3f data: zigzag32 packet_block_event: !id: 0x1a - !bound: server - coordinates: BlockCoordinates - case_1: zigzag32 - case_2: zigzag32 + !bound: client + # Position is the position of the block that an event occurred at. + position: BlockCoordinates + # EventType is the type of the block event. + # The event type decides the way the event data that follows is used + type: zigzag32 => + 0: sound + 1: change_state + # EventData holds event type specific data. For chests for example, + # opening the chest means the data must be 1 + data: zigzag32 packet_entity_event: !id: 0x1b !bound: both runtime_entity_id: varint - event_id: u8 + event_id: u8 => + 1: jump + 2: hurt_animation + 3: death_animation + 4: arm_swing + 5: stop_attack + 6: tame_fail + 7: tame_success + 8: shake_wet + 9: use_item + 10: eat_grass_animation + 11: fish_hook_bubble + 12: fish_hook_position + 13: fish_hook_hook + 14: fish_hook_tease + 15: squid_ink_cloud + 16: zombie_villager_cure + 18: respawn + 19: iron_golem_offer_flower + 20: iron_golem_withdraw_flower + 21: love_particles #breeding + 22: villager_angry + 23: villager_happy + 24: witch_spell_particles + 25: firework_particles + 26: in_love_particles + 27: silverfish_spawn_animation + 28: guardian_attack + 29: witch_drink_potion + 30: witch_throw_potion + 31: minecart_tnt_prime_fuse + 32: creeper_prime_fuse + 33: air_supply_expired + 34: player_add_xp_levels + 35: elder_guardian_curse + 36: agent_arm_swing + 37: ender_dragon_death + 38: dust_particles #not sure what this is + 39: arrow_shake + + 57: eating_item + + 60: baby_animal_feed #green particles, like bonemeal on crops + 61: death_smoke_cloud + 62: complete_trade + 63: remove_leash #data 1 = cut leash + + 65: consume_totem + 66: player_check_treasure_hunter_achievement #mojang... + 67: entity_spawn #used for MinecraftEventing stuff, not needed + 68: dragon_puke #they call this puke particles + 69: item_entity_merge + 70: start_swim + 71: balloon_pop + 72: treasure_hunt + 73: agent_summon + 74: charged_crossbow + 75: fall data: zigzag32 packet_mob_effect: !id: 0x1c - !bound: server + !bound: client runtime_entity_id: varint event_id: u8 effect_id: zigzag32 @@ -524,7 +652,7 @@ packet_mob_effect: packet_update_attributes: !id: 0x1d - !bound: server + !bound: client runtime_entity_id: varint64 attributes: PlayerAttributes tick: varint64 @@ -560,7 +688,7 @@ packet_interact: packet_block_pick_request: !id: 0x22 - !bound: client + !bound: server x: zigzag32 y: zigzag32 z: zigzag32 @@ -569,21 +697,59 @@ packet_block_pick_request: packet_entity_pick_request: !id: 0x23 - !bound: client + !bound: server runtime_entity_id: lu64 selected_slot: u8 +# PlayerAction is sent by the client when it executes any action, for example starting to sprint, swim, +# starting the breaking of a block, dropping an item, etc. packet_player_action: !id: 0x24 - !bound: client + !bound: server + # EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and + # entities are generally identified in packets using this runtime ID. runtime_entity_id: varint - action_id: zigzag32 - coordinates: BlockCoordinates + # ActionType is the ID of the action that was executed by the player. It is one of the constants that may + # be found above. + action: zigzag32 => + 0: start_break + 1: abort_break + 2: stop_break + 3: get_updated_block + 4: drop_item + 5: start_sleeping + 6: stop_sleeping + 7: respawn + 8: jump + 9: start_sprint + 10: stop_sprint + 11: start_sneak + 12: stop_sneak + 13: creative_player_destroy_block + # sent when spawning in a different dimension to tell the server we spawned + 14: dimension_change_ack + 15: start_glide + 16: stop_glide + 17: build_denied + 18: continue_break + 19: change_skin + # no longer used + 20: set_enchatnment_seed + 21: swimming + 22: stop_swimming + 23: start_spin_attack + 24: stop_spin_attack + 25: ineract_block + # BlockPosition is the position of the target block, if the action with the ActionType set concerned a + # block. If that is not the case, the block position will be zero. + position: BlockCoordinates + # BlockFace is the face of the target block that was touched. If the action with the ActionType set + # concerned a block. If not, the face is always 0. face: zigzag32 packet_hurt_armor: !id: 0x26 - !bound: server + !bound: client health: zigzag32 packet_set_entity_data: @@ -601,7 +767,7 @@ packet_set_entity_motion: packet_set_entity_link: !id: 0x29 - !bound: server + !bound: client ridden_id: zigzag64 rider_id: zigzag64 link_type: u8 @@ -609,12 +775,12 @@ packet_set_entity_link: packet_set_health: !id: 0x2a - !bound: server + !bound: client health: zigzag32 packet_set_spawn_position: !id: 0x2b - !bound: server + !bound: client spawn_type: zigzag32 coordinates: BlockCoordinates dimension: zigzag32 @@ -637,7 +803,7 @@ packet_respawn: packet_container_open: !id: 0x2e - !bound: server + !bound: client window_id: u8 type: u8 coordinates: BlockCoordinates @@ -672,14 +838,14 @@ packet_inventory_slot: packet_container_set_data: !id: 0x33 - !bound: server + !bound: client window_id: u8 property: zigzag32 value: zigzag32 packet_crafting_data: !id: 0x34 - !bound: server + !bound: client recipes: Recipes potion_type_recipes: PotionTypeRecipes potion_container_recipes: PotionContainerChangeRecipes @@ -696,7 +862,7 @@ packet_crafting_event: packet_gui_data_pick_item: !id: 0x36 - !bound: server + !bound: client packet_adventure_settings: !id: 0x37 @@ -711,12 +877,12 @@ packet_adventure_settings: packet_block_entity_data: !id: 0x38 !bound: both - coordinates: BlockCoordinates + position: BlockCoordinates nbt: nbt packet_player_input: !id: 0x39 - !bound: client + !bound: server motion_x: lf32 motion_z: lf32 jumping: bool @@ -724,25 +890,25 @@ packet_player_input: packet_level_chunk: !id: 0x3a - !bound: server - chunk_x: zigzag32 - chunk_z: zigzag32 + !bound: client + x: zigzag32 + z: zigzag32 sub_chunk_count: varint column: Chunks packet_set_commands_enabled: !id: 0x3b - !bound: server + !bound: client enabled: bool packet_set_difficulty: !id: 0x3c - !bound: server + !bound: client difficulty: varint packet_change_dimension: !id: 0x3d - !bound: server + !bound: client dimension: zigzag32 position: vec3f respawn: bool @@ -754,23 +920,23 @@ packet_set_player_game_type: packet_player_list: !id: 0x3f - !bound: server + !bound: client records: PlayerRecords packet_simple_event: !id: 0x40 - !bound: server + !bound: client event_type: lu16 packet_spawn_experience_orb: !id: 0x42 - !bound: server + !bound: client position: vec3f count: zigzag32 packet_clientbound_map_item_data: !id: 0x43 - !bound: server + !bound: client mapinfo: MapInfo packet_map_info_request: @@ -785,7 +951,7 @@ packet_request_chunk_radius: packet_chunk_radius_update: !id: 0x46 - !bound: server + !bound: client chunk_radius: zigzag32 packet_item_frame_drop_item: @@ -795,52 +961,137 @@ packet_item_frame_drop_item: packet_game_rules_changed: !id: 0x48 - !bound: server + !bound: client rules: GameRules packet_camera: !id: 0x49 - !bound: server + !bound: client unknown1: zigzag64 unknown2: zigzag64 packet_boss_event: !id: 0x4a - !bound: server + !bound: both boss_entity_id: zigzag64 - event_type: varint + type: varint => + # S2C: Shows the boss-bar to the player. + 0: show_bar + # C2S: Registers a player to a boss fight. + 1: register_player + # S2C: Removes the boss-bar from the client. + 2: hide_bar + # C2S: Unregisters a player from a boss fight. + 3: unregister_player + # S2C: Sets the bar percentage. + 4: set_bar_progress + # S2C: Sets title of the bar. + 5: set_bar_title + # S2C: darkens the sky + 6: update_properties + # S2C: Not implemented :( Intended to alter bar appearance, but these currently produce no effect on client-side whatsoever. + 7: texture + _: type? + if register_player or unregister_player: + player_id: zigzag64 + if show: + title: string + bar_progress: lf32 + if update_properties: + darkness_factor: li16 + if texture: + color: varint + overlay: varint + if set_bar_progress: + bar_progress: lf32 + if set_bar_title: + title: string packet_show_credits: !id: 0x4b - !bound: server + !bound: client runtime_entity_id: varint status: zigzag32 packet_available_commands: !id: 0x4c - !bound: server + !bound: client + # enum_values: string[]varint + # suffixes: string[]varint + # enums: []varint + # name: string + # # The length of the array below + # values_len: varint + # # Not read from stream: instead calculated from the `values_len` field + # # If the values_len < 0xff => byte + # # If the values_len < 0xffff => short + # # If the values_len < 0xffffff => int + # enum_typex: u8 => + # 0: byte + # 1: short + # 2: int + # valuex: []varint + # # S: bool + # ix: ../enum_typex? + # if byte: u8 + # if short: lu16 + # if int: lu32 +# CommandRequest is sent by the client to request the execution of a server-side command. Although some +# servers support sending commands using the Text packet, this packet is guaranteed to have the correct +# result. packet_command_request: !id: 0x4d - !bound: client + !bound: server + # CommandLine is the raw entered command line. The client does no parsing of the command line by itself + # (unlike it did in the early stages), but lets the server do that. command: string - command_type: varint - unknown_uuid: uuid - request_id: string - unknown: bool + # Origin holds information about the command sender that will be returnd back in the command response + origin: CommandOrigin + # Internal specifies if the command request internal. Setting it to false seems to work and the usage of + # this field is not known. + interval: bool + packet_command_block_update: !id: 0x4e - !bound: client + !bound: server is_block: bool packet_command_output: !id: 0x4f - !bound: server + !bound: client + # CommandOrigin is the data specifying the origin of the command. In other words, the source that the + # command request was from, such as the player itself or a websocket server. The client forwards the + # messages in this packet to the right origin, depending on what is sent here. + origin: CommandOrigin + # OutputType specifies the type of output that is sent. The OutputType sent by vanilla games appears to + # be 3, which seems to work. + output_type: i8 + # SuccessCount is the amount of times that a command was executed successfully as a result of the command + # that was requested. For servers, this is usually a rather meaningless fields, but for vanilla, this is + # applicable for commands created with Functions. + success_count: varint + # OutputMessages is a list of all output messages that should be sent to the player. Whether they are + # shown or not, depends on the type of the messages. + output: []varint + # Success indicates if the output message was one of a successful command execution. If set to true, the + # output message is by default coloured white, whereas if set to false, the message is by default + # coloured red. + success: bool + # Message is the message that is sent to the client in the chat window. It may either be simply a + # message or a translated built-in string like 'commands.tp.success.coordinates', combined with specific + # parameters below. + message_id: string + # Parameters is a list of parameters that serve to supply the message sent with additional information, + # such as the position that a player was teleported to or the effect that was applied to an entity. + # These parameters only apply for the Minecraft built-in command output. + paramaters: string[]varint + packet_update_trade: !id: 0x50 - !bound: server + !bound: client window_id: u8 window_type: u8 unknown0: varint @@ -854,7 +1105,7 @@ packet_update_trade: packet_update_equipment: !id: 0x51 - !bound: server + !bound: client window_id: u8 window_type: u8 unknown: u8 @@ -863,7 +1114,7 @@ packet_update_equipment: packet_resource_pack_data_info: !id: 0x52 - !bound: server + !bound: client package_id: string max_chunk_size: lu32 chunk_count: lu32 @@ -874,7 +1125,7 @@ packet_resource_pack_data_info: packet_resource_pack_chunk_data: !id: 0x53 - !bound: server + !bound: client package_id: string chunk_index: lu32 progress: lu64 @@ -882,19 +1133,19 @@ packet_resource_pack_chunk_data: packet_resource_pack_chunk_request: !id: 0x54 - !bound: client + !bound: server package_id: string chunk_index: lu32 packet_transfer: !id: 0x55 - !bound: server + !bound: client server_address: string port: lu16 packet_play_sound: !id: 0x56 - !bound: server + !bound: client name: string coordinates: BlockCoordinates volume: lf32 @@ -902,13 +1153,13 @@ packet_play_sound: packet_stop_sound: !id: 0x57 - !bound: server + !bound: client name: string stop_all: bool packet_set_title: !id: 0x58 - !bound: server + !bound: client type: zigzag32 text: string fade_in_time: zigzag32 @@ -917,22 +1168,22 @@ packet_set_title: packet_add_behavior_tree: !id: 0x59 - !bound: server + !bound: client behaviortree: string packet_structure_block_update: !id: 0x5a - !bound: server + !bound: client packet_show_store_offer: !id: 0x5b - !bound: server + !bound: client unknown0: string unknown1: bool packet_purchase_receipt: !id: 0x5c - !bound: client + !bound: server packet_player_skin: !id: 0x5d @@ -945,21 +1196,43 @@ packet_player_skin: packet_sub_client_login: !id: 0x5e - !bound: server + !bound: client packet_initiate_web_socket_connection: !id: 0x5f - !bound: server + !bound: client server: string packet_set_last_hurt_by: !id: 0x60 - !bound: server + !bound: client unknown: varint packet_book_edit: !id: 0x61 - !bound: server + !bound: client + type: u8 => + 0: replace_page + 1: add_page + 2: delete_page + 3: swap_pages + 4: sign + slot: u8 + _: type? + if replace_page or add_page: + page_number: u8 + text: string + photo_name: string + if delete_page: + page_number: u8 + if swap_pages: + page1: u8 + page2: u8 + if sign: + title: string + author: string + xuid: string + packet_npc_request: !id: 0x62 @@ -971,51 +1244,51 @@ packet_npc_request: packet_photo_transfer: !id: 0x63 - !bound: client + !bound: server file_name: string image_data: string unknown2: string packet_modal_form_request: !id: 0x64 - !bound: server + !bound: client form_id: varint data: string packet_modal_form_response: !id: 0x65 - !bound: client + !bound: server form_id: varint data: string packet_server_settings_request: !id: 0x66 - !bound: client + !bound: server packet_server_settings_response: !id: 0x67 - !bound: server + !bound: client form_id: varint data: string packet_show_profile: !id: 0x68 - !bound: server + !bound: client xuid: string packet_set_default_game_type: !id: 0x69 - !bound: server + !bound: client gamemode: varint packet_remove_objective: !id: 0x6a - !bound: server + !bound: client objective_name: string packet_set_display_objective: !id: 0x6b - !bound: server + !bound: client display_slot: string objective_name: string display_name: string @@ -1024,7 +1297,7 @@ packet_set_display_objective: packet_set_score: !id: 0x6c - !bound: server + !bound: client entries: ScoreEntries packet_lab_table: @@ -1038,7 +1311,7 @@ packet_lab_table: packet_update_block_synced: !id: 0x6e - !bound: server + !bound: client coordinates: BlockCoordinates block_runtime_id: varint block_priority: varint @@ -1048,23 +1321,23 @@ packet_update_block_synced: packet_move_entity_delta: !id: 0x6f - !bound: server + !bound: client runtime_entity_id: varint flags: lu16 packet_set_scoreboard_identity: !id: 0x70 - !bound: server + !bound: client entries: ScoreboardIdentityEntries packet_set_local_player_as_initialized: !id: 0x71 - !bound: client + !bound: server runtime_entity_id: varint packet_update_soft_enum: !id: 0x72 - !bound: server + !bound: client packet_network_stack_latency: !id: 0x73 @@ -1080,7 +1353,7 @@ packet_script_custom_event: packet_spawn_particle_effect: !id: 0x76 - !bound: server + !bound: client dimension_id: u8 entity_id: zigzag64 position: vec3f @@ -1088,7 +1361,7 @@ packet_spawn_particle_effect: packet_available_entity_identifiers: !id: 0x77 - !bound: server + !bound: client nbt: nbt packet_level_sound_event_v2: @@ -1103,13 +1376,13 @@ packet_level_sound_event_v2: packet_network_chunk_publisher_update: !id: 0x79 - !bound: server + !bound: client coordinates: BlockCoordinates radius: varint packet_biome_definition_list: !id: 0x7a - !bound: server + !bound: client nbt: nbt packet_level_sound_event: @@ -1124,15 +1397,15 @@ packet_level_sound_event: packet_level_event_generic: !id: 0x7c - !bound: server + !bound: client packet_lectern_update: !id: 0x7d - !bound: server + !bound: client packet_video_stream_connect: !id: 0x7e - !bound: server + !bound: client server_uri: string frame_send_frequency: lf32 action: u8 @@ -1146,32 +1419,32 @@ packet_client_cache_status: packet_on_screen_texture_animation: !id: 0x82 - !bound: server + !bound: client packet_map_create_locked_copy: !id: 0x83 - !bound: server + !bound: client packet_structure_template_data_export_request: !id: 0x84 - !bound: server + !bound: client packet_structure_template_data_export_response: !id: 0x85 - !bound: server + !bound: client packet_update_block_properties: !id: 0x86 - !bound: server + !bound: client nbt: nbt packet_client_cache_blob_status: !id: 0x87 - !bound: server + !bound: client packet_client_cache_miss_response: !id: 0x88 - !bound: server + !bound: client packet_network_settings: !id: 0x8f @@ -1181,31 +1454,31 @@ packet_network_settings: packet_creative_content: !id: 0x91 - !bound: server + !bound: client items: ItemStacks packet_player_enchant_options: !id: 0x92 - !bound: server + !bound: client enchant_options: EnchantOptions packet_item_stack_request: !id: 0x93 - !bound: client + !bound: server requests: ItemStackRequests packet_item_stack_response: !id: 0x94 - !bound: server + !bound: client responses: ItemStackResponses packet_update_player_game_type: !id: 0x97 - !bound: client + !bound: server packet_packet_violation_warning: !id: 0x9c - !bound: client + !bound: server violation_type: zigzag32 severity: zigzag32 packet_id: zigzag32 @@ -1213,11 +1486,11 @@ packet_packet_violation_warning: packet_item_component: !id: 0xa2 - !bound: server + !bound: client entries: ItemComponentList packet_filter_text_packet: !id: 0xa3 - !bound: server + !bound: client text: string from_server: bool diff --git a/data/new/types.yaml b/data/new/types.yaml index f53f36d..528a0ba 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -104,27 +104,146 @@ vec2f: z: lf32 MetadataDictionary: []varint - key: varint + # https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/entity/Entity.php#L101 + key: varint => + 0: index + 1: health #int (minecart/boat) + 2: variant #int + 3: color #byte + 4: nametag #string + 5: owner_eid #long + 6: target_eid #long + 7: air #short + 8: potion_color #int (ARGB!) + 9: potion_ambient #byte + 10: jump_duration #long + 11: hurt_time #int (minecart/boat) + 12: hurt_direction #int (minecart/boat) + 13: paddle_time_left #float + 14: paddle_time_right #float + 15: experience_value #int (xp orb) + 16: minecart_display_block #int (id | (data << 16)) + 17: minecart_display_offset #int + 18: minecart_has_display #byte (must be 1 for minecart to show block inside) + 20: old_swell + 21: swell_dir + 22: charge_amount + 23: enderman_held_runtime_id #short + 24: entity_age #short + 26: player_flags + 27: player_index + 28: player_bed_position #block coords + 29: fireball_power_x #float + 30: fireball_power_y + 31: fireball_power_z + 32: aux_power + 33: fish_x + 34: fish_z + 35: fish_angle + 36: potion_aux_value #short + 37: lead_holder_eid #long + 38: scale + 39: interactive_tag #string + 40: npc_skin_id #string + 41: url_tag #string + 42: max_airdata_max_air + 43: mark_variant #int + 44: container_type #byte + 45: container_base_size #int + 46: container_extra_slots_per_strength #int + 47: block_target + 48: wither_invulnerable_ticks #int + 49: wither_target_1 #long + 50: wither_target_2 #long + 51: wither_target_3 #long + 52: aerial_attack + 53: boundingbox_width + 54: boundingbox_height + 55: fuse_length + 56: rider_seat_position #vector3f + 57: rider_rotation_locked #byte + 58: rider_max_rotation #float + 59: rider_min_rotation #float + 60: area_effect_cloud_radius #float + 61: area_effect_cloud_waiting #int + 62: area_effect_cloud_particle_id #int + 63: shulker_peek_id #int + 64: shulker_attach_face #byte + 65: shulker_attached #short + 66: shulker_attach_pos + 67: trading_player_eid #long + 68: trading_career + 69: has_command_block + 70: command_block_command #string + 71: command_block_last_output #string + 72: command_block_track_output #byte + 73: controlling_rider_seat_number #byte + 74: strength #int + 75: max_strength #int + 76: spell_casting_color #int + 77: limited_life + 78: armor_stand_pose_index # int + 79: ender_crystal_time_offset # int + 80: always_show_nametag # byte + 81: color_2 # byte + 82: name_author + 83: score_tag #String + 84: balloon_attached_entity # long + 85: pufferfish_size + 86: bubble_time + 87: agent + 88: sitting_amount + 89: sitting_amount_previous + 90: eating_counter + 91: flags_extended + 92: laying_amount + 93: laying_amount_previous + 94: duration + 95: spawn_time + 96: change_rate + 97: change_on_pickup + 98: pickup_count + 99: interact_text + 100: trade_tier + 101: max_trade_tier + 102: trade_experience + 103: skin_id + 104: spawning_frames + 105: command_block_tick_delay + 106: command_block_execute_on_first_tick + 107: ambient_sound_interval + 108: ambient_sound_interval_range + 109: ambient_sound_event_name + 110: fall_damage_multiplier + 111: name_raw_text + 112: can_ride_target + 113: low_tier_cured_discount + 114: high_tier_cured_discount + 115: nearby_cured_discount + 116: nearby_cured_discount_timestamp + 117: hitbox + 118: is_buoyant + 119: buoyancy_data type: varint => - 0: BYTE - 1: SHORT - 2: INT - 3: FLOAT - 4: STRING - 5: COMPOUND_TAG - 6: POS - 7: LONG - 8: VECTOR3F + 0: byte + 1: short + 2: int + 3: float + 4: string + 5: compound + 6: vec3i + 7: long + 8: vec3f value: type? - if BYTE: i8 - if SHORT: li16 - if INT: zigzag32 - if FLOAT: lf32 - if STRING: string - if COMPOUND_TAG: nbt - if POS: vec3i - if LONG: zigzag64 - if VECTOR3F: li32 + if byte: i8 + if short: li16 + if int: zigzag32 + if float: lf32 + if string: string + if compound: nbt + if vec3i: vec3i + if long: zigzag64 + if vec3f: vec3f Links: []varint ridden_entity_id: zigzag64 @@ -455,4 +574,37 @@ ItemStackResponses: []varint ItemComponentList: []varint name: string - nbt: nbt \ No newline at end of file + nbt: nbt + +CommandOrigin: + # Origin is one of the values above that specifies the origin of the command. The origin may change, + # depending on what part of the client actually called the command. The command may be issued by a + # websocket server, for example. + type: varint => + 0: player + 1: block + 2: minecart_block + 3: dev_console + 4: test + 5: automation_player + 6: client_automation + 7: dedicated_server + 8: entity + 9: virtual + 10: game_argument + 11: entity_server + # UUID is the UUID of the command called. This UUID is a bit odd as it is not specified by the server. It + # is not clear what exactly this UUID is meant to identify, but it is unique for each command called. + uuid: uuid + # RequestID is an ID that identifies the request of the client. The server should send a CommandOrigin + # with the same request ID to ensure it can be matched with the request by the caller of the command. + # This is especially important for websocket servers and it seems that this field is only non-empty for + # these websocket servers. + request_id: string + # PlayerUniqueID is an ID that identifies the player, the same as the one found in the AdventureSettings + # packet. Filling it out with 0 seems to work. + # PlayerUniqueID is only written if Origin is CommandOriginDevConsole or CommandOriginTest. + player_entity_id: type? + if dev_console or test: + player_entity_id: zigzag64 + diff --git a/data/newproto.json b/data/newproto.json index f2a320f..7a6f93e 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -433,7 +433,132 @@ [ { "name": "key", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "index", + "1": "health", + "2": "variant", + "3": "color", + "4": "nametag", + "5": "owner_eid", + "6": "target_eid", + "7": "air", + "8": "potion_color", + "9": "potion_ambient", + "10": "jump_duration", + "11": "hurt_time", + "12": "hurt_direction", + "13": "paddle_time_left", + "14": "paddle_time_right", + "15": "experience_value", + "16": "minecart_display_block", + "17": "minecart_display_offset", + "18": "minecart_has_display", + "20": "old_swell", + "21": "swell_dir", + "22": "charge_amount", + "23": "enderman_held_runtime_id", + "24": "entity_age", + "26": "player_flags", + "27": "player_index", + "28": "player_bed_position", + "29": "fireball_power_x", + "30": "fireball_power_y", + "31": "fireball_power_z", + "32": "aux_power", + "33": "fish_x", + "34": "fish_z", + "35": "fish_angle", + "36": "potion_aux_value", + "37": "lead_holder_eid", + "38": "scale", + "39": "interactive_tag", + "40": "npc_skin_id", + "41": "url_tag", + "42": "max_airdata_max_air", + "43": "mark_variant", + "44": "container_type", + "45": "container_base_size", + "46": "container_extra_slots_per_strength", + "47": "block_target", + "48": "wither_invulnerable_ticks", + "49": "wither_target_1", + "50": "wither_target_2", + "51": "wither_target_3", + "52": "aerial_attack", + "53": "boundingbox_width", + "54": "boundingbox_height", + "55": "fuse_length", + "56": "rider_seat_position", + "57": "rider_rotation_locked", + "58": "rider_max_rotation", + "59": "rider_min_rotation", + "60": "area_effect_cloud_radius", + "61": "area_effect_cloud_waiting", + "62": "area_effect_cloud_particle_id", + "63": "shulker_peek_id", + "64": "shulker_attach_face", + "65": "shulker_attached", + "66": "shulker_attach_pos", + "67": "trading_player_eid", + "68": "trading_career", + "69": "has_command_block", + "70": "command_block_command", + "71": "command_block_last_output", + "72": "command_block_track_output", + "73": "controlling_rider_seat_number", + "74": "strength", + "75": "max_strength", + "76": "spell_casting_color", + "77": "limited_life", + "78": "armor_stand_pose_index", + "79": "ender_crystal_time_offset", + "80": "always_show_nametag", + "81": "color_2", + "82": "name_author", + "83": "score_tag", + "84": "balloon_attached_entity", + "85": "pufferfish_size", + "86": "bubble_time", + "87": "agent", + "88": "sitting_amount", + "89": "sitting_amount_previous", + "90": "eating_counter", + "91": "flags_extended", + "92": "laying_amount", + "93": "laying_amount_previous", + "94": "duration", + "95": "spawn_time", + "96": "change_rate", + "97": "change_on_pickup", + "98": "pickup_count", + "99": "interact_text", + "100": "trade_tier", + "101": "max_trade_tier", + "102": "trade_experience", + "103": "skin_id", + "104": "spawning_frames", + "105": "command_block_tick_delay", + "106": "command_block_execute_on_first_tick", + "107": "ambient_sound_interval", + "108": "ambient_sound_interval_range", + "109": "ambient_sound_event_name", + "110": "fall_damage_multiplier", + "111": "name_raw_text", + "112": "can_ride_target", + "113": "low_tier_cured_discount", + "114": "high_tier_cured_discount", + "115": "nearby_cured_discount", + "116": "nearby_cured_discount_timestamp", + "117": "hitbox", + "118": "is_buoyant", + "119": "buoyancy_data" + } + } + ] }, { "name": "type", @@ -442,15 +567,15 @@ { "type": "varint", "mappings": { - "0": "BYTE", - "1": "SHORT", - "2": "INT", - "3": "FLOAT", - "4": "STRING", - "5": "COMPOUND_TAG", - "6": "POS", - "7": "LONG", - "8": "VECTOR3F" + "0": "byte", + "1": "short", + "2": "int", + "3": "float", + "4": "string", + "5": "compound", + "6": "vec3i", + "7": "long", + "8": "vec3f" } } ] @@ -462,15 +587,15 @@ { "compareTo": "type", "fields": { - "BYTE": "i8", - "SHORT": "li16", - "INT": "zigzag32", - "FLOAT": "lf32", - "STRING": "string", - "COMPOUND_TAG": "nbt", - "POS": "vec3i", - "LONG": "zigzag64", - "VECTOR3F": "li32" + "byte": "i8", + "short": "li16", + "int": "zigzag32", + "float": "lf32", + "string": "string", + "compound": "nbt", + "vec3i": "vec3i", + "long": "zigzag64", + "vec3f": "vec3f" }, "default": "void" } @@ -2008,6 +2133,72 @@ ] } ], + "CommandOrigin": [ + "container", + [ + { + "name": "type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "player", + "1": "block", + "2": "minecart_block", + "3": "dev_console", + "4": "test", + "5": "automation_player", + "6": "client_automation", + "7": "dedicated_server", + "8": "entity", + "9": "virtual", + "10": "game_argument", + "11": "entity_server" + } + } + ] + }, + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "request_id", + "type": "string" + }, + { + "name": "player_entity_id", + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "dev_console": [ + "container", + [ + { + "name": "player_entity_id", + "type": "zigzag64" + } + ] + ], + "test": [ + "container", + [ + { + "name": "player_entity_id", + "type": "zigzag64" + } + ] + ] + }, + "default": "void" + } + ] + } + ] + ], "mcpe_packet": [ "container", [ @@ -2500,7 +2691,7 @@ "container", [ { - "name": "sourceName", + "name": "source_name", "type": "string" } ] @@ -2509,7 +2700,7 @@ "container", [ { - "name": "sourceName", + "name": "source_name", "type": "string" } ] @@ -2518,7 +2709,7 @@ "container", [ { - "name": "sourceName", + "name": "source_name", "type": "string" } ] @@ -3300,8 +3491,76 @@ "container", [ { - "name": "event_id", - "type": "zigzag32" + "name": "event", + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "1000": "sound_click", + "1001": "sound_click_fail", + "1002": "sound_shoot", + "1003": "sound_door", + "1004": "sound_fizz", + "1005": "sound_ignite", + "1007": "sound_ghast", + "1008": "sound_ghast_shoot", + "1009": "sound_blaze_shoot", + "1010": "sound_door_bump", + "1012": "sound_door_crash", + "1018": "sound_enderman_teleport", + "1020": "sound_anvil_break", + "1021": "sound_anvil_use", + "1022": "sound_anvil_fall", + "1030": "sound_pop", + "1032": "sound_portal", + "1040": "sound_itemframe_add_item", + "1041": "sound_itemframe_remove", + "1042": "sound_itemframe_place", + "1043": "sound_itemframe_remove_item", + "1044": "sound_itemframe_rotate_item", + "1050": "sound_camera", + "1051": "sound_orb", + "1052": "sound_totem", + "1060": "sound_armor_stand_break", + "1061": "sound_armor_stand_hit", + "1062": "sound_armor_stand_fall", + "1063": "sound_armor_stand_place", + "2000": "particle_shoot", + "2001": "particle_destroy", + "2002": "particle_splash", + "2003": "particle_eye_despawn", + "2004": "particle_spawn", + "2006": "guardian_curse", + "2008": "particle_block_force_field", + "2009": "particle_projectile_hit", + "2013": "particle_enderman_teleport", + "2014": "particle_punch_block", + "3001": "start_rain", + "3002": "start_thunder", + "3003": "stop_rain", + "3004": "stop_thunder", + "3005": "pause_game", + "3006": "pause_game_no_screen", + "3007": "set_game_speed", + "3500": "redstone_trigger", + "3501": "cauldron_explode", + "3502": "cauldron_dye_armor", + "3503": "cauldron_clean_armor", + "3504": "cauldron_fill_potion", + "3505": "cauldron_take_potion", + "3506": "cauldron_fill_water", + "3507": "cauldron_take_water", + "3508": "cauldron_add_dye", + "3509": "cauldron_clean_banner", + "3600": "block_start_break", + "3601": "block_stop_break", + "4000": "set_data", + "9800": "players_sleeping", + "16384": "add_particle_mask" + } + } + ] }, { "name": "position", @@ -3317,15 +3576,24 @@ "container", [ { - "name": "coordinates", + "name": "position", "type": "BlockCoordinates" }, { - "name": "case_1", - "type": "zigzag32" + "name": "type", + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "sound", + "1": "change_state" + } + } + ] }, { - "name": "case_2", + "name": "data", "type": "zigzag32" } ] @@ -3339,7 +3607,68 @@ }, { "name": "event_id", - "type": "u8" + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "1": "jump", + "2": "hurt_animation", + "3": "death_animation", + "4": "arm_swing", + "5": "stop_attack", + "6": "tame_fail", + "7": "tame_success", + "8": "shake_wet", + "9": "use_item", + "10": "eat_grass_animation", + "11": "fish_hook_bubble", + "12": "fish_hook_position", + "13": "fish_hook_hook", + "14": "fish_hook_tease", + "15": "squid_ink_cloud", + "16": "zombie_villager_cure", + "18": "respawn", + "19": "iron_golem_offer_flower", + "20": "iron_golem_withdraw_flower", + "21": "love_particles", + "22": "villager_angry", + "23": "villager_happy", + "24": "witch_spell_particles", + "25": "firework_particles", + "26": "in_love_particles", + "27": "silverfish_spawn_animation", + "28": "guardian_attack", + "29": "witch_drink_potion", + "30": "witch_throw_potion", + "31": "minecart_tnt_prime_fuse", + "32": "creeper_prime_fuse", + "33": "air_supply_expired", + "34": "player_add_xp_levels", + "35": "elder_guardian_curse", + "36": "agent_arm_swing", + "37": "ender_dragon_death", + "38": "dust_particles", + "39": "arrow_shake", + "57": "eating_item", + "60": "baby_animal_feed", + "61": "death_smoke_cloud", + "62": "complete_trade", + "63": "remove_leash", + "65": "consume_totem", + "66": "player_check_treasure_hunter_achievement", + "67": "entity_spawn", + "68": "dragon_puke", + "69": "item_entity_merge", + "70": "start_swim", + "71": "balloon_pop", + "72": "treasure_hunt", + "73": "agent_summon", + "74": "charged_crossbow", + "75": "fall" + } + } + ] }, { "name": "data", @@ -3511,11 +3840,44 @@ "type": "varint" }, { - "name": "action_id", - "type": "zigzag32" + "name": "action", + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "start_break", + "1": "abort_break", + "2": "stop_break", + "3": "get_updated_block", + "4": "drop_item", + "5": "start_sleeping", + "6": "stop_sleeping", + "7": "respawn", + "8": "jump", + "9": "start_sprint", + "10": "stop_sprint", + "11": "start_sneak", + "12": "stop_sneak", + "13": "creative_player_destroy_block", + "14": "dimension_change_ack", + "15": "start_glide", + "16": "stop_glide", + "17": "build_denied", + "18": "continue_break", + "19": "change_skin", + "20": "set_enchatnment_seed", + "21": "swimming", + "22": "stop_swimming", + "23": "start_spin_attack", + "24": "stop_spin_attack", + "25": "ineract_block" + } + } + ] }, { - "name": "coordinates", + "name": "position", "type": "BlockCoordinates" }, { @@ -3837,7 +4199,7 @@ "container", [ { - "name": "coordinates", + "name": "position", "type": "BlockCoordinates" }, { @@ -3871,11 +4233,11 @@ "container", [ { - "name": "chunk_x", + "name": "x", "type": "zigzag32" }, { - "name": "chunk_z", + "name": "z", "type": "zigzag32" }, { @@ -4038,8 +4400,106 @@ "type": "zigzag64" }, { - "name": "event_type", - "type": "varint" + "name": "type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "show_bar", + "1": "register_player", + "2": "hide_bar", + "3": "unregister_player", + "4": "set_bar_progress", + "5": "set_bar_title", + "6": "update_properties", + "7": "texture" + } + } + ] + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "register_player": [ + "container", + [ + { + "name": "player_id", + "type": "zigzag64" + } + ] + ], + "unregister_player": [ + "container", + [ + { + "name": "player_id", + "type": "zigzag64" + } + ] + ], + "show": [ + "container", + [ + { + "name": "title", + "type": "string" + }, + { + "name": "bar_progress", + "type": "lf32" + } + ] + ], + "update_properties": [ + "container", + [ + { + "name": "darkness_factor", + "type": "li16" + } + ] + ], + "texture": [ + "container", + [ + { + "name": "color", + "type": "varint" + }, + { + "name": "overlay", + "type": "varint" + } + ] + ], + "set_bar_progress": [ + "container", + [ + { + "name": "bar_progress", + "type": "lf32" + } + ] + ], + "set_bar_title": [ + "container", + [ + { + "name": "title", + "type": "string" + } + ] + ] + }, + "default": "void" + } + ] } ] ], @@ -4068,19 +4528,11 @@ "type": "string" }, { - "name": "command_type", - "type": "varint" + "name": "origin", + "type": "CommandOrigin" }, { - "name": "unknown_uuid", - "type": "uuid" - }, - { - "name": "request_id", - "type": "string" - }, - { - "name": "unknown", + "name": "interval", "type": "bool" } ] @@ -4096,7 +4548,52 @@ ], "packet_command_output": [ "container", - [] + [ + { + "name": "origin", + "type": "CommandOrigin" + }, + { + "name": "output_type", + "type": "i8" + }, + { + "name": "success_count", + "type": "varint" + }, + { + "name": "output", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "success", + "type": "bool" + }, + { + "name": "message_id", + "type": "string" + }, + { + "name": "paramaters", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + } + ] + ] + } + ] + } + ] ], "packet_update_trade": [ "container", @@ -4386,7 +4883,113 @@ ], "packet_book_edit": [ "container", - [] + [ + { + "name": "type", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "replace_page", + "1": "add_page", + "2": "delete_page", + "3": "swap_pages", + "4": "sign" + } + } + ] + }, + { + "name": "slot", + "type": "u8" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "type", + "fields": { + "replace_page": [ + "container", + [ + { + "name": "page_number", + "type": "u8" + }, + { + "name": "text", + "type": "string" + }, + { + "name": "photo_name", + "type": "string" + } + ] + ], + "add_page": [ + "container", + [ + { + "name": "page_number", + "type": "u8" + }, + { + "name": "text", + "type": "string" + }, + { + "name": "photo_name", + "type": "string" + } + ] + ], + "delete_page": [ + "container", + [ + { + "name": "page_number", + "type": "u8" + } + ] + ], + "swap_pages": [ + "container", + [ + { + "name": "page1", + "type": "u8" + }, + { + "name": "page2", + "type": "u8" + } + ] + ], + "sign": [ + "container", + [ + { + "name": "title", + "type": "string" + }, + { + "name": "author", + "type": "string" + }, + { + "name": "xuid", + "type": "string" + } + ] + ] + }, + "default": "void" + } + ] + } + ] ], "packet_npc_request": [ "container", From b6f8fff01e3f35ff9f16a85790279feded9501fc Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 16 Feb 2021 23:31:19 -0500 Subject: [PATCH 089/106] disable some logging --- src/auth/chains.js | 6 +---- src/auth/constants.js | 3 +-- src/auth/encryption.js | 11 ++++----- src/client.js | 10 ++++---- src/connection.js | 3 ++- src/transforms/encryption.js | 45 +++++++++++------------------------- 6 files changed, 28 insertions(+), 50 deletions(-) diff --git a/src/auth/chains.js b/src/auth/chains.js index 5208b9f..5083a03 100644 --- a/src/auth/chains.js +++ b/src/auth/chains.js @@ -1,11 +1,7 @@ const JWT = require('jsonwebtoken') const constants = require('./constants') -const fs = require('fs') -const { decode } = require('jwt-simple') -// import jwt from 'jwt-simple'; -// const jwt = require('jwt-simple') -// 💗 web archive +// Refer to the docs: // https://web.archive.org/web/20180917171505if_/https://confluence.yawk.at/display/PEPROTOCOL/Game+Packets#GamePackets-Login function mcPubKeyToPem(mcPubKeyBuffer) { diff --git a/src/auth/constants.js b/src/auth/constants.js index 3d04d67..2ffbe1d 100644 --- a/src/auth/constants.js +++ b/src/auth/constants.js @@ -1,4 +1,3 @@ module.exports = { - PUBLIC_KEY: 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V', - secret_key: 'nwOn35gXIfEfgZPIrjNJ+cAxODD/XIpjs3YG7FO1pmwbzpRSlac', + PUBLIC_KEY: 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V' } diff --git a/src/auth/encryption.js b/src/auth/encryption.js index 956eede..8402497 100644 --- a/src/auth/encryption.js +++ b/src/auth/encryption.js @@ -31,11 +31,10 @@ function Encrypt(client, server, options) { const secretHash = crypto.createHash('sha256') secretHash.update(SALT) secretHash.update(client.sharedSecret) - console.log('---- SHARED SECRET', client.sharedSecret) - + console.log('[encrypt] Shared secret', client.sharedSecret) client.secretKeyBytes = secretHash.digest() - console.log('Hash', client.secretKeyBytes) + console.log('[encrypt] Shared hash', client.secretKeyBytes) const x509 = writeX509PublicKey(alice.getPublicKey()) const token = JWT.sign({ salt: toBase64(SALT), @@ -54,7 +53,7 @@ function Encrypt(client, server, options) { } function startServerboundEncryption(token) { - console.warn('Starting serverbound encryption', token) + console.warn('[encrypt] Starting serverbound encryption', token) const jwt = token?.token if (!jwt) { // TODO: allow connecting to servers without encryption @@ -67,7 +66,7 @@ function Encrypt(client, server, options) { const body = JSON.parse(String(payload)) const serverPublicKey = readX509PublicKey(head.x5u) client.sharedSecret = alice.computeSecret(serverPublicKey) - console.log('------ SHARED SECRET', client.sharedSecret) + console.log('[encrypt] Shared secret', client.sharedSecret) const salt = Buffer.from(body.salt, 'base64') @@ -76,7 +75,7 @@ function Encrypt(client, server, options) { secretHash.update(client.sharedSecret) client.secretKeyBytes = secretHash.digest() - console.log('Hash', client.secretKeyBytes) + console.log('[encrypt] Shared hash', client.secretKeyBytes) const initial = client.secretKeyBytes.slice(0, 16) client.startEncryption(initial) diff --git a/src/client.js b/src/client.js index acba7a6..8d21ead 100644 --- a/src/client.js +++ b/src/client.js @@ -34,7 +34,7 @@ class Client extends Connection { } onEncapsulated = (encapsulated, inetAddr) => { - log(inetAddr.address, ': Encapsulated', encapsulated) + // log(inetAddr.address, ': Encapsulated', encapsulated) const buffer = encapsulated.buffer this.handle(buffer) } @@ -102,9 +102,11 @@ class Client extends Connection { } readPacket(packet) { - console.log('packet', packet) + // console.log('packet', packet) const des = this.deserializer.parsePacketBuffer(packet) - console.info('->', des) + console.log('->',des) + const pakData = { name: des.data.name, params: des.data.params } + // console.info('->', JSON.stringify(pakData, (k,v) => typeof v == 'bigint' ? v.toString() : v)) switch (des.data.name) { case 'server_to_client_handshake': this.emit('client.server_handshake', des.data.params) @@ -118,7 +120,7 @@ class Client extends Connection { case 'start_game': fs.writeFileSync('start_game.json', JSON.stringify(des.data.params, (k,v) => typeof v == 'bigint' ? v.toString() : v)) default: - console.log('Sending to listeners') + // console.log('Sending to listeners') } this.emit(des.data.name, des.data.params) diff --git a/src/connection.js b/src/connection.js index e6eef5a..f266ebf 100644 --- a/src/connection.js +++ b/src/connection.js @@ -87,7 +87,7 @@ class Connection extends EventEmitter { handle(buffer) { // handle encapsulated if (buffer[0] == 0xfe) { // wrapper if (this.encryptionEnabled) { - // console.log('READING ENCRYPTED PACKET', buffer) + console.log('Reading encrypted packet', buffer) this.decrypt(buffer.slice(1)) } else { const stream = new BinaryStream(buffer) @@ -100,6 +100,7 @@ class Connection extends EventEmitter { } } } + console.log('[client] procesed ', buffer) } } diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index f9cf293..26896c4 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -126,47 +126,28 @@ function createDecryptor(client, iv) { // console.log(computedCheckSum2, computedCheckSum3) console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') client.receiveCounter++ - // if (checksum.toString("hex") == computedCheckSum.toString("hex")) { - this.push(packet) - // console.log('🔵 Decriphered', checksum) - // const inflated = Zlib.inflateRawSync(chunk, { - // chunkSize: 1024 * 1024 * 2 - // }) - // console.log('🔵 Inflated') - // client.onDecryptedPacket(inflated) - // } else { - // // console.log('🔴 Not OK') - // throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) - // } - cb() - } - }) - - const inflator = new Transform({ - transform(chunk, enc, cb) { - console.log('🔵 Inflating') const inflated = Zlib.inflateRawSync(chunk, { chunkSize: 1024 * 1024 * 2 }) - console.log('🔵 Inflated') - this.push(inflated) - cb() - // Zlib.inflateRaw(chunk, { chunkSize: 1024 * 1024 * 2 }, (err, buf) => { - // console.log('🔵 INF') - // if (err) throw err - // this.push(buf) - // cb() - // }) + if (checksum.toString("hex") == computedCheckSum.toString("hex")) { + this.push(packet) + console.log('🔵 Decriphered', checksum) + + console.log('🔵 Inflated') + client.onDecryptedPacket(inflated) + } else { + console.log(`🔴 Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) + client.onDecryptedPacket(inflated) // allow it anyway + // throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) + } + cb() } }) + client.decipher.pipe(verifyChecksum) - .pipe(inflator) - // .pipe(Zlib.createInflateRaw({ chunkSize: 1024 * 1024 * 2 })) - .on('data', (...args) => client.onDecryptedPacket(...args)) - // .on('end', () => console.log('Decryptor: finish pipeline')) // Not sure why, but sending two packets to the decryption pipe before // the other is completed breaks the checksum check. From 4e3c5f8e3139bca8b5c3fc6660c077379ad9ce8f Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 16 Feb 2021 23:32:57 -0500 Subject: [PATCH 090/106] implement command packet --- data/new/compile.js | 2 +- data/new/proto.yml | 94 ++++++++--- data/newproto.json | 238 +++++++++++++++++++++++++++- src/datatypes/compiler-minecraft.js | 113 +++++++++---- test/serialization.js | 55 ++++++- 5 files changed, 445 insertions(+), 57 deletions(-) diff --git a/data/new/compile.js b/data/new/compile.js index 6df30d9..7ffca0e 100644 --- a/data/new/compile.js +++ b/data/new/compile.js @@ -18,9 +18,9 @@ fs.unlinkSync('./protocol.json') //remove temp file function createProtocol() { const compiler = new ProtoDefCompiler() const protocol = require('../newproto.json').types - compiler.addTypesToCompile(protocol) compiler.addTypes(require('../../src/datatypes/compiler-minecraft')) compiler.addTypes(require('prismarine-nbt/compiler-zigzag')) + compiler.addTypesToCompile(protocol) fs.writeFileSync('../read.js', 'module.exports = ' + compiler.readCompiler.generate()) fs.writeFileSync('../write.js', 'module.exports = ' + compiler.writeCompiler.generate()) diff --git a/data/new/proto.yml b/data/new/proto.yml index 9727a76..b24839e 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -1013,29 +1013,83 @@ packet_show_credits: runtime_entity_id: varint status: zigzag32 +# This packet sends a list of commands to the client. Commands can have +# arguments, and some of those arguments can have 'enum' values, which are a list of possible +# values for the argument. The serialization is rather complex and involves palettes like chunks. +## In bedrock-protocol, listen to on('client.commands') for a simpler representation packet_available_commands: !id: 0x4c !bound: client - # enum_values: string[]varint - # suffixes: string[]varint - # enums: []varint - # name: string - # # The length of the array below - # values_len: varint - # # Not read from stream: instead calculated from the `values_len` field - # # If the values_len < 0xff => byte - # # If the values_len < 0xffff => short - # # If the values_len < 0xffffff => int - # enum_typex: u8 => - # 0: byte - # 1: short - # 2: int - # valuex: []varint - # # S: bool - # ix: ../enum_typex? - # if byte: u8 - # if short: lu16 - # if int: lu32 + # Here all the enum values for all of the possible commands are stored to one array palette + enum_values: string[]varint + # Integer paramaters may sometimes have a prefix, such as the XP command: + # /xp [player: target] <- here, the xp command gives experience points + # /xp L [player: target] <- here, the xp command gives experience levels + # This is the palette of suffixes + suffixes: string[]varint + # The list of enum objects + enums: []varint + # The name of the enum + name: string + # The length of the array below + values_len: varint + # Not read from stream: instead calculated from the `values_len` field + # If the values_len < 0xff => byte + # If the values_len < 0xffff => short + # If the values_len < 0xffffff => int + _enum_type: '["enum_size_based_on_values_len"]' + # The values in the enum + values: []$values_len + # The indexes to value in the palette + _: ../_enum_type? + if byte: u8 + if short: lu16 + if int: lu32 + command_data: []varint + name: string + description: string + flags: u8 + permission_level: u8 + alias: li32 + # The list of overload paramaters for this command + overloads: []varint + # Each of the paramaters gets an array of posible overloads + _: []varint + # The name of the paramater shown to the user (the `amount` in `/xp `) + paramater_name: string + # Bitfield: If FLAG_ENUM is set, the lower 16 bits act as an index to enums array + # If FLAG_SUFFIX is set, the lower 16 bits act as an index to the suffix palette + # and the client interperts the type as just `int` as in the example above + paramater_type: li32 + # Is this paramater required? + optional: bool + # Additinal options for this command (thanks macroshaft...) + flags: CommandFlags + # There are two types of enums: static enums which cannot be changed after sending AvaliableCommands, + # (unless you resend the whole packet) and 'soft' or 'dynamic' enums like below which is an array + # that can be updated with the UpdateSoftEnum packet + dynamic_enums: []varint + name: string + values: string[]varint + enum_constraints: []varint + value_index: li32 + enum_index: li32 + constraints: []varint + constraint: u8 => + 0: cheats_enabled + +# ParamOptionCollapseEnum specifies if the enum (only if the Type is actually an enum type. If not, +# setting this to true has no effect) should be collapsed. This means that the options of the enum are +# never shown in the actual usage of the command, but only as auto-completion, like it automatically does +# with enums that have a big amount of options. To illustrate, it can make +# <$Name: bool>. +CommandFlags: [ "bitfield", [ + { "name": "unused", "size": 1, "signed": false }, + { "name": "collapse_enum", "size": 1, "signed": false }, + { "name": "has_semantic_constraint", "size": 1, "signed": false } +]] + +# enum_size_based_on_values_len: native # CommandRequest is sent by the client to request the execution of a server-side command. Although some # servers support sending commands using the Text packet, this packet is guaranteed to have the correct diff --git a/data/newproto.json b/data/newproto.json index 7a6f93e..ead075d 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -4518,7 +4518,223 @@ ], "packet_available_commands": [ "container", - [] + [ + { + "name": "enum_values", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + }, + { + "name": "suffixes", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + }, + { + "name": "enums", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "values_len", + "type": "varint" + }, + { + "name": "_enum_type", + "type": [ + "enum_size_based_on_values_len" + ] + }, + { + "name": "values", + "type": [ + "array", + { + "count": "values_len", + "type": [ + "switch", + { + "compareTo": "../_enum_type", + "fields": { + "byte": "u8", + "short": "lu16", + "int": "lu32" + }, + "default": "void" + } + ] + } + ] + } + ] + ] + } + ] + }, + { + "name": "command_data", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "description", + "type": "string" + }, + { + "name": "flags", + "type": "u8" + }, + { + "name": "permission_level", + "type": "u8" + }, + { + "name": "alias", + "type": "li32" + }, + { + "name": "overloads", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "paramater_name", + "type": "string" + }, + { + "name": "paramater_type", + "type": "li32" + }, + { + "name": "optional", + "type": "bool" + }, + { + "name": "flags", + "type": "CommandFlags" + } + ] + ] + } + ] + } + ] + } + ] + ] + } + ] + }, + { + "name": "dynamic_enums", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + }, + { + "name": "values", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + } + ] + ] + } + ] + }, + { + "name": "enum_constraints", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "value_index", + "type": "li32" + }, + { + "name": "enum_index", + "type": "li32" + }, + { + "name": "constraints", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "constraint", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "cheats_enabled" + } + } + ] + } + ] + ] + } + ] + } + ] + ] + } + ] + } + ] ], "packet_command_request": [ "container", @@ -5546,6 +5762,26 @@ { "countType": "li32" } + ], + "CommandFlags": [ + "bitfield", + [ + { + "name": "unused", + "size": 1, + "signed": false + }, + { + "name": "collapse_enum", + "size": 1, + "signed": false + }, + { + "name": "has_semantic_constraint", + "size": 1, + "signed": false + } + ] ] } } \ No newline at end of file diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js index 7dc6ea4..7130749 100644 --- a/src/datatypes/compiler-minecraft.js +++ b/src/datatypes/compiler-minecraft.js @@ -1,39 +1,84 @@ const UUID = require('uuid-1345') const minecraft = require('./minecraft') -module.exports = { - Read: { - uuid: ['native', (buffer, offset) => { - return { - value: UUID.stringify(buffer.slice(offset, 16 + offset)), - size: 16 - } - }], - restBuffer: ['native', (buffer, offset) => { - return { - value: buffer.slice(offset), - size: buffer.length - offset - } - }], - nbt: ['native', minecraft.nbt[0]] - }, - Write: { - uuid: ['native', (value, buffer, offset) => { - const buf = UUID.parse(value) - buf.copy(buffer, offset) - return offset + 16 - }], - restBuffer: ['native', (value, buffer, offset) => { - value.copy(buffer, offset) - return offset + value.length - }], - nbt: ['native', minecraft.nbt[1]] - }, - SizeOf: { - uuid: ['native', 16], - restBuffer: ['native', (value) => { - return value.length - }], - nbt: ['native', minecraft.nbt[2]] +const Read = {} +const Write = {} +const SizeOf = {} + +/** + * UUIDs + */ +Read.uuid = ['native', (buffer, offset) => { + return { + value: UUID.stringify(buffer.slice(offset, 16 + offset)), + size: 16 } +}] +Write.uuid = ['native', (value, buffer, offset) => { + const buf = UUID.parse(value) + buf.copy(buffer, offset) + return offset + 16 +}] +SizeOf.uuid = ['native', 16] + +/** + * Rest of buffer + */ +Read.restBuffer = ['native', (buffer, offset) => { + return { + value: buffer.slice(offset), + size: buffer.length - offset + } +}] +Write.restBuffer = ['native', (value, buffer, offset) => { + value.copy(buffer, offset) + return offset + value.length +}] +SizeOf.restBuffer = ['native', (value) => { + return value.length +}] + +/** + * NBT + */ +Read.nbt = ['native', minecraft.nbt[0]] +Write.nbt = ['native', minecraft.nbt[1]] +SizeOf.nbt = ['native', minecraft.nbt[2]] + +/** + * Command Packet + * - used for determining the size of the following enum + */ +Read.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { + return compiler.wrapCode(js(() => { + if (values_len <= 0xff) return { value: 'byte', size: 0 } + if (values_len <= 0xffff) return { value: 'short', size: 0 } + if (values_len <= 0xffffff) return { value: 'int', size: 0 } + })) +}] +Write.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { + return str(() => { + if (value.values_len <= 0xff) _enum_type = 'byte' + else if (value.values_len <= 0xffff) _enum_type = 'short' + else if (value.values_len <= 0xffffff) _enum_type = 'int' + return offset + }) +}] +SizeOf.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { + return str(() => { + if (value.values_len <= 0xff) _enum_type = 'byte' + else if (value.values_len <= 0xffff) _enum_type = 'short' + else if (value.values_len <= 0xffffff) _enum_type = 'int' + return 0 + }) +}] + +function js(fn) { + return fn.toString().split('\n').slice(1, -1).join('\n').trim() } + +function str(fn) { + return fn.toString() + ')();(()=>{}' +} + +module.exports = { Read, Write, SizeOf } \ No newline at end of file diff --git a/test/serialization.js b/test/serialization.js index c7588ca..a15441f 100644 --- a/test/serialization.js +++ b/test/serialization.js @@ -110,8 +110,61 @@ function test() { console.log(JSON.stringify(d)) } + async function availableCommands() { + var avaliable = { + enum_values: ['true', 'false'], + suffixes: ['L'], + enums: [ + { + name: 'Boolean', + values_len: 2, + values: [0, 1] + } + ], + command_data: [ + { + name: 'give', + description: 'Gives you items', + flags: 0, + permission_level: 0, + alias: -1, + overloads: [ + [ + { paramater_name: 'player id', paramater_type: 2, optional: false, flags: { "collapse_enum": 1 } } + ], + [ + { paramater_name: 'item id', paramater_type: 2, optional: false, flags: 0 }, + ] + ], + }, + { + name: 'xp', + description: 'Gives you xp', + flags: 0, permission_level: 0, alias: -1, + overloads: [ + [{ paramater_name: 'player id', paramater_type: 2, optional: false, flags: 0 }] + ] + } + ], + enum_constraints: [ + { + value_index: 2, enum_index: 3, constraints: [ + { constraint: 'cheats_enabled' } + ] + }, + ], + dynamic_enums: [ + { name: 'Hello', values: ['yolo', 'yee'] } + ] + } - creativeTst() + var s = write('available_commands', avaliable) + var d = read(s).data.params + console.log(JSON.stringify(d, null, 2)) + } + + // creativeTst() + availableCommands() } if (!module.parent) { From fe05a3d64546ff97ecb8d0ef8bd7bddaee2ad5dc Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 18 Feb 2021 01:41:00 -0500 Subject: [PATCH 091/106] fix decryption --- src/client/auth.js | 1 - src/transforms/encryption.js | 122 +++++++++++++++++++++++------------ 2 files changed, 79 insertions(+), 44 deletions(-) diff --git a/src/client/auth.js b/src/client/auth.js index bb83897..5502b43 100644 --- a/src/client/auth.js +++ b/src/client/auth.js @@ -36,7 +36,6 @@ async function postAuthenticate (client, options, chains) { client.username = profile.name client.accessToken = chains client.emit('session', profile) - client.connect() } /** diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index 26896c4..f911fb2 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -61,7 +61,7 @@ function computeCheckSum(packetPlaintext, sendCounter, secretKeyBytes) { digest.update(packetPlaintext); digest.update(secretKeyBytes); let hash = digest.digest(); - + // console.log('Hash', hash.toString('hex')) return hash.slice(0, 8); } @@ -117,54 +117,90 @@ function createDecryptor(client, iv) { client.decipher = createDecipher(client.secretKeyBytes, iv) client.receiveCounter = client.receiveCounter || 0n - const verifyChecksum = new Transform({ // verify checksum - transform(chunk, encoding, cb) { - console.log('Decryptor: checking checksum', client.receiveCounter, chunk) - const packet = chunk.slice(0, chunk.length - 8); - const checksum = chunk.slice(chunk.length - 8); - const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) - // console.log(computedCheckSum2, computedCheckSum3) - console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') - client.receiveCounter++ + function verify(chunk) { + console.log('Decryptor: checking checksum', client.receiveCounter, chunk) - const inflated = Zlib.inflateRawSync(chunk, { - chunkSize: 1024 * 1024 * 2 - }) + // First try to zlib decompress, then see how much bytes get read + const { buffer, engine } = Zlib.inflateRawSync(chunk, { + chunkSize: 1024 * 1024 * 2, + info: true + }) - if (checksum.toString("hex") == computedCheckSum.toString("hex")) { - this.push(packet) - console.log('🔵 Decriphered', checksum) - - console.log('🔵 Inflated') - client.onDecryptedPacket(inflated) - } else { - console.log(`🔴 Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) - client.onDecryptedPacket(inflated) // allow it anyway - // throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) - } - cb() + // Holds how much bytes we read, also where the checksum (should) start + const inflatedLen = engine.bytesRead + // It appears that mc sends extra bytes past the checksum. I don't think this is a raknet + // issue (as we are able to decipher properly, zlib works and should also have a checksum) so + // there needs to be more investigation done. If you know what's wrong here, please make an issue :) + const extraneousLen = chunk.length - inflatedLen - 8 + if (extraneousLen > 0) { // Extra bytes + // Info for debugging, todo: use debug() + const extraneousBytes = chunk.slice(inflatedLen + 8) + console.debug('Extraneous bytes!', extraneousLen, extraneousBytes.toString('hex')) + } else if (extraneousLen < 0) { + // No checksum or decompression failed + console.warn('Failed to decrypt', chunk.toString('hex')) + throw new Error('Decrypted packet is missing checksum') } + + console.log('Inflated', inflatedLen, chunk.length, extraneousLen, chunk.toString('hex')) + + const packet = chunk.slice(0, inflatedLen); + const checksum = chunk.slice(inflatedLen, inflatedLen + 8); + console.log("packet, checksum", packet, checksum) + const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) + // // console.log(computedCheckSum2, computedCheckSum3) + // console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') + client.receiveCounter++ + + + // // const infLen = Zlib.inflateRawSync(chunk, { + // // chunkSize: 1024 * 1024 * 2, + // // info: true + // // }) + // console.log('infLen', engine) + + // const cReadLen = engine.bytesRead + // const diff = chunk.length - cReadLen + // const newPacket = chunk.slice(0, cReadLen) + // const newExpectedSum = chunk.slice(cReadLen, cReadLen+8) + // const newComputedChecksum = computeCheckSum(newPacket, client.receiveCounter - 1n, client.secretKeyBytes) + // if (diff > 8) { + // const remaining = chunk.slice(cReadLen + 8) + // console.log('Extraneous bytes:', remaining.toString('hex')) + // const inflated2 = Zlib.inflateRawSync(remaining, { + // // info: true + // }) + // console.log('inflated', inflated2.toString('hex')) + // } + // console.log('New', newExpectedSum, newComputedChecksum) + + // console.log('Decrypted len ', chunk.length, buffer.length, engine.bytesRead) + + if (checksum.toString("hex") == computedCheckSum.toString("hex")) { + console.log('🔵 Inflated') + client.onDecryptedPacket(buffer) + // client.emit('decrypted', inflated) + } else { + console.log(`🔴 Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) + + // const sums = [] + // for (var i = 0n; i < 20n; i++) { + // sums.push(computeCheckSum(packet, i, client.secretKeyBytes).toString('hex')) + // } + // console.log('Tried', sums) + + // client.onDecryptedPacket(inflated) // allow it anyway + // client.emit('decrypted', inflated) + throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) + } + } + + client.decipher.on('data', (buffer) => { + verify(buffer) }) - - client.decipher.pipe(verifyChecksum) - - // Not sure why, but sending two packets to the decryption pipe before - // the other is completed breaks the checksum check. - // TODO: Refactor the logic here to be async so we can await a promise - // queue - let decQ = [] - setInterval(() => { - if (decQ.length) { - let pak = decQ.shift() - console.log('🟡 DECRYPTING', pak) - client.decipher.write(pak) - } - }, 500) - return (blob) => { - decQ.push(blob) - // client.decipher.write(blob) + client.decipher.write(blob) } } From 8db7305eed053a8bfcf45843230b981005f66301 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 18 Feb 2021 01:50:46 -0500 Subject: [PATCH 092/106] move raknet to worker --- src/ConnWorker.js | 64 ++++++++++++++++++++++++++++++ src/client.js | 59 +++++++++++++++++---------- src/connection.js | 32 +++++++++------ src/{ => datatypes}/BatchPacket.js | 0 4 files changed, 121 insertions(+), 34 deletions(-) create mode 100644 src/ConnWorker.js rename src/{ => datatypes}/BatchPacket.js (100%) diff --git a/src/ConnWorker.js b/src/ConnWorker.js new file mode 100644 index 0000000..f6d38d3 --- /dev/null +++ b/src/ConnWorker.js @@ -0,0 +1,64 @@ +const RakClient = require('@jsprismarine/raknet/client') +const { Worker, isMainThread, parentPort } = require('worker_threads') +const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') + +function connect(hostname, port) { + if (isMainThread) { + const worker = new Worker(__filename) + worker.postMessage({ type: 'connect', hostname, port }) + return worker + } +} + +var raknet + +function main() { + parentPort.on('message', (evt) => { + if (evt.type == 'connect') { + console.warn('-------- ', evt) + const { hostname, port } =evt + raknet = new RakClient(hostname, port) + + raknet.connect().then(() => { + console.log('Raknet Connected!') + }) + + raknet.on('connecting', () => { + console.log(`[client] connecting to ${hostname}/${port}`) + parentPort.postMessage('message', { type: 'connecting' }) + console.log('Raknet', raknet) + }) + + raknet.once('connected', (connection) => { + console.log(`[worker] connected!`) + globalThis.raknetConnection = connection + parentPort.postMessage({ type: 'connected' }) + }) + + raknet.on('encapsulated', (...args) => { + // console.log('-> ENCAP BUF', args) + setTimeout(() => { + parentPort.postMessage({ type: 'encapsulated', args }) + }, 100) + }) + + raknet.on('raw', (buffer, inetAddr) => { + console.log('Raw packet', buffer, inetAddr) + }) + } else if (evt.type == 'queueEncapsulated') { + console.log('SEND' , globalThis.raknetConnection, evt.packet) + + const sendPacket = new EncapsulatedPacket() + sendPacket.reliability = 0 + sendPacket.buffer = evt.packet + + globalThis.raknetConnection?.addEncapsulatedToQueue(sendPacket) + if (evt.immediate) { + globalThis.raknetConnection?.sendQueue() + } + } + }) +} + +if (!isMainThread) main() +module.exports = { connect } \ No newline at end of file diff --git a/src/client.js b/src/client.js index 8d21ead..b7b2ed5 100644 --- a/src/client.js +++ b/src/client.js @@ -1,12 +1,14 @@ const RakClient = require('@jsprismarine/raknet/client') const { Connection } = require('./connection') const { createDeserializer, createSerializer } = require('./transforms/serializer') +const ConnWorker = require('./ConnWorker') const { Encrypt } = require('./auth/encryption') const auth = require('./client/auth') const Options = require('./options') const fs = require('fs') const log = console.log +const useWorkers = true class Client extends Connection { constructor(options) { @@ -25,6 +27,7 @@ class Client extends Connection { } this.on('session', this.connect) + // this.on('decrypted', this.onDecryptedPacket) } validateOptions() { @@ -35,32 +38,46 @@ class Client extends Connection { onEncapsulated = (encapsulated, inetAddr) => { // log(inetAddr.address, ': Encapsulated', encapsulated) - const buffer = encapsulated.buffer + const buffer = Buffer.from(encapsulated.buffer) this.handle(buffer) } connect = async (sessionData) => { - console.log('Got session data', sessionData) + if (useWorkers) { + this.worker = ConnWorker.connect('127.0.0.1', 19132) + this.worker.on('message', (evt) => { + switch (evt.type) { + case 'connected': + this.sendLogin() + break + case 'encapsulated': + this.onEncapsulated(...evt.args) + break + } + }) - if (this.raknet) return + } else { + if (this.raknet) return - this.raknet = new RakClient('127.0.0.1', 19132) - await this.raknet.connect() + this.raknet = new RakClient('127.0.0.1', 19132) + await this.raknet.connect() - this.raknet.on('connecting', () => { - // console.log(`[client] connecting to ${hostname}/${port}`) - }) - this.raknet.on('connected', (connection) => { - console.log(`[client] connected!`) - this.connection = connection - this.sendLogin() - }) + this.raknet.on('connecting', () => { + // console.log(`[client] connecting to ${hostname}/${port}`) + }) + this.raknet.on('connected', (connection) => { + console.log(`[client] connected!`) + this.connection = connection + this.sendLogin() + }) - this.raknet.on('encapsulated', this.onEncapsulated) + this.raknet.on('encapsulated', this.onEncapsulated) + + this.raknet.on('raw', (buffer, inetAddr) => { + console.log('Raw packet', buffer, inetAddr) + }) + } - this.raknet.on('raw', (buffer, inetAddr) => { - console.log('Raw packet', buffer, inetAddr) - }) } sendLogin() { @@ -104,7 +121,7 @@ class Client extends Connection { readPacket(packet) { // console.log('packet', packet) const des = this.deserializer.parsePacketBuffer(packet) - console.log('->',des) + console.log('->', des) const pakData = { name: des.data.name, params: des.data.params } // console.info('->', JSON.stringify(pakData, (k,v) => typeof v == 'bigint' ? v.toString() : v)) switch (des.data.name) { @@ -115,12 +132,12 @@ class Client extends Connection { this.onDisconnectRequest(des.data.params) break case 'crafting_data': - fs.writeFileSync('crafting.json', JSON.stringify(des.data.params, (k,v) => typeof v == 'bigint' ? v.toString() : v)) + fs.writeFileSync('crafting.json', JSON.stringify(des.data.params, (k, v) => typeof v == 'bigint' ? v.toString() : v)) break case 'start_game': - fs.writeFileSync('start_game.json', JSON.stringify(des.data.params, (k,v) => typeof v == 'bigint' ? v.toString() : v)) + fs.writeFileSync('start_game.json', JSON.stringify(des.data.params, (k, v) => typeof v == 'bigint' ? v.toString() : v)) default: - // console.log('Sending to listeners') + // console.log('Sending to listeners') } this.emit(des.data.name, des.data.params) diff --git a/src/connection.js b/src/connection.js index f266ebf..58a51c8 100644 --- a/src/connection.js +++ b/src/connection.js @@ -1,5 +1,5 @@ const BinaryStream = require('@jsprismarine/jsbinaryutils').default -const BatchPacket = require('./BatchPacket') +const BatchPacket = require('./datatypes/BatchPacket') const cipher = require('./transforms/encryption') const { EventEmitter } = require('events') const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') @@ -48,12 +48,7 @@ class Connection extends EventEmitter { sendDecryptedBatch(batch) { const buf = batch.encode() // send to raknet - const sendPacket = new EncapsulatedPacket(); - sendPacket.reliability = 0; - sendPacket.buffer = buf - - this.connection.addEncapsulatedToQueue(sendPacket) - this.connection.sendQueue() + this.sendMCPE(buf, true) } sendEncryptedBatch(batch) { @@ -62,15 +57,26 @@ class Connection extends EventEmitter { this.encrypt(buf) } + sendMCPE(buffer, immediate) { + if (this.worker) { + console.log('-> buf', buffer) + this.worker.postMessage({ type: 'queueEncapsulated', packet: buffer, immediate }) + } else { + const sendPacket = new EncapsulatedPacket(); + sendPacket.reliability = 0 + sendPacket.buffer = buffer + this.connection.addEncapsulatedToQueue(sendPacket) + if (immediate) this.connection.sendQueue() + } + } + // These are callbacks called from encryption.js onEncryptedPacket = (buf) => { console.log('ENC BUF', buf) const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header - const sendPacket = new EncapsulatedPacket(); - sendPacket.reliability = 0 - sendPacket.buffer = packet + console.log('Sending wrapped encrypted batch', packet) - this.connection.addEncapsulatedToQueue(sendPacket) + this.sendMCPE(packet) } onDecryptedPacket = (buf) => { @@ -87,7 +93,7 @@ class Connection extends EventEmitter { handle(buffer) { // handle encapsulated if (buffer[0] == 0xfe) { // wrapper if (this.encryptionEnabled) { - console.log('Reading encrypted packet', buffer) + console.trace('Reading encrypted packet', buffer.toString('hex')) this.decrypt(buffer.slice(1)) } else { const stream = new BinaryStream(buffer) @@ -100,7 +106,7 @@ class Connection extends EventEmitter { } } } - console.log('[client] procesed ', buffer) + console.log('[client] handled incoming ', buffer) } } diff --git a/src/BatchPacket.js b/src/datatypes/BatchPacket.js similarity index 100% rename from src/BatchPacket.js rename to src/datatypes/BatchPacket.js From 0ed5a8d0611cf289074fab7dece791b14b313f40 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 18 Feb 2021 13:30:19 -0500 Subject: [PATCH 093/106] protocol updates, packet dumping --- .gitignore | 5 ++- data/new/proto.yml | 58 ++++++++++++++++--------- data/newproto.json | 81 +++++++++++++++++++++++++---------- src/client.js | 17 ++++++-- src/clientTest.js | 2 +- src/connection.js | 5 +-- src/{ => old}/createClient.js | 0 src/{ => old}/createServer.js | 0 src/transforms/encryption.js | 50 ++------------------- test/serialization.js | 12 +++++- 10 files changed, 131 insertions(+), 99 deletions(-) rename src/{ => old}/createClient.js (100%) rename src/{ => old}/createServer.js (100%) diff --git a/.gitignore b/.gitignore index 570a59b..4f37984 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ node_modules/ npm-debug.log __* -data/*.js \ No newline at end of file +data/*.js +src/**/*.json +src/*.txt +dist/ \ No newline at end of file diff --git a/data/new/proto.yml b/data/new/proto.yml index b24839e..3440313 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -240,7 +240,7 @@ packet_start_game: # Specifies if the world has education edition features enabled, such as the blocks or entities # specific to education edition. has_edu_features_enabled: bool - edu_product_uuid_: string + edu_product_uuid: string # The level specifying the Intensity of the rain falling. When set to 0, no rain falls at all. rain_level: lf32 lightning_level: lf32 @@ -306,7 +306,7 @@ packet_start_game: game_version: string limited_world_width: li32 limited_world_length: li32 - is_new_nether_: bool + is_new_nether: bool experimental_gameplay_override: bool # A base64 encoded world ID that is used to identify the world. level_id: string @@ -820,7 +820,7 @@ packet_player_hotbar: !bound: both selected_slot: varint window_id: u8 - select_slot_: bool + select_slot: bool packet_inventory_content: !id: 0x31 @@ -1020,8 +1020,15 @@ packet_show_credits: packet_available_commands: !id: 0x4c !bound: client + # The length of the enums for all the command paramaters in this packet + values_len: varint + # Not read from stream: instead calculated from the `values_len` field + # If the values_len < 0xff => byte + # If the values_len < 0xffff => short + # If the values_len < 0xffffff => int + _enum_type: '["enum_size_based_on_values_len"]' # Here all the enum values for all of the possible commands are stored to one array palette - enum_values: string[]varint + enum_values: string[]$values_len # Integer paramaters may sometimes have a prefix, such as the XP command: # /xp [player: target] <- here, the xp command gives experience points # /xp L [player: target] <- here, the xp command gives experience levels @@ -1031,15 +1038,8 @@ packet_available_commands: enums: []varint # The name of the enum name: string - # The length of the array below - values_len: varint - # Not read from stream: instead calculated from the `values_len` field - # If the values_len < 0xff => byte - # If the values_len < 0xffff => short - # If the values_len < 0xffffff => int - _enum_type: '["enum_size_based_on_values_len"]' # The values in the enum - values: []$values_len + values: []varint # The indexes to value in the palette _: ../_enum_type? if byte: u8 @@ -1056,15 +1056,31 @@ packet_available_commands: # Each of the paramaters gets an array of posible overloads _: []varint # The name of the paramater shown to the user (the `amount` in `/xp `) - paramater_name: string - # Bitfield: If FLAG_ENUM is set, the lower 16 bits act as an index to enums array - # If FLAG_SUFFIX is set, the lower 16 bits act as an index to the suffix palette - # and the client interperts the type as just `int` as in the example above - paramater_type: li32 + paramater_name: string + value_type: lu16 => + 1: int + 2: float + 3: value + 4: wildcard_int + 5: operator + 6: target + 14: file_path + 29: string + 37: position + 41: message + 43: raw_text + 46: json + 53: command + # In MC, this + prior field are combined to one 32bit bitfield + enum_type: lu16 => + 0x10: valid + 0x20: enum + 0x100: suffixed + 0x400: soft_enum # Is this paramater required? optional: bool # Additinal options for this command (thanks macroshaft...) - flags: CommandFlags + options: CommandFlags # There are two types of enums: static enums which cannot be changed after sending AvaliableCommands, # (unless you resend the whole packet) and 'soft' or 'dynamic' enums like below which is an array # that can be updated with the UpdateSoftEnum packet @@ -1084,9 +1100,9 @@ packet_available_commands: # with enums that have a big amount of options. To illustrate, it can make # <$Name: bool>. CommandFlags: [ "bitfield", [ - { "name": "unused", "size": 1, "signed": false }, - { "name": "collapse_enum", "size": 1, "signed": false }, - { "name": "has_semantic_constraint", "size": 1, "signed": false } + { "name": "unused", "size": 6, "signed": false }, # 6 unused upper bits + { "name": "has_semantic_constraint", "size": 1, "signed": false }, + { "name": "collapse_enum", "size": 1, "signed": false } ]] # enum_size_based_on_values_len: native diff --git a/data/newproto.json b/data/newproto.json index ead075d..6be7328 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -2912,7 +2912,7 @@ "type": "bool" }, { - "name": "edu_product_uuid_", + "name": "edu_product_uuid", "type": "string" }, { @@ -3020,7 +3020,7 @@ "type": "li32" }, { - "name": "is_new_nether_", + "name": "is_new_nether", "type": "bool" }, { @@ -4060,7 +4060,7 @@ "type": "u8" }, { - "name": "select_slot_", + "name": "select_slot", "type": "bool" } ] @@ -4519,12 +4519,22 @@ "packet_available_commands": [ "container", [ + { + "name": "values_len", + "type": "varint" + }, + { + "name": "_enum_type", + "type": [ + "enum_size_based_on_values_len" + ] + }, { "name": "enum_values", "type": [ "array", { - "countType": "varint", + "count": "values_len", "type": "string" } ] @@ -4552,22 +4562,12 @@ "name": "name", "type": "string" }, - { - "name": "values_len", - "type": "varint" - }, - { - "name": "_enum_type", - "type": [ - "enum_size_based_on_values_len" - ] - }, { "name": "values", "type": [ "array", { - "count": "values_len", + "countType": "varint", "type": [ "switch", { @@ -4635,15 +4635,50 @@ "type": "string" }, { - "name": "paramater_type", - "type": "li32" + "name": "value_type", + "type": [ + "mapper", + { + "type": "lu16", + "mappings": { + "1": "int", + "2": "float", + "3": "value", + "4": "wildcard_int", + "5": "operator", + "6": "target", + "14": "file_path", + "29": "string", + "37": "position", + "41": "message", + "43": "raw_text", + "46": "json", + "53": "command" + } + } + ] + }, + { + "name": "enum_type", + "type": [ + "mapper", + { + "type": "lu16", + "mappings": { + "16": "valid", + "32": "enum", + "256": "suffixed", + "1024": "soft_enum" + } + } + ] }, { "name": "optional", "type": "bool" }, { - "name": "flags", + "name": "options", "type": "CommandFlags" } ] @@ -5768,6 +5803,11 @@ [ { "name": "unused", + "size": 6, + "signed": false + }, + { + "name": "has_semantic_constraint", "size": 1, "signed": false }, @@ -5775,11 +5815,6 @@ "name": "collapse_enum", "size": 1, "signed": false - }, - { - "name": "has_semantic_constraint", - "size": 1, - "signed": false } ] ] diff --git a/src/client.js b/src/client.js index b7b2ed5..bd2da33 100644 --- a/src/client.js +++ b/src/client.js @@ -1,10 +1,11 @@ -const RakClient = require('@jsprismarine/raknet/client') +const RakClient = require('jsp-raknet/client') const { Connection } = require('./connection') const { createDeserializer, createSerializer } = require('./transforms/serializer') const ConnWorker = require('./ConnWorker') const { Encrypt } = require('./auth/encryption') const auth = require('./client/auth') const Options = require('./options') +const debug = require('debug')('minecraft-protocol') const fs = require('fs') const log = console.log @@ -93,7 +94,7 @@ class Client extends Connection { const bodyLength = this.clientUserChain.length + encodedChain.length + 8 - console.log('Auth chain', chain) + debug('Auth chain', chain) this.write('login', { protocol_version: this.options.version, @@ -121,9 +122,15 @@ class Client extends Connection { readPacket(packet) { // console.log('packet', packet) const des = this.deserializer.parsePacketBuffer(packet) - console.log('->', des) const pakData = { name: des.data.name, params: des.data.params } + console.log('->', pakData.name, serialize(pakData.params).slice(0, 100)) // console.info('->', JSON.stringify(pakData, (k,v) => typeof v == 'bigint' ? v.toString() : v)) + try { + if (!fs.existsSync(`./packets/${pakData.name}.json`)) { + fs.writeFileSync(`./packets/${pakData.name}.json`, serialize(pakData.params, 2)) + fs.writeFileSync(`./packets/${pakData.name}.txt`, packet.toString('hex')) + } + } catch {} switch (des.data.name) { case 'server_to_client_handshake': this.emit('client.server_handshake', des.data.params) @@ -144,4 +151,8 @@ class Client extends Connection { } } +function serialize(obj = {}, fmt) { + return JSON.stringify(obj, (k, v) => typeof v == 'bigint' ? v.toString() : v, fmt) +} + module.exports = { Client } \ No newline at end of file diff --git a/src/clientTest.js b/src/clientTest.js index d0ba45f..39bb310 100644 --- a/src/clientTest.js +++ b/src/clientTest.js @@ -1,4 +1,4 @@ -process.env.DEBUG = 'minecraft-protocol raknet' +// process.env.DEBUG = 'minecraft-protocol raknet' const { Client } = require('./client') // console.log = () => diff --git a/src/connection.js b/src/connection.js index 58a51c8..1ecbee2 100644 --- a/src/connection.js +++ b/src/connection.js @@ -80,7 +80,7 @@ class Connection extends EventEmitter { } onDecryptedPacket = (buf) => { - console.log('🟢 Decrypted', buf) + // console.log('🟢 Decrypted', buf) const stream = new BinaryStream(buf) const packets = BatchPacket.getPackets(stream) @@ -93,7 +93,6 @@ class Connection extends EventEmitter { handle(buffer) { // handle encapsulated if (buffer[0] == 0xfe) { // wrapper if (this.encryptionEnabled) { - console.trace('Reading encrypted packet', buffer.toString('hex')) this.decrypt(buffer.slice(1)) } else { const stream = new BinaryStream(buffer) @@ -106,7 +105,7 @@ class Connection extends EventEmitter { } } } - console.log('[client] handled incoming ', buffer) + // console.log('[client] handled incoming ', buffer) } } diff --git a/src/createClient.js b/src/old/createClient.js similarity index 100% rename from src/createClient.js rename to src/old/createClient.js diff --git a/src/createServer.js b/src/old/createServer.js similarity index 100% rename from src/createServer.js rename to src/old/createServer.js diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index f911fb2..670d8a9 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -74,7 +74,7 @@ function createEncryptor(client, iv) { const addChecksum = new Transform({ // append checksum transform(chunk, enc, cb) { - console.log('Encryptor: checking checksum', chunk) + // console.log('Encryptor: checking checksum', chunk) // Here we concat the payload + checksum before the encryption const packet = Buffer.concat([chunk, computeCheckSum(chunk, client.sendCounter, client.secretKeyBytes)]) client.sendCounter++ @@ -118,7 +118,7 @@ function createDecryptor(client, iv) { client.receiveCounter = client.receiveCounter || 0n function verify(chunk) { - console.log('Decryptor: checking checksum', client.receiveCounter, chunk) + // console.log('Decryptor: checking checksum', client.receiveCounter, chunk) // First try to zlib decompress, then see how much bytes get read const { buffer, engine } = Zlib.inflateRawSync(chunk, { @@ -142,62 +142,20 @@ function createDecryptor(client, iv) { throw new Error('Decrypted packet is missing checksum') } - console.log('Inflated', inflatedLen, chunk.length, extraneousLen, chunk.toString('hex')) - const packet = chunk.slice(0, inflatedLen); const checksum = chunk.slice(inflatedLen, inflatedLen + 8); - console.log("packet, checksum", packet, checksum) const computedCheckSum = computeCheckSum(packet, client.receiveCounter, client.secretKeyBytes) - // // console.log(computedCheckSum2, computedCheckSum3) - // console.assert(checksum.toString("hex") == computedCheckSum.toString("hex"), 'checksum mismatch') client.receiveCounter++ - - // // const infLen = Zlib.inflateRawSync(chunk, { - // // chunkSize: 1024 * 1024 * 2, - // // info: true - // // }) - // console.log('infLen', engine) - - // const cReadLen = engine.bytesRead - // const diff = chunk.length - cReadLen - // const newPacket = chunk.slice(0, cReadLen) - // const newExpectedSum = chunk.slice(cReadLen, cReadLen+8) - // const newComputedChecksum = computeCheckSum(newPacket, client.receiveCounter - 1n, client.secretKeyBytes) - // if (diff > 8) { - // const remaining = chunk.slice(cReadLen + 8) - // console.log('Extraneous bytes:', remaining.toString('hex')) - // const inflated2 = Zlib.inflateRawSync(remaining, { - // // info: true - // }) - // console.log('inflated', inflated2.toString('hex')) - // } - // console.log('New', newExpectedSum, newComputedChecksum) - - // console.log('Decrypted len ', chunk.length, buffer.length, engine.bytesRead) - if (checksum.toString("hex") == computedCheckSum.toString("hex")) { - console.log('🔵 Inflated') client.onDecryptedPacket(buffer) - // client.emit('decrypted', inflated) } else { - console.log(`🔴 Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) - - // const sums = [] - // for (var i = 0n; i < 20n; i++) { - // sums.push(computeCheckSum(packet, i, client.secretKeyBytes).toString('hex')) - // } - // console.log('Tried', sums) - - // client.onDecryptedPacket(inflated) // allow it anyway - // client.emit('decrypted', inflated) + console.log('Inflated', inflatedLen, chunk.length, extraneousLen, chunk.toString('hex')) throw Error(`Checksum mismatch ${checksum.toString("hex")} != ${computedCheckSum.toString("hex")}`) } } - client.decipher.on('data', (buffer) => { - verify(buffer) - }) + client.decipher.on('data', verify) return (blob) => { client.decipher.write(blob) diff --git a/test/serialization.js b/test/serialization.js index a15441f..8250f14 100644 --- a/test/serialization.js +++ b/test/serialization.js @@ -1,3 +1,4 @@ +const fs = require('fs') const { createDeserializer, createSerializer } = require('../src/transforms/serializer') function test() { @@ -163,8 +164,17 @@ function test() { console.log(JSON.stringify(d, null, 2)) } + async function avaliableCmd() { + const buffer = Buffer.from(fs.readFileSync('./serialization/available_commands.txt', 'utf8'), 'hex') + const readed = read(buffer) + const recipes = readed.data.params.enums + console.log('read', recipes) + fs.writeFileSync('commands.json', JSON.stringify(readed.data,null,2)) + } + // creativeTst() - availableCommands() + // availableCommands() + // avaliableCmd() } if (!module.parent) { From 8c409108093b7addbf70cf181df318ceb2aa12f7 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 20 Feb 2021 01:08:38 -0500 Subject: [PATCH 094/106] protocol updates --- data/new/proto.yml | 222 ++++++++++++++++++++--- data/new/types.yaml | 78 ++++---- data/newproto.json | 424 ++++++++++++++++++++++++++++++++------------ 3 files changed, 554 insertions(+), 170 deletions(-) diff --git a/data/new/proto.yml b/data/new/proto.yml index 3440313..6bbb0d5 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -230,7 +230,7 @@ packet_start_game: # Defines if achievements are disabled in the world. The client crashes if this value is set # to true while the player's or the world's game mode is creative, and it's recommended to simply # always set this to false as a server. - has_achievements_disabled: bool + achievements_disabled: bool # The time at which the day cycle was locked if the day cycle is disabled using the respective # game rule. The client will maIntain this time as Boolean as the day cycle is disabled. day_cycle_stop_time: zigzag32 @@ -239,7 +239,7 @@ packet_start_game: edu_offer: zigzag32 # Specifies if the world has education edition features enabled, such as the blocks or entities # specific to education edition. - has_edu_features_enabled: bool + edu_features_enabled: bool edu_product_uuid: string # The level specifying the Intensity of the rain falling. When set to 0, no rain falls at all. rain_level: lf32 @@ -459,7 +459,7 @@ packet_move_player: packet_rider_jump: !id: 0x14 !bound: both - unknown: zigzag32 + jump_strength: zigzag32 packet_update_block: !id: 0x15 @@ -765,13 +765,12 @@ packet_set_entity_motion: runtime_entity_id: varint velocity: vec3f +# SetActorLink is sent by the server to initiate an entity link client-side, meaning one entity will start +# riding another. packet_set_entity_link: !id: 0x29 !bound: client - ridden_id: zigzag64 - rider_id: zigzag64 - link_type: u8 - unknown: u8 + link: Link packet_set_health: !id: 0x2a @@ -781,10 +780,12 @@ packet_set_health: packet_set_spawn_position: !id: 0x2b !bound: client - spawn_type: zigzag32 - coordinates: BlockCoordinates + spawn_type: zigzag32 => + 0: player + 1: world + player_position: BlockCoordinates dimension: zigzag32 - unknown_coordinates: BlockCoordinates + world_position: BlockCoordinates packet_animate: !id: 0x2c @@ -888,13 +889,37 @@ packet_player_input: jumping: bool sneaking: bool + +# LevelChunk is sent by the server to provide the client with a chunk of a world data (16xYx16 blocks). +# Typically a certain amount of chunks is sent to the client before sending it the spawn PlayStatus packet, +# so that the client spawns in a loaded world. packet_level_chunk: !id: 0x3a !bound: client + # ChunkX is the X coordinate of the chunk sent. (To translate a block's X to a chunk's X: x >> 4) x: zigzag32 + # ChunkZ is the Z coordinate of the chunk sent. (To translate a block's Z to a chunk's Z: z >> 4) z: zigzag32 + # SubChunkCount is the amount of sub chunks that are part of the chunk sent. Depending on if the cache + # is enabled, a list of blob hashes will be sent, or, if disabled, the sub chunk data. sub_chunk_count: varint - column: Chunks + # CacheEnabled specifies if the client blob cache should be enabled. This system is based on hashes of + # blobs which are consistent and saved by the client in combination with that blob, so that the server + # does not have to send the same chunk multiple times. If the client does not yet have a blob with the hash sent, + # it will send a ClientCacheBlobStatus packet containing the hashes is does not have the data of. + cache_enabled: bool + blobs: cache_enabled? + if true: + # BlobHashes is a list of all blob hashes used in the chunk. It is composed of SubChunkCount + 1 hashes, + # with the first SubChunkCount hashes being those of the sub chunks and the last one that of the biome + # of the chunk. + # If CacheEnabled is set to false, BlobHashes can be left empty. + hashes: lu64[]varint + # RawPayload is a serialised string of chunk data. The data held depends on if CacheEnabled is set to + # true. If set to false, the payload is composed of multiple sub-chunks, each of which carry a version + # which indicates the way they are serialised, followed by biomes, border blocks and tile entities. If + # CacheEnabled is true, the payload consists out of the border blocks and tile entities only. + payload: string packet_set_commands_enabled: !id: 0x3b @@ -964,11 +989,17 @@ packet_game_rules_changed: !bound: client rules: GameRules +# Camera is sent by the server to use an Education Edition camera on a player. It produces an image +# client-side. packet_camera: !id: 0x49 !bound: client - unknown1: zigzag64 - unknown2: zigzag64 + # CameraEntityUniqueID is the unique ID of the camera entity from which the picture was taken. + camera_entity_unique_id: zigzag64 + # TargetPlayerUniqueID is the unique ID of the target player. The unique ID is a value that remains + # consistent across different sessions of the same world, but most servers simply fill the runtime ID of + # the player out for this field. + target_player_unique_id: zigzag64 packet_boss_event: !id: 0x4a @@ -1071,6 +1102,97 @@ packet_available_commands: 43: raw_text 46: json 53: command + # 15: unknown15 + # 16: unknown16 + # 125: unknown125 + # 126: unknown126 + # 22: unknown22 + # 10: unknown10 + # 39: unknown39 + # 18: unknown18 + # 20: unknown20 + # 19: unknown19 + # 7: unknown7 + # 23: unknown23 + # 24: unknown24 + # 13: unknown13 + # 25: unknown25 + # 40: unknown40 + # 56: unknown56 + # 26: unknown26 + # 27: unknown27 + # 28: unknown28 + # 31: unknown31 + # 30: unknown30 + # 0: unknown0 + # 32: unknown32 + # 49: unknown49 + # 12: unknown12 + # 35: unknown35 + # 36: unknown36 + # 38: unknown38 + # 44: unknown44 + # 47: unknown47 + # 45: unknown45 + # 48: unknown48 + # 55: unknown55 + # 54: unknown54 + # 50: unknown50 + # 51: unknown51 + # 52: unknown52 + # 9: unknown9 + # 123: unknown123 + # 57: unknown57 + # 58: unknown58 + # 59: unknown59 + # 60: unknown60 + # 61: unknown61 + # 63: unknown63 + # 75: unknown75 + # 64: unknown64 + # 67: unknown67 + # 66: unknown66 + # 73: unknown73 + # 72: unknown72 + # 74: unknown74 + # 62: unknown62 + # 68: unknown68 + # 69: unknown69 + # 65: unknown65 + # 70: unknown70 + # 71: unknown71 + # 76: unknown76 + # 77: unknown77 + # 79: unknown79 + # 78: unknown78 + # 80: unknown80 + # 81: unknown81 + # 82: unknown82 + # 83: unknown83 + # 84: unknown84 + # 87: unknown87 + # 88: unknown88 + # 92: unknown92 + # 89: unknown89 + # 90: unknown90 + # 91: unknown91 + # 93: unknown93 + # 95: unknown95 + # 94: unknown94 + # 98: unknown98 + # 96: unknown96 + # 97: unknown97 + # 99: unknown99 + # 100: unknown100 + # 101: unknown101 + # 102: unknown102 + # 103: unknown103 + # 104: unknown104 + # 105: unknown105 + # 106: unknown106 + # 107: unknown107 + # 108: unknown108 + # 124: unknown124 # In MC, this + prior field are combined to one 32bit bitfield enum_type: lu16 => 0x10: valid @@ -1159,28 +1281,64 @@ packet_command_output: paramaters: string[]varint +# UpdateTrade is sent by the server to update the trades offered by a villager to a player. It is sent at the +# moment that a player interacts with a villager. packet_update_trade: !id: 0x50 !bound: client + # WindowID is the ID that identifies the trading window that the client currently has opened. window_id: u8 + # WindowType is an identifier specifying the type of the window opened. In vanilla, it appears this is + # always filled out with 15. window_type: u8 - unknown0: varint - unknown1: varint - unknown2: varint - is_willing: bool - trader_entity_id: zigzag64 - player_entity_id: zigzag64 + # Size is the amount of trading options that the villager has. + size: varint + # TradeTier is the tier of the villager that the player is trading with. The tier starts at 0 with a + # first two offers being available, after which two additional offers are unlocked each time the tier + # becomes one higher. + trade_tier: varint + # VillagerUniqueID is the unique ID of the villager entity that the player is trading with. The + # TradeTier sent above applies to this villager. + villager_unique_id: varint64 + # EntityUniqueID is the unique ID of the entity (usually a player) for which the trades are updated. The + # updated trades may apply only to this entity. + entity_unique_id: varint64 + # DisplayName is the name displayed at the top of the trading UI. It is usually used to represent the + # profession of the villager in the UI. display_name: string - nbt: nbt + # NewTradeUI specifies if the villager should be using the new trade UI (The one added in 1.11.) rather + # than the old one. This should usually be set to true. + new_trading_ui: bool + # Trading based on Minecraft economy - specifies if the prices of the villager's offers are modified by an increase in + # demand for the item. (A mechanic added in 1.11.) Buying more of the same item will increase the price + # of that particular item. + # https://minecraft.gamepedia.com/Trading#Economics + economic_trades: bool + # NBT serialised compound of offers that the villager has. + offers: nbt +# UpdateEquip is sent by the server to the client upon opening a horse inventory. It is used to set the +# content of the inventory and specify additional properties, such as the items that are allowed to be put +# in slots of the inventory. packet_update_equipment: !id: 0x51 !bound: client + # WindowID is the identifier associated with the window that the UpdateEquip packet concerns. It is the + # ID sent for the horse inventory that was opened before this packet was sent. window_id: u8 + # WindowType is the type of the window that was opened. Generally, this is the type of a horse inventory, + # as the packet is specifically made for that. window_type: u8 - unknown: u8 + # Size is the size of the horse inventory that should be opened. A bigger size does, in fact, change the + # amount of slots displayed. + size: u8 + # EntityUniqueID is the unique ID of the entity whose equipment was 'updated' to the player. It is + # typically the horse entity that had its inventory opened. entity_id: zigzag64 - nbt: nbt + # `inventory` is a network NBT serialised compound holding the content of the inventory of + # the entity (the equipment) and additional data such as the allowed items for a particular slot, used to + # make sure only saddles can be put in the saddle slot etc. + inventory: nbt packet_resource_pack_data_info: !id: 0x52 @@ -1508,19 +1666,35 @@ packet_update_block_properties: !bound: client nbt: nbt +# ClientCacheBlobStatus is part of the blob cache protocol. It is sent by the client to let the server know +# what blobs it needs and which blobs it already has, in an ACK type system. packet_client_cache_blob_status: !id: 0x87 !bound: client + # A list of blob hashes that the client does not have a blob available for. The server + # should send the blobs matching these hashes as soon as possible. + missing: lu64[]varint + # A list of hashes that the client does have a cached blob for. Server doesn't need to send. + have: lu64[]varint +# ClientCacheMissResponse is part of the blob cache protocol. It is sent by the server in response to a +# ClientCacheBlobStatus packet and contains the blob data of all blobs that the client acknowledged not to +# have yet. packet_client_cache_miss_response: !id: 0x88 !bound: client + blobs: Blob[]varint + +# NetworkSettings is sent by the server to update a variety of network settings. These settings modify the +# way packets are sent over the network stack. packet_network_settings: !id: 0x8f !bound: both - unknown: u8 - compression_threshold: u8 + # CompressionThreshold is the minimum size of a packet that is compressed when sent. If the size of a + # packet is under this value, it is not compressed. + # When set to 0, all packets will be left uncompressed. + compression_threshold: u16 packet_creative_content: !id: 0x91 diff --git a/data/new/types.yaml b/data/new/types.yaml index 528a0ba..a0835b1 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -48,12 +48,15 @@ GameRule: GameRules: GameRule[]varint -Chunks: - cache_enabled: bool - _: cache_enabled? - if true: void # TODO - if false: void - +# CacheBlob represents a blob as used in the client side blob cache protocol. It holds a hash of its data and +# the full data of it. +Blob: + # Hash is the hash of the blob. The hash is computed using xxHash, and must be deterministic for the same + # chunk data. + hash: lu64 + # Payload is the data of the blob. When sent, the client will associate the Hash of the blob with the + # Payload in it. + payload: string BlockPalette: []varint name: string @@ -245,13 +248,15 @@ MetadataDictionary: []varint if long: zigzag64 if vec3f: vec3f -Links: []varint +Link: ridden_entity_id: zigzag64 rider_entity_id: zigzag64 type: u8 immediate: bool rider_initiated: bool +Links: Link[]varint + EntityAttributes: []varint name: string min: lf32 @@ -276,7 +281,16 @@ PlayerAttributes: []varint name: string Transaction: + # LegacyRequestID is an ID that is only non-zero at times when sent by the client. The server should + # always send 0 for this. When this field is not 0, the LegacySetItemSlots slice below will have values + # in it. + # LegacyRequestID ties in with the ItemStackResponse packet. If this field is non-0, the server should + # respond with an ItemStackResponse packet. Some inventory actions such as dropping an item out of the + # hotbar are still one using this packet, and the ItemStackResponse packet needs to tie in with it. legacy_request_id: zigzag32 + # `legacy_transactions` are only present if the LegacyRequestID is non-zero. These item slots inform the + # server of the slots that were changed during the inventory transaction, and the server should send + # back an ItemStackResponse packet with these slots present in it. (Or false with no slots, if rejected.) legacy_transactions: legacy_request_id? if 0: void default: []varint @@ -284,37 +298,37 @@ Transaction: changed_slots: []varint slot_id: u8 transaction_type: varint => - 0: TYPE_NORMAL - 1: TYPE_INVENTORY_MISMATCH - 2: TYPE_ITEM_USE - 3: TYPE_ITEM_USE_ON_ENTITY - 4: TYPE_ITEM_RELEASE - has_network_ids: bool + 0: normal + 1: inventory_mismatch + 2: item_use + 3: item_use_on_entity + 4: item_release + network_ids: bool inventory_actions: []varint source_type: varint => - "0": "INV_SOURCE_TYPE_CONTAINER" - "1": "INV_SOURCE_TYPE_GLOBAL" - "2": "INV_SOURCE_TYPE_WORLD_INTERACTION" - "3": "INV_SOURCE_TYPE_CREATIVE" - "100": "INV_SOURCE_TYPE_CRAFT_SLOT" - "99999": "INV_SOURCE_TYPE_CRAFT" + 0: container + 1: global + 2: world_interaction + 3: creative + 100: craft_slot + 99999: craft _: source_type? - if INV_SOURCE_TYPE_CONTAINER or INV_SOURCE_TYPE_CREATIVE: + if container or creative: inventory_id: varint - if INV_SOURCE_TYPE_WORLD_INTERACTION: + if world_interaction: flags: varint - if INV_SOURCE_TYPE_CRAFT or INV_SOURCE_TYPE_CRAFT_SLOT: + if craft or craft_slot: action: varint default: void slot: varint old_item: Item new_item: Item - new_item_stack_id: ../has_network_ids? + new_item_stack_id: ../network_ids? if true: zigzag32 default: void transaction_data: transaction_type? - if TYPE_NORMAL or TYPE_INVENTORY_MISMATCH: void - if TYPE_ITEM_USE: + if normal or inventory_mismatch: void + if item_use: action_type: varint face: varint hotbar_slot: varint @@ -322,14 +336,14 @@ Transaction: player_pos: vec3f click_pos: vec3f block_runtime_id: varint - if TYPE_ITEM_USE_ON_ENTITY: + if item_use_on_entity: entity_runtime_id: varint64 action_type: varint hotbar_slot: zigzag32 item_in_hand: Item player_pos: vec3f click_pos: vec3f - if TYPE_ITEM_RELEASE: + if item_release: action_type: varint hotbar_slot: zigzag32 item_in_hand: Item @@ -369,11 +383,11 @@ Recipes: []varint # `furnace`, except it has an input item with a specific metadata value, instead of any metadata value. '3': 'furnace_with_metadata' # 'ENTRY_FURNACE_DATA', // has metadata '4': 'multi' #'ENTRY_MULTI', //TODO - '5': 'shapeless' #'ENTRY_SHULKER_BOX', //TODO - '6': 'shapeless' #'ENTRY_SHAPELESS_CHEMISTRY', //TODO - '7': 'shaped' #'ENTRY_SHAPED_CHEMISTRY', //TODO + '5': 'shulker_box' #'ENTRY_SHULKER_BOX', //TODO + '6': 'shapeless_chemistry' #'ENTRY_SHAPELESS_CHEMISTRY', //TODO + '7': 'shaped_chemistry' #'ENTRY_SHAPED_CHEMISTRY', //TODO recipe: type? - if shapeless: + if shapeless or shulker_box or shapeless_chemistry: recipe_id: string input: RecipeIngredient[]varint output: Item[]varint @@ -381,7 +395,7 @@ Recipes: []varint block: string priority: zigzag32 network_id: zigzag32 - if shaped: + if shaped or shaped_chemistry: recipe_id: string width: zigzag32 height: zigzag32 diff --git a/data/newproto.json b/data/newproto.json index 6be7328..671b939 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -186,26 +186,16 @@ "type": "GameRule" } ], - "Chunks": [ + "Blob": [ "container", [ { - "name": "cache_enabled", - "type": "bool" + "name": "hash", + "type": "lu64" }, { - "anon": true, - "type": [ - "switch", - { - "compareTo": "cache_enabled", - "fields": { - "true": "void", - "false": "void" - }, - "default": "void" - } - ] + "name": "payload", + "type": "string" } ] ], @@ -605,35 +595,36 @@ ] } ], + "Link": [ + "container", + [ + { + "name": "ridden_entity_id", + "type": "zigzag64" + }, + { + "name": "rider_entity_id", + "type": "zigzag64" + }, + { + "name": "type", + "type": "u8" + }, + { + "name": "immediate", + "type": "bool" + }, + { + "name": "rider_initiated", + "type": "bool" + } + ] + ], "Links": [ "array", { "countType": "varint", - "type": [ - "container", - [ - { - "name": "ridden_entity_id", - "type": "zigzag64" - }, - { - "name": "rider_entity_id", - "type": "zigzag64" - }, - { - "name": "type", - "type": "u8" - }, - { - "name": "immediate", - "type": "bool" - }, - { - "name": "rider_initiated", - "type": "bool" - } - ] - ] + "type": "Link" } ], "EntityAttributes": [ @@ -787,17 +778,17 @@ { "type": "varint", "mappings": { - "0": "TYPE_NORMAL", - "1": "TYPE_INVENTORY_MISMATCH", - "2": "TYPE_ITEM_USE", - "3": "TYPE_ITEM_USE_ON_ENTITY", - "4": "TYPE_ITEM_RELEASE" + "0": "normal", + "1": "inventory_mismatch", + "2": "item_use", + "3": "item_use_on_entity", + "4": "item_release" } } ] }, { - "name": "has_network_ids", + "name": "network_ids", "type": "bool" }, { @@ -816,12 +807,12 @@ { "type": "varint", "mappings": { - "0": "INV_SOURCE_TYPE_CONTAINER", - "1": "INV_SOURCE_TYPE_GLOBAL", - "2": "INV_SOURCE_TYPE_WORLD_INTERACTION", - "3": "INV_SOURCE_TYPE_CREATIVE", - "100": "INV_SOURCE_TYPE_CRAFT_SLOT", - "99999": "INV_SOURCE_TYPE_CRAFT" + "0": "container", + "1": "global", + "2": "world_interaction", + "3": "creative", + "100": "craft_slot", + "99999": "craft" } } ] @@ -833,7 +824,7 @@ { "compareTo": "source_type", "fields": { - "INV_SOURCE_TYPE_CONTAINER": [ + "container": [ "container", [ { @@ -842,7 +833,7 @@ } ] ], - "INV_SOURCE_TYPE_CREATIVE": [ + "creative": [ "container", [ { @@ -851,7 +842,7 @@ } ] ], - "INV_SOURCE_TYPE_WORLD_INTERACTION": [ + "world_interaction": [ "container", [ { @@ -860,7 +851,7 @@ } ] ], - "INV_SOURCE_TYPE_CRAFT": [ + "craft": [ "container", [ { @@ -869,7 +860,7 @@ } ] ], - "INV_SOURCE_TYPE_CRAFT_SLOT": [ + "craft_slot": [ "container", [ { @@ -900,7 +891,7 @@ "type": [ "switch", { - "compareTo": "../has_network_ids", + "compareTo": "../network_ids", "fields": { "true": "zigzag32" }, @@ -920,9 +911,9 @@ { "compareTo": "transaction_type", "fields": { - "TYPE_NORMAL": "void", - "TYPE_INVENTORY_MISMATCH": "void", - "TYPE_ITEM_USE": [ + "normal": "void", + "inventory_mismatch": "void", + "item_use": [ "container", [ { @@ -955,7 +946,7 @@ } ] ], - "TYPE_ITEM_USE_ON_ENTITY": [ + "item_use_on_entity": [ "container", [ { @@ -984,7 +975,7 @@ } ] ], - "TYPE_ITEM_RELEASE": [ + "item_release": [ "container", [ { @@ -1142,9 +1133,9 @@ "2": "furnace", "3": "furnace_with_metadata", "4": "multi", - "5": "shapeless", - "6": "shapeless", - "7": "shaped" + "5": "shulker_box", + "6": "shapeless_chemistry", + "7": "shaped_chemistry" } } ] @@ -1201,6 +1192,96 @@ } ] ], + "shulker_box": [ + "container", + [ + { + "name": "recipe_id", + "type": "string" + }, + { + "name": "input", + "type": [ + "array", + { + "countType": "varint", + "type": "RecipeIngredient" + } + ] + }, + { + "name": "output", + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] + }, + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "block", + "type": "string" + }, + { + "name": "priority", + "type": "zigzag32" + }, + { + "name": "network_id", + "type": "zigzag32" + } + ] + ], + "shapeless_chemistry": [ + "container", + [ + { + "name": "recipe_id", + "type": "string" + }, + { + "name": "input", + "type": [ + "array", + { + "countType": "varint", + "type": "RecipeIngredient" + } + ] + }, + { + "name": "output", + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] + }, + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "block", + "type": "string" + }, + { + "name": "priority", + "type": "zigzag32" + }, + { + "name": "network_id", + "type": "zigzag32" + } + ] + ], "shaped": [ "container", [ @@ -1260,6 +1341,65 @@ } ] ], + "shaped_chemistry": [ + "container", + [ + { + "name": "recipe_id", + "type": "string" + }, + { + "name": "width", + "type": "zigzag32" + }, + { + "name": "height", + "type": "zigzag32" + }, + { + "name": "input", + "type": [ + "array", + { + "count": "width", + "type": [ + "array", + { + "count": "height", + "type": "RecipeIngredient" + } + ] + } + ] + }, + { + "name": "output", + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] + }, + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "block", + "type": "string" + }, + { + "name": "priority", + "type": "zigzag32" + }, + { + "name": "network_id", + "type": "zigzag32" + } + ] + ], "furnace": [ "container", [ @@ -2896,7 +3036,7 @@ "type": "BlockCoordinates" }, { - "name": "has_achievements_disabled", + "name": "achievements_disabled", "type": "bool" }, { @@ -2908,7 +3048,7 @@ "type": "zigzag32" }, { - "name": "has_edu_features_enabled", + "name": "edu_features_enabled", "type": "bool" }, { @@ -3394,7 +3534,7 @@ "container", [ { - "name": "unknown", + "name": "jump_strength", "type": "zigzag32" } ] @@ -3929,20 +4069,8 @@ "container", [ { - "name": "ridden_id", - "type": "zigzag64" - }, - { - "name": "rider_id", - "type": "zigzag64" - }, - { - "name": "link_type", - "type": "u8" - }, - { - "name": "unknown", - "type": "u8" + "name": "link", + "type": "Link" } ] ], @@ -3960,10 +4088,19 @@ [ { "name": "spawn_type", - "type": "zigzag32" + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "player", + "1": "world" + } + } + ] }, { - "name": "coordinates", + "name": "player_position", "type": "BlockCoordinates" }, { @@ -3971,7 +4108,7 @@ "type": "zigzag32" }, { - "name": "unknown_coordinates", + "name": "world_position", "type": "BlockCoordinates" } ] @@ -4245,8 +4382,39 @@ "type": "varint" }, { - "name": "column", - "type": "Chunks" + "name": "cache_enabled", + "type": "bool" + }, + { + "name": "blobs", + "type": [ + "switch", + { + "compareTo": "cache_enabled", + "fields": { + "true": [ + "container", + [ + { + "name": "hashes", + "type": [ + "array", + { + "countType": "varint", + "type": "lu64" + } + ] + } + ] + ] + }, + "default": "void" + } + ] + }, + { + "name": "payload", + "type": "string" } ] ], @@ -4383,11 +4551,11 @@ "container", [ { - "name": "unknown1", + "name": "camera_entity_unique_id", "type": "zigzag64" }, { - "name": "unknown2", + "name": "target_player_unique_id", "type": "zigzag64" } ] @@ -4858,35 +5026,35 @@ "type": "u8" }, { - "name": "unknown0", + "name": "size", "type": "varint" }, { - "name": "unknown1", + "name": "trade_tier", "type": "varint" }, { - "name": "unknown2", - "type": "varint" + "name": "villager_unique_id", + "type": "varint64" }, { - "name": "is_willing", - "type": "bool" - }, - { - "name": "trader_entity_id", - "type": "zigzag64" - }, - { - "name": "player_entity_id", - "type": "zigzag64" + "name": "entity_unique_id", + "type": "varint64" }, { "name": "display_name", "type": "string" }, { - "name": "nbt", + "name": "new_trading_ui", + "type": "bool" + }, + { + "name": "economic_trades", + "type": "bool" + }, + { + "name": "offers", "type": "nbt" } ] @@ -4903,7 +5071,7 @@ "type": "u8" }, { - "name": "unknown", + "name": "size", "type": "u8" }, { @@ -4911,7 +5079,7 @@ "type": "zigzag64" }, { - "name": "nbt", + "name": "inventory", "type": "nbt" } ] @@ -5678,22 +5846,50 @@ ], "packet_client_cache_blob_status": [ "container", - [] + [ + { + "name": "missing", + "type": [ + "array", + { + "countType": "varint", + "type": "lu64" + } + ] + }, + { + "name": "have", + "type": [ + "array", + { + "countType": "varint", + "type": "lu64" + } + ] + } + ] ], "packet_client_cache_miss_response": [ "container", - [] + [ + { + "name": "blobs", + "type": [ + "array", + { + "countType": "varint", + "type": "Blob" + } + ] + } + ] ], "packet_network_settings": [ "container", [ - { - "name": "unknown", - "type": "u8" - }, { "name": "compression_threshold", - "type": "u8" + "type": "u16" } ] ], From 57290cd1807e7665fce56570c93a067f51c17e64 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sat, 20 Feb 2021 01:14:59 -0500 Subject: [PATCH 095/106] client packet verification --- src/ConnWorker.js | 2 +- src/client.js | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/clientTest.js | 42 ++++++++++++++++++++++++++++++++---------- src/connection.js | 22 +++++++++++++++++++--- 4 files changed, 96 insertions(+), 15 deletions(-) diff --git a/src/ConnWorker.js b/src/ConnWorker.js index f6d38d3..81e7507 100644 --- a/src/ConnWorker.js +++ b/src/ConnWorker.js @@ -1,4 +1,4 @@ -const RakClient = require('@jsprismarine/raknet/client') +const RakClient = require('jsp-raknet/client') const { Worker, isMainThread, parentPort } = require('worker_threads') const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') diff --git a/src/client.js b/src/client.js index bd2da33..e83d8db 100644 --- a/src/client.js +++ b/src/client.js @@ -119,18 +119,55 @@ class Client extends Connection { process.exit(1) } + tryRencode(name, params, actual) { + if (name == 'level_chunk') { + console.log("Skipping chunk validation, it's broken right now") + return + } + const packet = this.serializer.createPacketBuffer({ name, params }) + + console.assert(packet.toString('hex') == actual.toString('hex')) + if (packet.toString('hex') !== actual.toString('hex')) { + + const ours = packet.toString('hex').match(/.{1,16}/g).join('\n') + const theirs = actual.toString('hex').match(/.{1,16}/g).join('\n') + + fs.writeFileSync('ours.txt', ours) + fs.writeFileSync('theirs.txt', theirs) + fs.writeFileSync('ours.json', serialize(params)) + fs.writeFileSync('theirs.json', serialize(this.deserializer.parsePacketBuffer(packet).data.params)) + + throw new Error(name + ' Packet comparison failed!') + } + } + readPacket(packet) { // console.log('packet', packet) const des = this.deserializer.parsePacketBuffer(packet) const pakData = { name: des.data.name, params: des.data.params } console.log('->', pakData.name, serialize(pakData.params).slice(0, 100)) + + // No idea what this exotic 0xA0 packet is, it's not implemented anywhere + // and seems empty. Possible gibberish from the raknet impl + if (pakData.name == '160' || !pakData.name) { // eslint-ignore-line + console.warn('?? Ignoring extraneous packet ', des) + return + } + + // Packet verifying (decode + re-encode + match test) + if (pakData.name) { + this.tryRencode(pakData.name, pakData.params, packet) + } + // console.info('->', JSON.stringify(pakData, (k,v) => typeof v == 'bigint' ? v.toString() : v)) + // Packet dumping try { if (!fs.existsSync(`./packets/${pakData.name}.json`)) { fs.writeFileSync(`./packets/${pakData.name}.json`, serialize(pakData.params, 2)) fs.writeFileSync(`./packets/${pakData.name}.txt`, packet.toString('hex')) } - } catch {} + } catch { } + switch (des.data.name) { case 'server_to_client_handshake': this.emit('client.server_handshake', des.data.params) @@ -143,6 +180,10 @@ class Client extends Connection { break case 'start_game': fs.writeFileSync('start_game.json', JSON.stringify(des.data.params, (k, v) => typeof v == 'bigint' ? v.toString() : v)) + break + case 'level_chunk': + fs.writeFileSync(`./chunks/chunk-${chunks++}.txt`, packet.toString('hex')) + break default: // console.log('Sending to listeners') } @@ -151,6 +192,8 @@ class Client extends Connection { } } +var chunks = 0; + function serialize(obj = {}, fmt) { return JSON.stringify(obj, (k, v) => typeof v == 'bigint' ? v.toString() : v, fmt) } diff --git a/src/clientTest.js b/src/clientTest.js index 39bb310..43af281 100644 --- a/src/clientTest.js +++ b/src/clientTest.js @@ -1,20 +1,42 @@ // process.env.DEBUG = 'minecraft-protocol raknet' const { Client } = require('./client') - +const fs = require('fs') // console.log = () => async function test() { - const client = new Client({ - hostname: '127.0.0.1', - port: 19132 + const client = new Client({ + hostname: '127.0.0.1', + port: 19132 + }) + + client.once('resource_packs_info', (packet) => { + client.write('resource_pack_client_response', { + response_status: 'completed', + resourcepackids: [] }) - - client.once('resource_packs_info', (packet) => { - client.write('resource_pack_client_response', { - response_status: 'completed', - resourcepackids: [] - }) + + client.once('resource_pack_stack', (stack) => { + client.write('resource_pack_client_response', { + response_status: 'completed', + resourcepackids: [] + }) }) + + // client.once('resource_packs_info', (packet) => { + // client.write('resource_pack_client_response', { + // response_status: 'completed', + // resourcepackids: [] + // }) + // }) + }) + + + + // var read = 0; + // client.on('level_chunk', (packet) => { + // read++ + // fs.writeFileSync(`level_chunk-${read}.json`, JSON.stringify(packet, null, 2)) + // }) } test() \ No newline at end of file diff --git a/src/connection.js b/src/connection.js index 1ecbee2..3fa2475 100644 --- a/src/connection.js +++ b/src/connection.js @@ -2,8 +2,8 @@ const BinaryStream = require('@jsprismarine/jsbinaryutils').default const BatchPacket = require('./datatypes/BatchPacket') const cipher = require('./transforms/encryption') const { EventEmitter } = require('events') -const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') - +const EncapsulatedPacket = require('jsp-raknet/protocol/encapsulated_packet') +const debug = require('debug')('minecraft-protocol') class Connection extends EventEmitter { startEncryption(iv) { @@ -15,8 +15,10 @@ class Connection extends EventEmitter { write(name, params) { // TODO: Batch console.log('Need to encode', name, params) + // console.log('<-', name) const batch = new BatchPacket() const packet = this.serializer.createPacketBuffer({ name, params }) + console.log('Sending buf', packet.toString('hex')) batch.addEncodedPacket(packet) if (this.encryptionEnabled) { @@ -45,6 +47,19 @@ class Connection extends EventEmitter { } } + /** + * Sends a MCPE packet buffer + */ + sendBuffer(buffer) { + const batch = new BatchPacket() + batch.addEncodedPacket(buffer) + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } + } + sendDecryptedBatch(batch) { const buf = batch.encode() // send to raknet @@ -53,10 +68,11 @@ class Connection extends EventEmitter { sendEncryptedBatch(batch) { const buf = batch.stream.getBuffer() - console.log('Sending encrypted batch', batch) + debug('Sending encrypted batch', batch) this.encrypt(buf) } + // TODO: Rename this to sendEncapsulated sendMCPE(buffer, immediate) { if (this.worker) { console.log('-> buf', buffer) From f3604fa9b543d554ccffef2ecfaca298b6e9a8ee Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 21 Feb 2021 15:22:04 -0500 Subject: [PATCH 096/106] protocol updates Add some updates --- data/new/proto.yml | 142 +++++++++++++++- data/new/types.yaml | 65 +++++++- data/newproto.json | 248 ++++++++++++++++++++++++++-- src/datatypes/compiler-minecraft.js | 58 ++++++- 4 files changed, 479 insertions(+), 34 deletions(-) diff --git a/data/new/proto.yml b/data/new/proto.yml index 6bbb0d5..b209d4f 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -200,7 +200,18 @@ packet_start_game: # The runtime ID of the player. The runtime ID is unique for each world session, # and entities are generally identified in packets using this runtime ID. runtime_entity_id: varint64 - player_gamemode: zigzag32 + # PlayerGameMode is the game mode the player currently has. It is a value from 0-4, with 0 being + # survival mode, 1 being creative mode, 2 being adventure mode, 3 being survival spectator and 4 being + # creative spectator. + # This field may be set to 5 to make the client fall back to the game mode set in the WorldGameMode + # field. + player_gamemode: zigzag32 => + 0: survival + 1: creative + 2: adventure + 3: survival_spectator + 4: creative_spectator + 5: fallback # The spawn position of the player in the world. In servers this is often the same as the # world's spawn position found below. spawn: vec3f @@ -680,11 +691,25 @@ packet_mob_armor_equipment: leggings: Item boots: Item +# Interact is sent by the client when it interacts with another entity in some way. It used to be used for +# normal entity and block interaction, but this is no longer the case now. packet_interact: !id: 0x21 !bound: both - action_id: u8 + # Action type is the ID of the action that was executed by the player. It is one of the constants that + # may be found above. + action_id: u8 => + 3: leave_vehicle + 4: mouse_over_entity + 6: open_inventory + # TargetEntityRuntimeID is the runtime ID of the entity that the player interacted with. This is empty + # for the InteractActionOpenInventory action type. target_runtime_entity_id: varint + # Position associated with the ActionType above. For the InteractActionMouseOverEntity, this is the + # position relative to the entity moused over over which the player hovered with its mouse/touch. For the + # InteractActionLeaveVehicle, this is the position that the player spawns at after leaving the vehicle. + position: action_id ? + if mouse_over_entity or leave_vehicle: vec3f packet_block_pick_request: !id: 0x22 @@ -865,16 +890,75 @@ packet_gui_data_pick_item: !id: 0x36 !bound: client + +# AdventureSettings is sent by the server to update game-play related features, in particular permissions to +# access these features for the client. It includes allowing the player to fly, build and mine, and attack +# entities. Most of these flags should be checked server-side instead of using this packet only. +# The client may also send this packet to the server when it updates one of these settings through the +# in-game settings interface. The server should verify if the player actually has permission to update those +# settings. packet_adventure_settings: !id: 0x37 !bound: both - flags: varint - command_permission: varint - action_permissions: varint - permission_level: varint + # Flags is a set of flags that specify certain properties of the player, such as whether or not it can + # fly and/or move through blocks. It is one of the AdventureFlag constants above. + flags: AdventureFlags + # CommandPermissionLevel is a permission level that specifies the kind of commands that the player is + # allowed to use. + command_permission: varint32 => + 0: normal + 1: operator + 2: host + 3: automation + 4: admin + # ActionPermissions is, much like Flags, a set of flags that specify actions that the player is allowed + # to undertake, such as whether it is allowed to edit blocks, open doors etc. It is a combination of the + # ActionPermission constants above. + action_permissions: ActionPermissions + # PermissionLevel is the permission level of the player as it shows up in the player list built up using + # the PlayerList packet. It is one of the PermissionLevel constants above. + permission_level: varint => + 0: visitor + 1: member + 2: operator + 3: custom + # Custom permissions custom_stored_permissions: varint + # PlayerUniqueID is a unique identifier of the player. It appears it is not required to fill this field + # out with a correct value. Simply writing 0 seems to work. user_id: li64 +AdventureFlags: [ "bitflags", + { + "type": "varint", + "flags": { + "world_immutable": 1, + "no_pvp": 2, + "auto_jump": 0x20, + "allow_flight": 0x40, + "no_clip": 0x80, + "world_builder": 0x100, + "flying": 0x200, + "muted": 0x400 + } + } +] + +ActionPermissions: [ "bitflags", + { + "type": "varint", + "flags": { + "build_and_mine": 0x10001, + "doors_and_switches": 0x10002, + "open_containers": 0x10004, + "attack_players": 0x10008, + "attack_mobs": 0x10010, + "operator": 0x10020, + "teleport": 0x10080, + } + } +] + packet_block_entity_data: !id: 0x38 !bound: both @@ -1547,21 +1631,61 @@ packet_update_block_synced: unknown0: varint unknown1: varint +# MoveActorDelta is sent by the server to move an entity. The packet is specifically optimised to save as +# much space as possible, by only writing non-zero fields. +# As of 1.16.100, this packet no longer actually contains any deltas. packet_move_entity_delta: !id: 0x6f !bound: client - runtime_entity_id: varint - flags: lu16 + # EntityRuntimeID is the runtime ID of the entity that is being moved. The packet works provided a + # non-player entity with this runtime ID is present. + runtime_entity_id: varint64 + # Flags is a list of flags that specify what data is in the packet. + flags: DeltaMoveFlags + x: flags.has_x? + if true: lf32 + y: flags.has_y? + if true: lf32 + z: flags.has_z? + if true: lf32 + rot_x: flags.has_rot_x? + if true: u8 # TODO: * implement ByteFloat + rot_y: flags.has_rot_y? + if true: u8 + rot_z: flags.has_rot_z? + if true: u8 + +DeltaMoveFlags: [ "bitflags", + { + "type": "lu16", + "flags": { + "has_x": 0x01, + "has_y": 0x02, + "has_z": 0x04, + "has_rot_x": 0x08, + "has_rot_y": 0x10, + "has_rot_z": 0x20, + "on_ground": 0x40, + "teleport": 0x80, + "force_move": 0x100 + } + } +] packet_set_scoreboard_identity: !id: 0x70 !bound: client entries: ScoreboardIdentityEntries +# SetLocalPlayerAsInitialised is sent by the client in response to a PlayStatus packet with the status set +# to spawn. The packet marks the moment at which the client is fully initialised and can receive any packet +# without discarding it. packet_set_local_player_as_initialized: !id: 0x71 !bound: server - runtime_entity_id: varint + # EntityRuntimeID is the entity runtime ID the player was assigned earlier in the login sequence in the + # StartGame packet. + runtime_entity_id: varint64 packet_update_soft_enum: !id: 0x72 diff --git a/data/new/types.yaml b/data/new/types.yaml index a0835b1..8f6b109 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -328,25 +328,76 @@ Transaction: default: void transaction_data: transaction_type? if normal or inventory_mismatch: void + # UseItemTransactionData represents an inventory transaction data object sent when the client uses an item on + # a block. if item_use: - action_type: varint + # ActionType is the type of the UseItem inventory transaction. It is one of the action types found above, + # and specifies the way the player interacted with the block. + action_type: varint => + 0: click_block + 1: click_air + 2: break_block + # BlockPosition is the position of the block that was interacted with. This is only really a correct + # block position if ActionType is not UseItemActionClickAir. + block_position: BlockCoordinates + # BlockFace is the face of the block that was interacted with. When clicking the block, it is the face + # clicked. When breaking the block, it is the face that was last being hit until the block broke. face: varint + # HotBarSlot is the hot bar slot that the player was holding while clicking the block. It should be used + # to ensure that the hot bar slot and held item are correctly synchronised with the server. hotbar_slot: varint - item_in_hand: Item + # HeldItem is the item that was held to interact with the block. The server should check if this item + # is actually present in the HotBarSlot. + held_item: Item + # Position is the position of the player at the time of interaction. For clicking a block, this is the + # position at that time, whereas for breaking the block it is the position at the time of breaking. player_pos: vec3f + # ClickedPosition is the position that was clicked relative to the block's base coordinate. It can be + # used to find out exactly where a player clicked the block. click_pos: vec3f + # BlockRuntimeID is the runtime ID of the block that was clicked. It may be used by the server to verify + # that the player's world client-side is synchronised with the server's. block_runtime_id: varint + # UseItemOnEntityTransactionData represents an inventory transaction data object sent when the client uses + # an item on an entity. if item_use_on_entity: + # TargetEntityRuntimeID is the entity runtime ID of the target that was clicked. It is the runtime ID + # that was assigned to it in the AddEntity packet. entity_runtime_id: varint64 - action_type: varint + # ActionType is the type of the UseItemOnEntity inventory transaction. It is one of the action types + # found in the constants above, and specifies the way the player interacted with the entity. + action_type: varint => + 0: interact + 1: attack + # HotBarSlot is the hot bar slot that the player was holding while clicking the entity. It should be used + # to ensure that the hot bar slot and held item are correctly synchronised with the server. hotbar_slot: zigzag32 - item_in_hand: Item + # HeldItem is the item that was held to interact with the entity. The server should check if this item + # is actually present in the HotBarSlot. + held_item: Item + # Position is the position of the player at the time of clicking the entity. player_pos: vec3f - click_pos: vec3f + # ClickedPosition is the position that was clicked relative to the entity's base coordinate. It can be + # used to find out exactly where a player clicked the entity. + click_pos: vec3f + # ReleaseItemTransactionData represents an inventory transaction data object sent when the client releases + # the item it was using, for example when stopping while eating or stopping the charging of a bow. if item_release: - action_type: varint + # ActionType is the type of the ReleaseItem inventory transaction. It is one of the action types found + # in the constants above, and specifies the way the item was released. + # As of 1.13, the ActionType is always 0. This field can be ignored, because releasing food (by consuming + # it) or releasing a bow (to shoot an arrow) is essentially the same. + action_type: varint => + 0: release + 1: consume + # HotBarSlot is the hot bar slot that the player was holding while releasing the item. It should be used + # to ensure that the hot bar slot and held item are correctly synchronised with the server. hotbar_slot: zigzag32 - item_in_hand: Item + # HeldItem is the item that was released. The server should check if this item is actually present in the + # HotBarSlot. + held_item: Item + # HeadPosition is the position of the player's head at the time of releasing the item. This is used + # mainly for purposes such as spawning eating particles at that position. head_pos: vec3f ItemStacks: []varint diff --git a/data/newproto.json b/data/newproto.json index 671b939..689ff79 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -918,7 +918,21 @@ [ { "name": "action_type", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "click_block", + "1": "click_air", + "2": "break_block" + } + } + ] + }, + { + "name": "block_position", + "type": "BlockCoordinates" }, { "name": "face", @@ -929,7 +943,7 @@ "type": "varint" }, { - "name": "item_in_hand", + "name": "held_item", "type": "Item" }, { @@ -955,14 +969,23 @@ }, { "name": "action_type", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "interact", + "1": "attack" + } + } + ] }, { "name": "hotbar_slot", "type": "zigzag32" }, { - "name": "item_in_hand", + "name": "held_item", "type": "Item" }, { @@ -980,14 +1003,23 @@ [ { "name": "action_type", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "release", + "1": "consume" + } + } + ] }, { "name": "hotbar_slot", "type": "zigzag32" }, { - "name": "item_in_hand", + "name": "held_item", "type": "Item" }, { @@ -2993,7 +3025,20 @@ }, { "name": "player_gamemode", - "type": "zigzag32" + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "survival", + "1": "creative", + "2": "adventure", + "3": "survival_spectator", + "4": "creative_spectator", + "5": "fallback" + } + } + ] }, { "name": "spawn", @@ -3926,11 +3971,35 @@ [ { "name": "action_id", - "type": "u8" + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "3": "leave_vehicle", + "4": "mouse_over_entity", + "6": "open_inventory" + } + } + ] }, { "name": "target_runtime_entity_id", "type": "varint" + }, + { + "name": "position", + "type": [ + "switch", + { + "compareTo": "action_id", + "fields": { + "mouse_over_entity": "vec3f", + "leave_vehicle": "vec3f" + }, + "default": "void" + } + ] } ] ], @@ -4308,19 +4377,42 @@ [ { "name": "flags", - "type": "varint" + "type": "AdventureFlags" }, { "name": "command_permission", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint32", + "mappings": { + "0": "normal", + "1": "operator", + "2": "host", + "3": "automation", + "4": "admin" + } + } + ] }, { "name": "action_permissions", - "type": "varint" + "type": "ActionPermissions" }, { "name": "permission_level", - "type": "varint" + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "visitor", + "1": "member", + "2": "operator", + "3": "custom" + } + } + ] }, { "name": "custom_stored_permissions", @@ -5611,11 +5703,89 @@ [ { "name": "runtime_entity_id", - "type": "varint" + "type": "varint64" }, { "name": "flags", - "type": "lu16" + "type": "DeltaMoveFlags" + }, + { + "name": "x", + "type": [ + "switch", + { + "compareTo": "flags.has_x", + "fields": { + "true": "lf32" + }, + "default": "void" + } + ] + }, + { + "name": "y", + "type": [ + "switch", + { + "compareTo": "flags.has_y", + "fields": { + "true": "lf32" + }, + "default": "void" + } + ] + }, + { + "name": "z", + "type": [ + "switch", + { + "compareTo": "flags.has_z", + "fields": { + "true": "lf32" + }, + "default": "void" + } + ] + }, + { + "name": "rot_x", + "type": [ + "switch", + { + "compareTo": "flags.has_rot_x", + "fields": { + "true": "u8" + }, + "default": "void" + } + ] + }, + { + "name": "rot_y", + "type": [ + "switch", + { + "compareTo": "flags.has_rot_y", + "fields": { + "true": "u8" + }, + "default": "void" + } + ] + }, + { + "name": "rot_z", + "type": [ + "switch", + { + "compareTo": "flags.has_rot_z", + "fields": { + "true": "u8" + }, + "default": "void" + } + ] } ] ], @@ -5633,7 +5803,7 @@ [ { "name": "runtime_entity_id", - "type": "varint" + "type": "varint64" } ] ], @@ -5994,6 +6164,37 @@ "countType": "li32" } ], + "AdventureFlags": [ + "bitflags", + { + "type": "varint", + "flags": { + "world_immutable": 1, + "no_pvp": 2, + "auto_jump": 32, + "allow_flight": 64, + "no_clip": 128, + "world_builder": 256, + "flying": 512, + "muted": 1024 + } + } + ], + "ActionPermissions": [ + "bitflags", + { + "type": "varint", + "flags": { + "build_and_mine": 65537, + "doors_and_switches": 65538, + "open_containers": 65540, + "attack_players": 65544, + "attack_mobs": 65552, + "operator": 65568, + "teleport": 65664 + } + } + ], "CommandFlags": [ "bitfield", [ @@ -6013,6 +6214,23 @@ "signed": false } ] + ], + "DeltaMoveFlags": [ + "bitflags", + { + "type": "lu16", + "flags": { + "has_x": 1, + "has_y": 2, + "has_z": 4, + "has_rot_x": 8, + "has_rot_y": 16, + "has_rot_z": 32, + "on_ground": 64, + "teleport": 128, + "force_move": 256 + } + } ] } } \ No newline at end of file diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js index 7130749..8d1e10f 100644 --- a/src/datatypes/compiler-minecraft.js +++ b/src/datatypes/compiler-minecraft.js @@ -45,18 +45,70 @@ Read.nbt = ['native', minecraft.nbt[0]] Write.nbt = ['native', minecraft.nbt[1]] SizeOf.nbt = ['native', minecraft.nbt[2]] +/** + * Bits + */ +// nvm, +// Read.bitflags = ['parametrizable', (compiler, { type, flags }) => { + // return compiler.wrapCode(` + // const { value, size } = ${compiler.callType('buffer, offset', type)} + // const val = {} + // for (let i = 0; i < size; i++) { + // const hi = (value >> i) & 1 + // if () + // const v = value & + // if (flags[i]) + // } + // ` +// }] + +Read.bitflags = ['parametrizable', (compiler, { type, flags }) => { + return compiler.wrapCode(` + const { value: _value, size } = ${compiler.callType(type, 'offset')} + const value = { _value } + const flags = ${JSON.stringify(flags)} + for (const key in flags) { + value[key] = (_value & flags[key]) == flags[key] + } + return { value, size } + `.trim()) +}] + + +Write.bitflags = ['parametrizable', (compiler, { type, flags }) => { + return compiler.wrapCode(` + const flags = ${JSON.stringify(flags)} + let val = value._value + for (const key in flags) { + if (value[key]) val |= flags[key] + } + return (ctx.${type})(val, buffer, offset) + `.trim()) +}] + +SizeOf.bitflags = ['parametrizable', (compiler, { type, flags }) => { + return compiler.wrapCode(` + const flags = ${JSON.stringify(flags)} + let val = value._value + for (const key in flags) { + if (value[key]) val |= flags[key] + } + return (ctx.${type})(val) + `.trim()) +}] + /** * Command Packet * - used for determining the size of the following enum */ -Read.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { +Read.enum_size_based_on_values_len = ['parametrizable', (compiler) => { return compiler.wrapCode(js(() => { if (values_len <= 0xff) return { value: 'byte', size: 0 } if (values_len <= 0xffff) return { value: 'short', size: 0 } if (values_len <= 0xffffff) return { value: 'int', size: 0 } })) }] -Write.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { +Write.enum_size_based_on_values_len = ['parametrizable', (compiler) => { return str(() => { if (value.values_len <= 0xff) _enum_type = 'byte' else if (value.values_len <= 0xffff) _enum_type = 'short' @@ -64,7 +116,7 @@ Write.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { return offset }) }] -SizeOf.enum_size_based_on_values_len = ['parametrizable', (compiler, array) => { +SizeOf.enum_size_based_on_values_len = ['parametrizable', (compiler) => { return str(() => { if (value.values_len <= 0xff) _enum_type = 'byte' else if (value.values_len <= 0xffff) _enum_type = 'short' From 4035295cdd2855b1105758de36738e2ea3d9c6ca Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 21 Feb 2021 15:26:34 -0500 Subject: [PATCH 097/106] packet batching + working client/server spawning --- src/client.js | 9 +--- src/clientTest.js | 5 ++ src/connection.js | 48 +++++++++++++---- src/server.js | 112 ++++++--------------------------------- src/serverPlayer.js | 126 ++++++++++++++++++++++++++++++++++++++++++++ src/serverTest.js | 125 ++++++++++++++++++++++++++++++------------- 6 files changed, 275 insertions(+), 150 deletions(-) create mode 100644 src/serverPlayer.js diff --git a/src/client.js b/src/client.js index e83d8db..6ceca76 100644 --- a/src/client.js +++ b/src/client.js @@ -28,6 +28,7 @@ class Client extends Connection { } this.on('session', this.connect) + this.startQueue() // this.on('decrypted', this.onDecryptedPacket) } @@ -104,14 +105,6 @@ class Client extends Connection { }) } - // After sending Server to Client Handshake, this handles the client's - // Client to Server handshake response. This indicates successful encryption - onHandshake() { - // https://wiki.vg/Bedrock_Protocol#Play_Status - this.write('play_status', { status: PLAY_STATUS.LoginSuccess }) - this.emit('join') - } - onDisconnectRequest(packet) { // We're talking over UDP, so there is no connection to close, instead // we stop communicating with the server diff --git a/src/clientTest.js b/src/clientTest.js index 43af281..75a621d 100644 --- a/src/clientTest.js +++ b/src/clientTest.js @@ -28,6 +28,11 @@ async function test() { // resourcepackids: [] // }) // }) + + client.queue('client_cache_status', { enabled: false }) + client.queue('request_chunk_radius', { chunk_radius: 1 }) + client.queue('tick_sync', { request_time: BigInt(Date.now()), response_time: 0n }) + }) diff --git a/src/connection.js b/src/connection.js index 3fa2475..44f3891 100644 --- a/src/connection.js +++ b/src/connection.js @@ -18,7 +18,7 @@ class Connection extends EventEmitter { // console.log('<-', name) const batch = new BatchPacket() const packet = this.serializer.createPacketBuffer({ name, params }) - console.log('Sending buf', packet.toString('hex')) + // console.log('Sending buf', packet.toString('hex').) batch.addEncodedPacket(packet) if (this.encryptionEnabled) { @@ -28,6 +28,33 @@ class Connection extends EventEmitter { } } + queue(name, params) { + console.log('<- ', name) + const packet = this.serializer.createPacketBuffer({ name, params }) + this.q.push(packet) + } + + startQueue() { + this.q = [] + this.loop = setInterval(() => { + if (this.q.length) { + //TODO: can we just build Batch before the queue loop? + const batch = new BatchPacket() + // For now, we're over conservative so send max 3 packets + // per batch and hold the rest for the next tick + for (let i = 0; i < 3 && i < this.q.length; i++) { + const packet = this.q.shift() + batch.addEncodedPacket(packet) + } + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } + } + }, 100) + } + writeRaw(name, buffer) { // skip protodef serializaion // temporary hard coded stuff const batch = new BatchPacket() @@ -37,7 +64,6 @@ class Connection extends EventEmitter { stream.writeUnsignedVarInt(0x7a) stream.append(buffer) batch.addEncodedPacket(stream.getBuffer()) - // console.log('----- SENDING BIOME DEFINITIONS') } if (this.encryptionEnabled) { @@ -50,13 +76,17 @@ class Connection extends EventEmitter { /** * Sends a MCPE packet buffer */ - sendBuffer(buffer) { - const batch = new BatchPacket() - batch.addEncodedPacket(buffer) - if (this.encryptionEnabled) { - this.sendEncryptedBatch(batch) + sendBuffer(buffer, immediate = false) { + if (immediate) { + const batch = new BatchPacket() + batch.addEncodedPacket(buffer) + if (this.encryptionEnabled) { + this.sendEncryptedBatch(batch) + } else { + this.sendDecryptedBatch(batch) + } } else { - this.sendDecryptedBatch(batch) + this.q.push(buffer) } } @@ -78,7 +108,7 @@ class Connection extends EventEmitter { console.log('-> buf', buffer) this.worker.postMessage({ type: 'queueEncapsulated', packet: buffer, immediate }) } else { - const sendPacket = new EncapsulatedPacket(); + const sendPacket = new EncapsulatedPacket() sendPacket.reliability = 0 sendPacket.buffer = buffer this.connection.addEncapsulatedToQueue(sendPacket) diff --git a/src/server.js b/src/server.js index 7db207d..f94b573 100644 --- a/src/server.js +++ b/src/server.js @@ -1,90 +1,10 @@ -const Listener = require('@jsprismarine/raknet/listener') +const Listener = require('jsp-raknet/listener') const { EventEmitter } = require('events') const { createDeserializer, createSerializer } = require('./transforms/serializer') -const { Encrypt } = require('./auth/encryption') -const { decodeLoginJWT } = require('./auth/chains') -const { Connection } = require('./connection') +const { Player } = require('./serverPlayer') + const Options = require('./options') - -const log = (...args) => console.log(...args) - -class Player extends Connection { - constructor(server, connection, options) { - super() - this.server = server - this.serializer = server.serializer - this.connection = connection - Encrypt(this, server, options) - } - - getData() { - return this.userData - } - - onLogin(packet) { - let body = packet.data - console.log('Body', body) - - const clientVer = body.protocol_version - if (this.server.options.version) { - if (this.server.options.version < clientVer) { - this.sendDisconnectStatus(failed_client) - return - } - } else if (clientVer < MIN_VERSION) { - this.sendDisconnectStatus(failed_client) - return - } - - // Parse login data - const authChain = JSON.parse(body.params.chain) - const skinChain = body.params.client_data - - try { - var { key, userData, chain } = decodeLoginJWT(authChain.chain, skinChain) - } catch (e) { - console.error(e) - throw new Error('Failed to verify user') - } - console.log('Verified user', 'got pub key', key, userData) - - this.emit('login', { user: userData.extraData }) // emit events for user - this.emit('server.client_handshake', { key }) // internal so we start encryption - - this.userData = userData.extraData - this.version = clientVer - } - - sendDisconnectStatus(play_status) { - this.write('play_status', { status: play_status }) - this.connection.close() - } - - // After sending Server to Client Handshake, this handles the client's - // Client to Server handshake response. This indicates successful encryption - onHandshake() { - // https://wiki.vg/Bedrock_Protocol#Play_Status - this.write('play_status', { status: 'login_success' }) - this.emit('join') - } - - readPacket(packet) { - console.log('packet', packet) - const des = this.server.deserializer.parsePacketBuffer(packet) - console.log('->', des) - switch (des.data.name) { - case 'login': - console.log(des) - this.onLogin(des) - return - case 'client_to_server_handshake': - this.onHandshake() - default: - console.log('ignoring, unhandled') - } - this.emit(des.data.name, des.data.params) - } -} +const debug = require('debug')('minecraft-protocol') class Server extends EventEmitter { constructor(options) { @@ -102,27 +22,23 @@ class Server extends EventEmitter { } } - getAddrHash(inetAddr) { - return inetAddr.address + '/' + inetAddr.port - } - onOpenConnection = (conn) => { - log('new connection', conn) + debug('new connection', conn) const player = new Player(this, conn) - this.clients[this.getAddrHash(conn.address)] = player + this.clients[hash(conn.address)] = player this.emit('connect', { client: player }) } onCloseConnection = (inetAddr, reason) => { - log('close connection', inetAddr, reason) - delete this.clients[this.getAddrHash(inetAddr)] + debug('close connection', inetAddr, reason) + delete this.clients[hash(inetAddr)] } onEncapsulated = (encapsulated, inetAddr) => { - log(inetAddr.address, ': Encapsulated', encapsulated) + debug(inetAddr.address, 'Encapsulated', encapsulated) const buffer = encapsulated.buffer - const client = this.clients[this.getAddrHash(inetAddr)] + const client = this.clients[hash(inetAddr)] if (!client) { throw new Error(`packet from unknown inet addr: ${inetAddr.address}/${inetAddr.port}`) } @@ -132,16 +48,18 @@ class Server extends EventEmitter { async create(serverIp, port) { this.listener = new Listener(this) this.raknet = await this.listener.listen(serverIp, port) - log('Listening on', serverIp, port) + console.debug('Listening on', serverIp, port) this.raknet.on('openConnection', this.onOpenConnection) this.raknet.on('closeConnection', this.onCloseConnection) this.raknet.on('encapsulated', this.onEncapsulated) this.raknet.on('raw', (buffer, inetAddr) => { - console.log('Raw packet', buffer, inetAddr) + debug('Raw packet', buffer, inetAddr) }) } } -module.exports = { Server, Player } \ No newline at end of file +const hash = (inetAddr) => inetAddr.address + '/' + inetAddr.port + +module.exports = { Server } \ No newline at end of file diff --git a/src/serverPlayer.js b/src/serverPlayer.js new file mode 100644 index 0000000..86d10bc --- /dev/null +++ b/src/serverPlayer.js @@ -0,0 +1,126 @@ +const { Encrypt } = require('./auth/encryption') +const { decodeLoginJWT } = require('./auth/chains') +const { Connection } = require('./connection') +const fs = require('fs') +const debug = require('debug')('minecraft-protocol') + +const ClientStatus = { + Authenticating: 0, + Initializing: 1, + Initialized: 2 +} + +class Player extends Connection { + constructor(server, connection, options) { + super() + this.server = server + this.serializer = server.serializer + this.connection = connection + Encrypt(this, server, options) + + this.startQueue() + this.status = ClientStatus.Authenticating + } + + getData() { + return this.userData + } + + onLogin(packet) { + let body = packet.data + debug('Body', body) + this.emit('loggingIn', body) + + const clientVer = body.protocol_version + if (this.server.options.version) { + if (this.server.options.version < clientVer) { + this.sendDisconnectStatus(failed_client) + return + } + } else if (clientVer < MIN_VERSION) { + this.sendDisconnectStatus(failed_client) + return + } + + // Parse login data + const authChain = JSON.parse(body.params.chain) + const skinChain = body.params.client_data + + try { + var { key, userData, chain } = decodeLoginJWT(authChain.chain, skinChain) + } catch (e) { + console.error(e) + throw new Error('Failed to verify user') + } + console.log('Verified user', 'got pub key', key, userData) + + this.emit('login', { user: userData.extraData }) // emit events for user + this.emit('server.client_handshake', { key }) // internal so we start encryption + + this.userData = userData.extraData + this.version = clientVer + } + + + /** + * Disconnects a client before it has joined + * @param {string} play_status + */ + sendDisconnectStatus(play_status) { + this.write('play_status', { status: play_status }) + this.connection.close() + } + + /** + * Disconnects a client after it has joined + */ + disconnect(reason, hide = false) { + this.write('disconnect', { + hide_disconnect_screen: hide, + message: reason + }) + this.connection.close() + } + + // After sending Server to Client Handshake, this handles the client's + // Client to Server handshake response. This indicates successful encryption + onHandshake() { + // https://wiki.vg/Bedrock_Protocol#Play_Status + this.write('play_status', { status: 'login_success' }) + this.status = ClientStatus.Initializing + this.emit('join') + } + + readPacket(packet) { + // console.log('packet', packet) + try { + var des = this.server.deserializer.parsePacketBuffer(packet) + } catch (e) { + this.disconnect('Server error') + console.warn('Packet parsing failed! Writing dump to ./packetdump.bin') + fs.writeFileSync('packetdump.bin', packet) + fs.writeFileSync('packetdump.txt', packet.toString('hex')) + throw e + } + + console.log('->', des) + switch (des.data.name) { + case 'login': + console.log(des) + this.onLogin(des) + return + case 'client_to_server_handshake': + // Emit the 'join' event + this.onHandshake() + case 'set_local_player_as_initialized': + this.state = ClientStatus.Initialized + // Emit the 'spawn' event + this.emit('spawn') + default: + console.log('ignoring, unhandled') + } + this.emit(des.data.name, des.data.params) + } +} + +module.exports = { Player, ClientStatus } \ No newline at end of file diff --git a/src/serverTest.js b/src/serverTest.js index 0d733f6..ad54097 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -1,3 +1,4 @@ +// process.env.DEBUG = 'minecraft-protocol raknet' const { Server } = require('./server') const CreativeItems = require('../data/creativeitems.json') const NBT = require('prismarine-nbt') @@ -24,7 +25,7 @@ server.on('connect', ({ client }) => { 'texture_packs': [] }) - client.once('resource_pack_client_response', (packet) => { + client.once('resource_pack_client_response', async (packet) => { // ResourcePackStack is sent by the server to send the order in which resource packs and behaviour packs // should be applied (and downloaded) by the client. client.write('resource_pack_stack', { @@ -37,45 +38,97 @@ server.on('connect', ({ client }) => { }) client.once('resource_pack_client_response', async (packet) => { - ran = true - let items = [] - let ids = 0 - for (var item of CreativeItems) { - let creativeitem = { runtime_id: items.length } - const has_nbt = !!item.nbt_b64 - if (item.id != 0) { - creativeitem.item = { - network_id: item.id, - auxiliary_value: item.damage || 0, - has_nbt, - nbt: { - version: 1, - }, - blocking_tick: 0, - can_destroy: [], - can_place_on: [] - } - if (has_nbt) { - let nbtBuf = Buffer.from(item.nbt_b64, 'base64') - let { parsed } = await NBT.parse(nbtBuf, 'little') - creativeitem.item.nbt.nbt = parsed - } - } - items.push(creativeitem) - // console.log(creativeitem) - } + // ran = true + // let items = [] + // let ids = 0 + // for (var item of CreativeItems) { + // let creativeitem = { runtime_id: items.length } + // const has_nbt = !!item.nbt_b64 + // if (item.id != 0) { + // creativeitem.item = { + // network_id: item.id, + // auxiliary_value: item.damage || 0, + // has_nbt, + // nbt: { + // version: 1, + // }, + // blocking_tick: 0, + // can_destroy: [], + // can_place_on: [] + // } + // if (has_nbt) { + // let nbtBuf = Buffer.from(item.nbt_b64, 'base64') + // let { parsed } = await NBT.parse(nbtBuf, 'little') + // creativeitem.item.nbt.nbt = parsed + // } + // } + // items.push(creativeitem) + // // console.log(creativeitem) + // } - console.log(items, ids) + // console.log(items, ids) - client.write('creative_content', { items }) + // client.write('creative_content', { items }) // wait a bit just for easier debugging - setTimeout(() => { - const biomeDefs = fs.readFileSync('../data/biome_definitions.nbt') - client.writeRaw('biome_definition_list', biomeDefs) + // setTimeout(() => { + // const biomeDefs = fs.readFileSync('../data/biome_definitions.nbt') + // client.writeRaw('biome_definition_list', biomeDefs) + + // // TODO: send chunks so we can spawn player + // }, 1000) - // TODO: send chunks so we can spawn player - }, 1000) }) + + client.write('network_settings', { + compression_threshold: 1 + }) + + for (let i = 0; i < 3; i++) { + client.queue('inventory_slot', {"inventory_id":120,"slot":i,"uniqueid":0,"item":{"network_id":0}}) + } + + client.queue('inventory_transaction', require('./packets/inventory_transaction.json')) + client.queue('player_list', require('./packets/player_list.json')) + client.queue('start_game', require('./packets/start_game.json')) + client.queue('item_component', {"entries":[]}) + client.queue('set_time', { time: 5433771 }) + client.queue('set_difficulty', { difficulty: 1 }) + client.queue('set_commands_enabled', { enabled: true }) + client.queue('adventure_settings', require('./packets/adventure_settings.json')) + + client.queue('biome_definition_list', require('./packets/biome_definition_list.json')) + client.queue('available_entity_identifiers', require('./packets/available_entity_identifiers.json')) + + client.queue('update_attributes', require('./packets/update_attributes.json')) + client.queue('creative_content', require('./packets/creative_content.json')) + client.queue('player_hotbar', {"selected_slot":3,"window_id":0,"select_slot":true}) + + client.queue('crafting_data', require('./packets/crafting_data.json')) + client.queue('available_commands', require('./packets/available_commands.json')) + + client.queue('game_rules_changed', require('./packets/game_rules_changed.json')) + client.queue('respawn', {"x":646.9405517578125,"y":65.62001037597656,"z":77.86255645751953,"state":0,"runtime_entity_id":0}) + + for (const file of fs.readdirSync('chunks')) { + const buffer = Buffer.from(fs.readFileSync('./chunks/' + file, 'utf8'), 'hex') + // console.log('Sending chunk', chunk) + client.sendBuffer(buffer) + } + + setInterval(() => { + client.write('network_chunk_publisher_update', {"coordinates":{"x":646,"y":130,"z":77},"radius":64}) + }, 9500) + + + setTimeout(() => { + client.write('play_status', { status: 'player_spawn' }) + }, 8000) }) }) -}) \ No newline at end of file +}) + +async function sleep(ms) { + return new Promise(res => { + setTimeout(() => { res() }, ms) + }) +} \ No newline at end of file From 93ab3064ab30e19e7b54f86bd7d6d56f263ab3a3 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Sun, 21 Feb 2021 15:36:36 -0500 Subject: [PATCH 098/106] update raknet path --- package.json | 1 + src/auth/encryption.js | 1 - src/datatypes/BatchPacket.js | 8 +++- test/serialization.js | 77 ++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f0cd2f0..175c491 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "debug": "^4.3.1", "ec-pem": "^0.18.0", "jsonwebtoken": "^8.5.1", + "jsp-raknet": "github:extremeheat/raknet#client", "jwt-simple": "^0.5.6", "lodash.merge": "^4.4.0", "minecraft-folder-path": "^1.1.0", diff --git a/src/auth/encryption.js b/src/auth/encryption.js index 8402497..375fc27 100644 --- a/src/auth/encryption.js +++ b/src/auth/encryption.js @@ -11,7 +11,6 @@ function Encrypt(client, server, options) { client.ecdhKeyPair.generateKeys() client.clientX509 = writeX509PublicKey(client.ecdhKeyPair.getPublicKey()) - function startClientboundEncryption(publicKey) { console.warn('[encrypt] Pub key base64: ', publicKey) const pubKeyBuf = readX509PublicKey(publicKey.key) diff --git a/src/datatypes/BatchPacket.js b/src/datatypes/BatchPacket.js index cdd9296..52f4320 100644 --- a/src/datatypes/BatchPacket.js +++ b/src/datatypes/BatchPacket.js @@ -5,12 +5,17 @@ const NETWORK_ID = 0xfe // This is not a real MCPE packet, it's a wrapper that contains compressed/encrypted batched packets class BatchPacket { - constructor(stream) { + // Shared this.payload = Buffer.alloc(0) this.stream = stream || new BinaryStream() + + // Decoding this.packets = [] + + // Encoding this.compressionLevel = 7 + this.count = 0 } decode() { @@ -43,6 +48,7 @@ class BatchPacket { addEncodedPacket(packet) { this.stream.writeUnsignedVarInt(packet.byteLength) this.stream.append(packet) + this.count++ } getPackets() { diff --git a/test/serialization.js b/test/serialization.js index 8250f14..6c1cbe5 100644 --- a/test/serialization.js +++ b/test/serialization.js @@ -172,11 +172,88 @@ function test() { fs.writeFileSync('commands.json', JSON.stringify(readed.data,null,2)) } + async function creativeTestNew() { + const json = require('../src/packets/creative_content.json') + const buf = write('creative_content', json) + + const des = read(buf) + fs.writeFileSync('cc.json', serialize(des.data.params, 2)) + console.log('Des', des) + } + + async function biomeDefinitions() { + const json = require('../src/packets/biome_definition_list.json') + const buf = write('biome_definition_list', json) + + const des = read(buf) + fs.writeFileSync('cc.json', serialize(des.data.params, 2)) + console.log('Des', des) + } + + async function playerList() { + const buf = Buffer.from('3f0001cc304faee0c9f37b41c80c39333e3f9cfdffffff5f0c546865496e766973696f6e58103235333534303837333838353837323000070000003f35656236356637332d616631312d343438652d383261612d3162376231363533313661642e706572736f6e612d653139393637326138633161383765302d30000100000001000000040000000000000000000000000000000000056e756c6c0a00000100003f35656236356637332d616631312d343438652d383261612d3162376231363533313661642e706572736f6e612d653139393637326138633161383765302d300477696465092366666666636439360000000000000000000000', 'hex') + const des = read(buf) + console.log(serialize(des.data.params, 2)) + } + + async function startGame() { + const s = '0bfdffffff5f090a32bc2144723d8342a1b99b420000000048ff21c3f6fafadb02000006706c61696e7300020002b006ffff010800c2b79505000000d48ca03e00000000000101060600001b12636f6d6d616e64626c6f636b6f757470757401010f646f6461796c696768746379636c6501010d646f656e7469747964726f707301010a646f666972657469636b010109646f6d6f626c6f6f7401010d646f6d6f62737061776e696e6701010b646f74696c6564726f707301010e646f776561746865726379636c6501010e64726f776e696e6764616d61676501010a66616c6c64616d61676501010a6669726564616d61676501010d6b656570696e76656e746f727901000b6d6f626772696566696e6701010370767001010f73686f77636f6f7264696e617465730100136e61747572616c726567656e65726174696f6e01010b746e746578706c6f64657301011373656e64636f6d6d616e64666565646261636b0101156d6178636f6d6d616e64636861696e6c656e67746802feff070a646f696e736f6d6e6961010114636f6d6d616e64626c6f636b73656e61626c656401010f72616e646f6d7469636b7370656564020212646f696d6d6564696174657265737061776e01001173686f7764656174686d6573736167657301011466756e6374696f6e636f6d6d616e646c696d697402a09c010b737061776e726164697573020a0873686f7774616773010100000000000000020400000000000001000000012a100000001000000000000d426564726f636b206c6576656c0d426564726f636b206c6576656c2430303030303030302d303030302d303030302d303030302d30303030303030303030303000026e5f520000000000e89280c209009207146d696e6563726166743a636f6f6b65645f636f640c0100166d696e6563726166743a7075727075725f626c6f636bc900000d6d696e6563726166743a626f772c0100146d696e6563726166743a656e645f627269636b73ce00000d6d696e6563726166743a61697262ff001c6d696e6563726166743a656e6465726d616e5f737061776e5f656767b80100196d696e6563726166743a6d757369635f646973635f77617264150200106d696e6563726166743a726162626974200100206d696e6563726166743a637265657065725f62616e6e65725f7061747465726e3c0200146d696e6563726166743a656c656d656e745f3235dcff00176d696e6563726166743a6d757368726f6f6d5f73746577040100286d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f627269636b5f736c6162e4fe00196d696e6563726166743a636f6f6b65645f706f726b63686f700701001b6d696e6563726166743a726176616765725f737061776e5f656767eb01001a6d696e6563726166743a73747269707065645f6f616b5f6c6f67f6ff000f6d696e6563726166743a6170706c65010100146d696e6563726166743a656c656d656e745f3530c3ff001a6d696e6563726166743a6d757369635f646973635f63686972700f0200226d696e6563726166743a707269736d6172696e655f627269636b735f737461697273fcff00176d696e6563726166743a636f6f6b65645f726162626974210100146d696e6563726166743a656c656d656e745f3334d3ff00176d696e6563726166743a71756172747a5f627269636b73d0fe00186d696e6563726166743a6974656d2e69726f6e5f646f6f724700000d6d696e6563726166743a636f64080100166d696e6563726166743a676f6c64656e5f6170706c65020100136d696e6563726166743a626f6f6b7368656c662f00001c6d696e6563726166743a676f6c64656e5f686f7273655f61726d6f720a02001e6d696e6563726166743a736d6f6f74685f71756172747a5f73746169727347ff00106d696e6563726166743a706f7461746f180100206d696e6563726166743a656e6368616e7465645f676f6c64656e5f6170706c65030100156d696e6563726166743a6e65746865725f73746172fc0100146d696e6563726166743a656c656d656e745f3135e6ff001c6d696e6563726166743a6974656d2e6461726b5f6f616b5f646f6f72c50000156d696e6563726166743a6c696768745f626c6f636b29ff00226d696e6563726166743a79656c6c6f775f676c617a65645f7465727261636f747461e000001c6d696e6563726166743a73746f6e655f627269636b5f7374616972736d0000106d696e6563726166743a706f7274616c5a0000146d696e6563726166743a676f6c645f696e676f74320100146d696e6563726166743a69726f6e5f696e676f74310100196d696e6563726166743a736c696d655f737061776e5f656767bb01000f6d696e6563726166743a7363757465320200106d696e6563726166743a636f6f6b69650f0100126d696e6563726166743a706f726b63686f70060100176d696e6563726166743a6469616d6f6e645f626c6f636b3900000f6d696e6563726166743a6272656164050100136d696e6563726166743a656c656d656e745f37eeff00166d696e6563726166743a69726f6e5f7069636b6178652901001c6d696e6563726166743a70696c6c616765725f737061776e5f656767e90100146d696e6563726166743a656c656d656e745f3237daff000e6d696e6563726166743a62656566110100196d696e6563726166743a626c617a655f737061776e5f656767c60100106d696e6563726166743a73616c6d6f6e090100226d696e6563726166743a73696c7665725f676c617a65645f7465727261636f747461e40000176d696e6563726166743a74726f706963616c5f666973680a0100156d696e6563726166743a636f636f615f6265616e739a0100156d696e6563726166743a776f6f64656e5f736c61629e0000146d696e6563726166743a656c656d656e745f3136e5ff00126d696e6563726166743a7472697077697265840000136d696e6563726166743a73746f6e655f6178653b01001c6d696e6563726166743a737461696e65645f676c6173735f70616e65a000000f6d696e6563726166743a616e76696c910000176d696e6563726166743a747261707065645f6368657374920000186d696e6563726166743a616e6369656e745f646562726973f1fe00146d696e6563726166743a707566666572666973680b0100106d696e6563726166743a6275636b6574680100176d696e6563726166743a636f6f6b65645f73616c6d6f6e0d0100146d696e6563726166743a656c656d656e745f3631b8ff00126d696e6563726166743a737061726b6c65724d0200156d696e6563726166743a7761727065645f646f6f725d0200146d696e6563726166743a64726965645f6b656c700e0100176d696e6563726166743a62656574726f6f745f736f75701e0100166d696e6563726166743a7265645f6d757368726f6f6d280000186d696e6563726166743a776f6f64656e5f7069636b617865360100176d696e6563726166743a6974656d2e63616d70666972652fff00156d696e6563726166743a6d656c6f6e5f736c696365100100136d696e6563726166743a6861795f626c6f636baa0000176d696e6563726166743a776f6f64656e5f73686f76656c350100186d696e6563726166743a6e617574696c75735f7368656c6c300200136d696e6563726166743a656c656d656e745f31f4ff001b6d696e6563726166743a73746f6e656375747465725f626c6f636b3bff00156d696e6563726166743a636f6f6b65645f62656566120100146d696e6563726166743a636f6d70617261746f72000200106d696e6563726166743a636172726f741701001b6d696e6563726166743a737472696465725f737061776e5f656767ed0100176d696e6563726166743a636f6d6d616e645f626c6f636b890000116d696e6563726166743a636869636b656e130100106d696e6563726166743a706f74696f6ea80100166d696e6563726166743a726f7474656e5f666c657368150100196d696e6563726166743a77697463685f737061776e5f656767c201000e6d696e6563726166743a64697274030000146d696e6563726166743a656c656d656e745f3632b7ff001b6d696e6563726166743a6461796c696768745f6465746563746f72970000146d696e6563726166743a736e6f775f6c617965724e0000156d696e6563726166743a7261626269745f666f6f740602001a6d696e6563726166743a6c696e676572696e675f706f74696f6e280200126d696e6563726166743a63616d7066697265420200106d696e6563726166743a736d6f6b65723aff00166d696e6563726166743a7761727065645f66656e6365fffe00186d696e6563726166743a636f6f6b65645f636869636b656e140100266d696e6563726166743a6c696768745f626c75655f676c617a65645f7465727261636f747461df0000156d696e6563726166743a73746f6e655f73776f7264380100146d696e6563726166743a7370696465725f657965160100196d696e6563726166743a686f7273655f737061776e5f656767c80100166d696e6563726166743a62616b65645f706f7461746f190100176d696e6563726166743a676f6c64656e5f636172726f741b0100176d696e6563726166743a7370727563655f7374616972738600001a6d696e6563726166743a706f69736f6e6f75735f706f7461746f1a0100146d696e6563726166743a656c656d656e745f3133e8ff00126d696e6563726166743a6f6273696469616e310000156d696e6563726166743a70756d706b696e5f7069651c0100196d696e6563726166743a6469616d6f6e645f7069636b6178653e0100116d696e6563726166743a6c616e7465726e30ff00146d696e6563726166743a69726f6e5f73776f7264330100166d696e6563726166743a736d6f6f74685f73746f6e6549ff00126d696e6563726166743a62656574726f6f741d01001a6d696e6563726166743a6d757369635f646973635f7374726164140200146d696e6563726166743a656c656d656e745f3433caff001a6d696e6563726166743a696e76697369626c65626564726f636b5f0000176d696e6563726166743a73776565745f626572726965731f0100156d696e6563726166743a7261626269745f73746577220100156d696e6563726166743a77686561745f73656564732301001b6d696e6563726166743a6974656d2e6372696d736f6e5f646f6f720cff000f6d696e6563726166743a6368657374360000176d696e6563726166743a70756d706b696e5f7365656473240100136d696e6563726166743a656c656d656e745f32f3ff00206d696e6563726166743a636f6d6d616e645f626c6f636b5f6d696e6563617274290200156d696e6563726166743a6d656c6f6e5f7365656473250100136d696e6563726166743a737061776e5f656767660200126d696e6563726166743a69726f6e5f6178652a0100156d696e6563726166743a6e65746865725f77617274260100186d696e6563726166743a62656574726f6f745f7365656473270100146d696e6563726166743a656c656d656e745f3335d2ff00156d696e6563726166743a656c656d656e745f3130348dff00156d696e6563726166743a69726f6e5f73686f76656c280100186d696e6563726166743a6772616e6974655f73746169727357ff00196d696e6563726166743a666c696e745f616e645f737465656c2b01001a6d696e6563726166743a7a6f676c696e5f737061776e5f656767f00100166d696e6563726166743a73746f6e655f73686f76656c390100156d696e6563726166743a6d656c6f6e5f626c6f636b6700000f6d696e6563726166743a6172726f772d01000e6d696e6563726166743a636f616c2e0100216d696e6563726166743a7265616c5f646f75626c655f73746f6e655f736c616232b50000126d696e6563726166743a63686172636f616c2f0100196d696e6563726166743a73747261795f737061776e5f656767cc0100116d696e6563726166743a636172726f74738d0000116d696e6563726166743a6469616d6f6e64300100166d696e6563726166743a776f6f64656e5f73776f7264340100196d696e6563726166743a6e65746865726974655f626f6f7473580200196d696e6563726166743a6d757369635f646973635f6d616c6c110200196d696e6563726166743a6461726b5f6f616b5f737461697273a40000146d696e6563726166743a776f6f64656e5f617865370100126d696e6563726166743a6661726d6c616e643c00001a6d696e6563726166743a6372696d736f6e5f74726170646f6f720aff00216d696e6563726166743a7a6f6d6269655f7069676d616e5f737061776e5f656767be0100176d696e6563726166743a73746f6e655f7069636b6178653a0100176d696e6563726166743a73616c6d6f6e5f6275636b65746d0100106d696e6563726166743a706c616e6b730500001a6d696e6563726166743a636861696e6d61696c5f68656c6d6574530100186d696e6563726166743a6469616d6f6e645f73686f76656c3d0100176d696e6563726166743a6469616d6f6e645f73776f72643c0100186d696e6563726166743a736d697468696e675f7461626c6536ff00156d696e6563726166743a6469616d6f6e645f6178653f01000f6d696e6563726166743a737469636b400100176d696e6563726166743a666c6f77696e675f77617465720800000e6d696e6563726166743a626f776c410100166d696e6563726166743a676f6c64656e5f73776f7264420100156d696e6563726166743a686f6e65795f626c6f636b24ff00176d696e6563726166743a676f6c64656e5f73686f76656c430100106d696e6563726166743a656c797472612a02001b6d696e6563726166743a6c69745f72656473746f6e655f6c616d707c0000186d696e6563726166743a676f6c64656e5f7069636b617865440100146d696e6563726166743a676f6c64656e5f617865450100146d696e6563726166743a656c656d656e745f3532c1ff00106d696e6563726166743a737472696e67460100216d696e6563726166743a7265616c5f646f75626c655f73746f6e655f736c61623458ff00116d696e6563726166743a66656174686572470100136d696e6563726166743a67756e706f776465724801001e6d696e6563726166743a736b756c6c5f62616e6e65725f7061747465726e3d0200176d696e6563726166743a6163616369615f737461697273a30000146d696e6563726166743a776f6f64656e5f686f65490100196d696e6563726166743a70616e64615f737061776e5f656767e70100136d696e6563726166743a73746f6e655f686f654a0100126d696e6563726166743a69726f6e5f686f654b0100146d696e6563726166743a656c656d656e745f38369fff00156d696e6563726166743a6469616d6f6e645f686f654c0100146d696e6563726166743a676f6c64656e5f686f654d0100156d696e6563726166743a6d6167656e74615f6479659601000f6d696e6563726166743a77686561744e0100186d696e6563726166743a6c6561746865725f68656c6d65744f01001c6d696e6563726166743a6c6561746865725f6368657374706c6174655001001a6d696e6563726166743a6c6561746865725f6c656767696e6773510100206d696e6563726166743a676c6973746572696e675f6d656c6f6e5f736c696365b00100136d696e6563726166743a6c6f646573746f6e6522ff00186d696e6563726166743a62726f776e5f6d757368726f6f6d270000176d696e6563726166743a6c6561746865725f626f6f7473520100156d696e6563726166743a656e645f67617465776179d100001e6d696e6563726166743a636861696e6d61696c5f6368657374706c617465540100176d696e6563726166743a6974656d2e62656574726f6f74f40000156d696e6563726166743a656c656d656e745f31303190ff001c6d696e6563726166743a636861696e6d61696c5f6c656767696e6773550100196d696e6563726166743a636861696e6d61696c5f626f6f7473560100136d696e6563726166743a736f756c5f73616e64580000156d696e6563726166743a69726f6e5f68656c6d6574570100126d696e6563726166743a736e6f7762616c6c740100146d696e6563726166743a656c656d656e745f3439c4ff00196d696e6563726166743a69726f6e5f6368657374706c617465580100106d696e6563726166743a62617272656c35ff00176d696e6563726166743a69726f6e5f6c656767696e6773590100146d696e6563726166743a69726f6e5f626f6f74735a0100216d696e6563726166743a7265616c5f646f75626c655f73746f6e655f736c61623359ff00136d696e6563726166743a656e6465725f657965af01001c6d696e6563726166743a6d757369635f646973635f70696773746570600200226d696e6563726166743a737469636b79706973746f6e61726d636f6c6c6973696f6e27ff00176d696e6563726166743a69726f6e5f74726170646f6f72a70000186d696e6563726166743a6469616d6f6e645f68656c6d65745b01001e6d696e6563726166743a73746f6e655f70726573737572655f706c6174654600001c6d696e6563726166743a6469616d6f6e645f6368657374706c6174655c01000e6d696e6563726166743a73616e640c0000276d696e6563726166743a6c696768745f77656967687465645f70726573737572655f706c617465930000106d696e6563726166743a706973746f6e2100001a6d696e6563726166743a6469616d6f6e645f6c656767696e67735d0100146d696e6563726166743a656c656d656e745f3330d7ff00176d696e6563726166743a6469616d6f6e645f626f6f74735e0100176d696e6563726166743a676f6c64656e5f68656c6d65745f0100146d696e6563726166743a656c656d656e745f3531c2ff001c6d696e6563726166743a646f75626c655f776f6f64656e5f736c61629d0000146d696e6563726166743a656c656d656e745f3834a1ff001c6d696e6563726166743a686172645f737461696e65645f676c617373fe00001b6d696e6563726166743a676f6c64656e5f6368657374706c617465600100146d696e6563726166743a7365616c616e7465726ea90000136d696e6563726166743a676c6f7773746f6e65590000196d696e6563726166743a676f6c64656e5f6c656767696e6773610100166d696e6563726166743a676f6c64656e5f626f6f7473620100106d696e6563726166743a736869656c646301001b6d696e6563726166743a6a756e676c655f66656e63655f67617465b90000166d696e6563726166743a666c6f77696e675f6c6176610a0000196d696e6563726166743a6167656e745f737061776e5f656767e50100106d696e6563726166743a636172706574ab00000f6d696e6563726166743a666c696e74640100126d696e6563726166743a7061696e74696e676501001a6d696e6563726166743a68656172745f6f665f7468655f736561310200226d696e6563726166743a6d6f7373795f636f62626c6573746f6e655f7374616972734dff00126d696e6563726166743a6f616b5f7369676e660100196d696e6563726166743a6d757369635f646973635f77616974170200146d696e6563726166743a656c656d656e745f3535beff00156d696e6563726166743a776f6f64656e5f646f6f72670100156d696e6563726166743a6d696c6b5f6275636b6574690100146d696e6563726166743a656c656d656e745f3734abff00166d696e6563726166743a77617465725f6275636b65746a01001b6d696e6563726166743a7368756c6b65725f737061776e5f656767d30100116d696e6563726166743a7265645f6479658a01000e6d696e6563726166743a626f6e659d0100236d696e6563726166743a6d6167656e74615f676c617a65645f7465727261636f747461de0000156d696e6563726166743a6c6176615f6275636b65746b01001e6d696e6563726166743a76696e64696361746f725f737061776e5f656767d80100146d696e6563726166743a636f645f6275636b65746c01001e6d696e6563726166743a74726f706963616c5f666973685f6275636b65746e0100136d696e6563726166743a656c656d656e745f36efff001b6d696e6563726166743a707566666572666973685f6275636b65746f0100196d696e6563726166743a636f6e63726574655f706f77646572ed0000126d696e6563726166743a6d696e6563617274700100106d696e6563726166743a736164646c657101001b6d696e6563726166743a6e65746865725f776172745f626c6f636bd60000156d696e6563726166743a656c656d656e745f31313681ff00176d696e6563726166743a6372696d736f6e5f726f6f747321ff00136d696e6563726166743a69726f6e5f646f6f72720100126d696e6563726166743a72656473746f6e65730100226d696e6563726166743a656c6465725f677561726469616e5f737061776e5f656767d50100126d696e6563726166743a63726f7373626f77350200186d696e6563726166743a616374697661746f725f7261696c7e0000126d696e6563726166743a6f616b5f626f6174750100146d696e6563726166743a656c656d656e745f393794ff00146d696e6563726166743a62697263685f626f6174760100146d696e6563726166743a707269736d6172696e65a80000216d696e6563726166743a706f6c69736865645f6772616e6974655f73746169727354ff00156d696e6563726166743a6a756e676c655f626f61747701001e6d696e6563726166743a73696c766572666973685f737061776e5f656767b90100196d696e6563726166743a6368656d69737472795f7461626c65ee0000156d696e6563726166743a7370727563655f626f6174780100146d696e6563726166743a656c656d656e745f3236dbff00156d696e6563726166743a6163616369615f626f6174790100176d696e6563726166743a6461726b5f6f616b5f626f61747a0100126d696e6563726166743a69726f6e5f6f72650f0000166d696e6563726166743a7772697474656e5f626f6f6bf50100116d696e6563726166743a6c6561746865727b01000e6d696e6563726166743a6b656c707c0100156d696e6563726166743a676f6c645f6e7567676574a701000f6d696e6563726166743a627269636b7d0100136d696e6563726166743a636c61795f62616c6c7e0100146d696e6563726166743a73756761725f63616e657f0100156d696e6563726166743a6c69745f70756d706b696e5b0000196d696e6563726166743a6e65746865726974655f696e676f744f02000f6d696e6563726166743a7061706572800100146d696e6563726166743a656c656d656e745f3233deff000f6d696e6563726166743a636f72616c7dff000e6d696e6563726166743a626f6f6b810100146d696e6563726166743a656e645f706f7274616c770000116d696e6563726166743a74726964656e74180200146d696e6563726166743a736c696d655f62616c6c820100186d696e6563726166743a63686573745f6d696e65636172748301000d6d696e6563726166743a656767840100176d696e6563726166743a636f775f737061776e5f656767b20100196d696e6563726166743a6d757369635f646973635f7374616c130200196d696e6563726166743a6e65746865726974655f73776f7264500200146d696e6563726166743a6974656d2e7265656473530000116d696e6563726166743a636f6d70617373850100186d696e6563726166743a6372696d736f6e5f73746169727302ff00156d696e6563726166743a66697368696e675f726f64860100136d696e6563726166743a726573657276656436ff0000196d696e6563726166743a616e6465736974655f73746169727355ff000f6d696e6563726166743a636c6f636b8701001a6d696e6563726166743a6f63656c6f745f737061776e5f656767c10100176d696e6563726166743a7370727563655f627574746f6e70ff00176d696e6563726166743a7265645f73616e6473746f6e65b30000186d696e6563726166743a676c6f7773746f6e655f64757374880100136d696e6563726166743a626c61636b5f647965890100136d696e6563726166743a677265656e5f6479658b0100156d696e6563726166743a7368756c6b65725f626f78da00000e6d696e6563726166743a64656e79d30000176d696e6563726166743a6265655f737061776e5f656767ec0100136d696e6563726166743a62726f776e5f6479658c0100126d696e6563726166743a626c75655f6479658d01000f6d696e6563726166743a6672616d65f701001b6d696e6563726166743a62726577696e677374616e64626c6f636b750000136d696e6563726166743a6974656d2e63616b655c0000146d696e6563726166743a707572706c655f6479658e01000d6d696e6563726166743a647965640200176d696e6563726166743a6d757369635f646973635f31330c0200126d696e6563726166743a6379616e5f6479658f0100136d696e6563726166743a626c617a655f726f64a50100186d696e6563726166743a6c696768745f677261795f647965900100126d696e6563726166743a677261795f647965910100206d696e6563726166743a7069676c696e5f62727574655f737061776e5f656767f10100146d696e6563726166743a656c656d656e745f3431ccff001a6d696e6563726166743a7261626269745f737061776e5f656767c90100126d696e6563726166743a70696e6b5f647965920100126d696e6563726166743a6c696d655f647965930100146d696e6563726166743a79656c6c6f775f647965940100176d696e6563726166743a626c6173745f6675726e6163653cff00146d696e6563726166743a656c656d656e745f3130ebff00186d696e6563726166743a6c696768745f626c75655f647965950100146d696e6563726166743a747572746c655f65676761ff000d6d696e6563726166743a626564a00100176d696e6563726166743a737461696e65645f676c617373f10000146d696e6563726166743a6f72616e67655f647965970100146d696e6563726166743a656c656d656e745f3134e7ff00136d696e6563726166743a77686974655f647965980100196d696e6563726166743a6974656d2e666c6f7765725f706f748c0000136d696e6563726166743a626f6e655f6d65616c990100176d696e6563726166743a747572746c655f68656c6d6574330200116d696e6563726166743a756e6b6e6f776ecffe00116d696e6563726166743a696e6b5f7361639b01001f6d696e6563726166743a73747269707065645f6372696d736f6e5f7374656d10ff00166d696e6563726166743a6c617069735f6c617a756c699c0100166d696e6563726166743a63686f7275735f6672756974240200106d696e6563726166743a63616d657261460200196d696e6563726166743a737573706963696f75735f737465774302000f6d696e6563726166743a73756761729e01001b6d696e6563726166743a637265657065725f737061776e5f656767b70100126d696e6563726166743a6e616d655f7461671a02000e6d696e6563726166743a63616b659f0100126d696e6563726166743a7265706561746572a10100106d696e6563726166743a626561636f6e8a00001e6d696e6563726166743a6e65746865726974655f6368657374706c617465560200226d696e6563726166743a706f6c69736865645f616e6465736974655f73746169727352ff00146d696e6563726166743a66696c6c65645f6d6170a201001b6d696e6563726166743a64726f776e65645f737061776e5f656767e101001e6d696e6563726166743a756e706f77657265645f636f6d70617261746f72950000106d696e6563726166743a736865617273a30100146d696e6563726166743a656c656d656e745f3331d6ff00156d696e6563726166743a656e6465725f706561726ca401001e6d696e6563726166743a7265645f73616e6473746f6e655f737461697273b40000186d696e6563726166743a6361727665645f70756d706b696e65ff00146d696e6563726166743a67686173745f74656172a60100166d696e6563726166743a676c6173735f626f74746c65a90100176d696e6563726166743a636f6f6b65645f6d7574746f6e1d0200146d696e6563726166743a656c656d656e745f3434c9ff002a6d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f627269636b5f737461697273edfe001f6d696e6563726166743a6a756e676c655f70726573737572655f706c61746567ff001e6d696e6563726166743a6665726d656e7465645f7370696465725f657965aa0100196d696e6563726166743a686f6e6579636f6d625f626c6f636b23ff00166d696e6563726166743a626c617a655f706f77646572ab0100156d696e6563726166743a6d61676d615f637265616dac0100106d696e6563726166743a6a69677361772dff00176d696e6563726166743a62726577696e675f7374616e64ad0100156d696e6563726166743a656c656d656e745f31313186ff00126d696e6563726166743a6361756c64726f6eae01001b6d696e6563726166743a636869636b656e5f737061776e5f656767b10100176d696e6563726166743a7069675f737061776e5f656767b30100196d696e6563726166743a73686565705f737061776e5f656767b401001a6d696e6563726166743a706172726f745f737061776e5f656767dc0100186d696e6563726166743a776f6c665f737061776e5f656767b501001d6d696e6563726166743a6d6f6f7368726f6f6d5f737061776e5f656767b60100146d696e6563726166743a66656e63655f676174656b00001c6d696e6563726166743a736b656c65746f6e5f737061776e5f656767ba01001c6d696e6563726166743a646f75626c655f73746f6e655f736c6162335eff00156d696e6563726166743a627269636b5f626c6f636b2d00001a6d696e6563726166743a7370696465725f737061776e5f656767bc0100106d696e6563726166743a626c656163684902001a6d696e6563726166743a636f6c6f7265645f746f7263685f7267ca00001a6d696e6563726166743a7a6f6d6269655f737061776e5f656767bd0100146d696e6563726166743a656c656d656e745f3231e0ff001c6d696e6563726166743a76696c6c616765725f737061776e5f656767bf0100136d696e6563726166743a636f6d706f737465722bff00196d696e6563726166743a73717569645f737061776e5f656767c001001c6d696e6563726166743a706f77657265645f636f6d70617261746f72960000176d696e6563726166743a6261745f737061776e5f656767c30100196d696e6563726166743a67686173745f737061776e5f656767c40100136d696e6563726166743a656c656d656e745f30240000156d696e6563726166743a6d6f625f737061776e6572340000206d696e6563726166743a63686973656c65645f6e65746865725f627269636b73d2fe001e6d696e6563726166743a6d61676d615f637562655f737061776e5f656767c50100156d696e6563726166743a7761727065645f7369676e5b02000f6d696e6563726166743a636861696e5f0200226d696e6563726166743a7761727065645f66756e6775735f6f6e5f615f737469636b5e02001f6d696e6563726166743a636176655f7370696465725f737061776e5f656767c70100176d696e6563726166743a736f756c5f63616d70666972656202001d6d696e6563726166743a656e6465726d6974655f737061776e5f656767ca01001c6d696e6563726166743a677561726469616e5f737061776e5f656767cb0100176d696e6563726166743a6372696d736f6e5f66656e636500ff00186d696e6563726166743a6875736b5f737061776e5f656767cd01001a6d696e6563726166743a7069676c696e5f737061776e5f656767ef0100176d696e6563726166743a77656570696e675f76696e657319ff00236d696e6563726166743a7769746865725f736b656c65746f6e5f737061776e5f656767ce0100196d696e6563726166743a676c6f77696e676f6273696469616ef60000116d696e6563726166743a6c656176657332a100001a6d696e6563726166743a646f6e6b65795f737061776e5f656767cf0100156d696e6563726166743a7370727563655f7369676e360200146d696e6563726166743a656c656d656e745f3539baff00186d696e6563726166743a6d756c655f737061776e5f656767d00100166d696e6563726166743a646f75626c655f706c616e74af0000156d696e6563726166743a656c656d656e745f31303988ff00226d696e6563726166743a736b656c65746f6e5f686f7273655f737061776e5f656767d101001b6d696e6563726166743a6e65746865726974655f7069636b617865520200116d696e6563726166743a6a756b65626f78540000206d696e6563726166743a7a6f6d6269655f686f7273655f737061776e5f656767d20100176d696e6563726166743a6e70635f737061776e5f656767d40100136d696e6563726166743a69726f6e5f62617273650000146d696e6563726166743a656c656d656e745f3830a5ff001e6d696e6563726166743a706f6c61725f626561725f737061776e5f656767d60100136d696e6563726166743a656e645f73746f6e65790000196d696e6563726166743a6c6c616d615f737061776e5f656767d70100196d696e6563726166743a6974656d2e62697263685f646f6f72c200001a6d696e6563726166743a65766f6b65725f737061776e5f656767d90100176d696e6563726166743a6d757369635f646973635f31311602001a6d696e6563726166743a6c69745f72656473746f6e655f6f72654a0000186d696e6563726166743a6372616674696e675f7461626c653a0000216d696e6563726166743a626c61636b5f676c617a65645f7465727261636f747461eb0000146d696e6563726166743a656c656d656e745f3537bcff001a6d696e6563726166743a7370727563655f77616c6c5f7369676e4aff00176d696e6563726166743a7665785f737061776e5f656767da0100196d696e6563726166743a7761727065645f74726170646f6f7209ff00186d696e6563726166743a7477697374696e675f76696e6573e1fe00246d696e6563726166743a6461796c696768745f6465746563746f725f696e766572746564b20000236d696e6563726166743a7a6f6d6269655f76696c6c616765725f737061776e5f656767db01001a6d696e6563726166743a72617069645f66657274696c697a65724a02000e6d696e6563726166743a636c6179520000216d696e6563726166743a74726f706963616c5f666973685f737061776e5f656767dd0100176d696e6563726166743a7374616e64696e675f7369676e3f0000176d696e6563726166743a636f645f737061776e5f656767de0100146d696e6563726166743a6974656d2e6672616d65c70000186d696e6563726166743a6372696d736f6e5f66756e6775731cff001e6d696e6563726166743a707566666572666973685f737061776e5f656767df01001c6d696e6563726166743a7265645f6d757368726f6f6d5f626c6f636b6400001a6d696e6563726166743a73616c6d6f6e5f737061776e5f656767e00100156d696e6563726166743a7761727065645f736c6162f7fe001c6d696e6563726166743a646f75626c655f73746f6e655f736c616232b600001b6d696e6563726166743a646f6c7068696e5f737061776e5f656767e20100136d696e6563726166743a656c656d656e745f39ecff001a6d696e6563726166743a747572746c655f737061776e5f656767e301001b6d696e6563726166743a7068616e746f6d5f737061776e5f656767e40100146d696e6563726166743a656c656d656e745f3238d9ff001a6d696e6563726166743a6974656d2e6163616369615f646f6f72c40000176d696e6563726166743a6361745f737061776e5f656767e60100176d696e6563726166743a666f785f737061776e5f656767e801001a6d696e6563726166743a636f62626c6573746f6e655f77616c6c8b0000106d696e6563726166743a71756172747a0202001b6d696e6563726166743a636172726f745f6f6e5f615f737469636bfb0100246d696e6563726166743a77616e646572696e675f7472616465725f737061776e5f656767ea0100126d696e6563726166743a74726170646f6f726000001a6d696e6563726166743a686f676c696e5f737061776e5f656767ee01001b6d696e6563726166743a657870657269656e63655f626f74746c65f20100196d696e6563726166743a6a756e676c655f74726170646f6f726cff00156d696e6563726166743a666972655f636861726765f30100146d696e6563726166743a656c656d656e745f3639b0ff00176d696e6563726166743a7772697461626c655f626f6f6bf40100116d696e6563726166743a656d6572616c64f60100146d696e6563726166743a666c6f7765725f706f74f80100106d696e6563726166743a6c6561766573120000136d696e6563726166743a656d7074795f6d6170f901000f6d696e6563726166743a736b756c6cfa0100186d696e6563726166743a6372696d736f6e5f6e796c69756d18ff00196d696e6563726166743a66697265776f726b5f726f636b6574fd0100156d696e6563726166743a656c656d656e745f3130328fff00176d696e6563726166743a66697265776f726b5f73746172fe01001a6d696e6563726166743a636f6c6f7265645f746f7263685f6270cc0000186d696e6563726166743a656e6368616e7465645f626f6f6bff01001a6d696e6563726166743a746f74656d5f6f665f756e6479696e672e0200156d696e6563726166743a6e6574686572627269636b010200166d696e6563726166743a746e745f6d696e6563617274030200146d696e6563726166743a656c656d656e745f3633b6ff00196d696e6563726166743a686f707065725f6d696e6563617274040200176d696e6563726166743a647261676f6e5f627265617468260200156d696e6563726166743a636f62626c6573746f6e65040000106d696e6563726166743a686f70706572050200156d696e6563726166743a7261626269745f686964650702001d6d696e6563726166743a6c6561746865725f686f7273655f61726d6f720802001a6d696e6563726166743a69726f6e5f686f7273655f61726d6f720902001d6d696e6563726166743a6469616d6f6e645f686f7273655f61726d6f720b0200186d696e6563726166743a6d757369635f646973635f6361740d0200156d696e6563726166743a6a756e676c655f646f6f722102001b6d696e6563726166743a6d757369635f646973635f626c6f636b730e0200136d696e6563726166743a73616e6473746f6e65180000176d696e6563726166743a776f6f64656e5f627574746f6e8f0000186d696e6563726166743a6d757369635f646973635f6661721002001c6d696e6563726166743a6d757369635f646973635f6d656c6c6f6869120200166d696e6563726166743a696e666f5f75706461746532f900000e6d696e6563726166743a6c6561641902001d6d696e6563726166743a707269736d6172696e655f6372797374616c731b0200156d696e6563726166743a6163616369615f7369676e390200106d696e6563726166743a6d7574746f6e1c0200146d696e6563726166743a656c656d656e745f3332d5ff00126d696e6563726166743a636f616c5f6f7265100000156d696e6563726166743a61726d6f725f7374616e641e0200156d696e6563726166743a7370727563655f646f6f721f02001a6d696e6563726166743a7068616e746f6d5f6d656d6272616e65340200146d696e6563726166743a62697263685f646f6f72200200156d696e6563726166743a6163616369615f646f6f72220200146d696e6563726166743a656c656d656e745f3432cbff00176d696e6563726166743a6461726b5f6f616b5f646f6f722302001c6d696e6563726166743a6e65746865726974655f6c656767696e67735702001d6d696e6563726166743a706f707065645f63686f7275735f6672756974250200146d696e6563726166743a656c656d656e745f3733acff00176d696e6563726166743a73706c6173685f706f74696f6e270200216d696e6563726166743a6461726b5f6f616b5f70726573737572655f706c61746568ff001a6d696e6563726166743a707269736d6172696e655f73686172642b0200126d696e6563726166743a73656167726173737eff00176d696e6563726166743a7368756c6b65725f7368656c6c2c0200186d696e6563726166743a72656473746f6e655f626c6f636b980000106d696e6563726166743a62616e6e65722d0200156d696e6563726166743a69726f6e5f6e75676765742f0200146d696e6563726166743a656c656d656e745f3338cfff00196d696e6563726166743a636f72616c5f66616e5f68616e673278ff00146d696e6563726166743a62697263685f7369676e370200186d696e6563726166743a636f72616c5f66616e5f646561647aff00116d696e6563726166743a62616c6c6f6f6e4b0200156d696e6563726166743a6a756e676c655f7369676e380200176d696e6563726166743a6461726b5f6f616b5f7369676e3a02001f6d696e6563726166743a666c6f7765725f62616e6e65725f7061747465726e3b0200216d696e6563726166743a706f6c69736865645f64696f726974655f73746169727353ff001f6d696e6563726166743a6d6f6a616e675f62616e6e65725f7061747465726e3e0200156d696e6563726166743a6d6f6e737465725f656767610000266d696e6563726166743a6669656c645f6d61736f6e65645f62616e6e65725f7061747465726e3f02000e6d696e6563726166743a62656c6c32ff00296d696e6563726166743a626f72647572655f696e64656e7465645f62616e6e65725f7061747465726e400200126d696e6563726166743a706f7461746f65738e00001f6d696e6563726166743a7069676c696e5f62616e6e65725f7061747465726e410200146d696e6563726166743a656c656d656e745f3738a7ff00136d696e6563726166743a686f6e6579636f6d624402001a6d696e6563726166743a7265645f6e65746865725f627269636bd70000166d696e6563726166743a686f6e65795f626f74746c65450200126d696e6563726166743a636f6d706f756e64470200126d696e6563726166743a6963655f626f6d62480200126d696e6563726166743a6d65646963696e654c0200176d696e6563726166743a7761727065645f66756e6775731bff00146d696e6563726166743a656c656d656e745f393299ff001a6d696e6563726166743a656e645f706f7274616c5f6672616d65780000146d696e6563726166743a676c6f775f737469636ba60000126d696e6563726166743a626c75655f696365f5ff00146d696e6563726166743a656c656d656e745f3833a2ff001b6d696e6563726166743a6c6f646573746f6e655f636f6d706173734e0200146d696e6563726166743a71756172747a5f6f72659900001a6d696e6563726166743a6e65746865726974655f73686f76656c5102001d6d696e6563726166743a636861696e5f636f6d6d616e645f626c6f636bbd00000e6d696e6563726166743a6c6f6f6d34ff001a6d696e6563726166743a6974656d2e7761727065645f646f6f720bff00176d696e6563726166743a6e65746865726974655f617865530200176d696e6563726166743a6e65746865726974655f686f655402001a6d696e6563726166743a6e65746865726974655f68656c6d6574550200196d696e6563726166743a6e65746865726974655f7363726170590200166d696e6563726166743a6372696d736f6e5f7369676e5a0200126d696e6563726166743a636f6e6372657465ec0000166d696e6563726166743a6372696d736f6e5f646f6f725c0200106d696e6563726166743a73706f6e6765130000186d696e6563726166743a6e65746865725f7370726f7574736102001b6d696e6563726166743a636172746f6772617068795f7461626c6538ff00196d696e6563726166743a626c61636b73746f6e655f736c6162e6fe00226d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f736c6162dbfe000f6d696e6563726166743a73746f6e650100000e6d696e6563726166743a776f6f6c230000176d696e6563726166743a79656c6c6f775f666c6f7765722500001f6d696e6563726166743a737461696e65645f68617264656e65645f636c61799f00000d6d696e6563726166743a6c6f671100000f6d696e6563726166743a66656e6365550000146d696e6563726166743a656c656d656e745f3533c0ff00146d696e6563726166743a73746f6e65627269636b6200001b6d696e6563726166743a6c69745f626c6173745f6675726e6163652aff00156d696e6563726166743a636f72616c5f626c6f636b7cff00246d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f627269636b73eefe00156d696e6563726166743a656c656d656e745f31303091ff001b6d696e6563726166743a646f75626c655f73746f6e655f736c61622c00000e6d696e6563726166743a7261696c4200001c6d696e6563726166743a646f75626c655f73746f6e655f736c6162345aff001d6d696e6563726166743a73747269707065645f6163616369615f6c6f67f8ff00206d696e6563726166743a7265616c5f646f75626c655f73746f6e655f736c61622b0000136d696e6563726166743a636f72616c5f66616e7bff00246d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f627574746f6ed8fe00146d696e6563726166743a7365615f7069636b6c6564ff00296d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f646f75626c655f736c6162dafe00116d696e6563726166743a7361706c696e67060000166d696e6563726166743a7761727065645f726f6f747320ff00146d696e6563726166743a656c656d656e745f3131eaff00146d696e6563726166743a7265645f666c6f776572260000136d696e6563726166743a77617465726c696c796f0000166d696e6563726166743a71756172747a5f626c6f636b9b0000136d696e6563726166743a736f756c5f736f696c14ff001f6d696e6563726166743a6163616369615f70726573737572655f706c6174656aff00136d696e6563726166743a74616c6c67726173731f0000156d696e6563726166743a656c656d656e745f3130338eff001e6d696e6563726166743a62726f776e5f6d757368726f6f6d5f626c6f636b6300000e6d696e6563726166743a6c6f6732a20000116d696e6563726166743a636f6e6475697463ff000f6d696e6563726166743a6d61676d61d50000146d696e6563726166743a656c656d656e745f3232dfff001c6d696e6563726166743a756e647965645f7368756c6b65725f626f78cd00001e6d696e6563726166743a7370727563655f7374616e64696e675f7369676e4bff00176d696e6563726166743a737469636b795f706973746f6e1d0000106d696e6563726166743a62616d626f6f5dff00126d696e6563726166743a6f62736572766572fb0000156d696e6563726166743a73636166666f6c64696e675bff00146d696e6563726166743a6772696e6473746f6e653dff00116d696e6563726166743a656e645f726f64d00000196d696e6563726166743a666c65746368696e675f7461626c6537ff00156d696e6563726166743a6974656d2e686f707065729a00000e6d696e6563726166743a776f6f642cff000d6d696e6563726166743a746e742e0000216d696e6563726166743a686172645f737461696e65645f676c6173735f70616e65bf00000f6d696e6563726166743a736c696d65a50000116d696e6563726166743a70756d706b696e560000166d696e6563726166743a6372696d736f6e5f736c6162f8fe00136d696e6563726166743a656c656d656e745f33f2ff00136d696e6563726166743a656c656d656e745f34f1ff00156d696e6563726166743a656e6465725f6368657374820000136d696e6563726166743a656c656d656e745f35f0ff00136d696e6563726166743a656c656d656e745f38edff00146d696e6563726166743a656c656d656e745f3132e9ff00146d696e6563726166743a656c656d656e745f3137e4ff00146d696e6563726166743a656c656d656e745f3138e3ff00146d696e6563726166743a656c656d656e745f3139e2ff00146d696e6563726166743a656c656d656e745f3230e1ff00146d696e6563726166743a656c656d656e745f3234ddff00146d696e6563726166743a656c656d656e745f3239d8ff00146d696e6563726166743a656c656d656e745f3333d4ff00146d696e6563726166743a656c656d656e745f3336d1ff000d6d696e6563726166743a6963654f0000146d696e6563726166743a656c656d656e745f3337d0ff00146d696e6563726166743a656c656d656e745f3339ceff00146d696e6563726166743a656c656d656e745f3430cdff00146d696e6563726166743a656c656d656e745f3435c8ff00146d696e6563726166743a656c656d656e745f3436c7ff00146d696e6563726166743a656c656d656e745f3437c6ff00146d696e6563726166743a656c656d656e745f3438c5ff00146d696e6563726166743a656c656d656e745f3534bfff00146d696e6563726166743a656c656d656e745f3536bdff00146d696e6563726166743a656c656d656e745f3538bbff00146d696e6563726166743a656c656d656e745f3630b9ff00146d696e6563726166743a656c656d656e745f3634b5ff00146d696e6563726166743a656c656d656e745f3635b4ff00146d696e6563726166743a656c656d656e745f3636b3ff00146d696e6563726166743a656c656d656e745f3637b2ff00146d696e6563726166743a656c656d656e745f3638b1ff00146d696e6563726166743a656c656d656e745f3730afff00146d696e6563726166743a656c656d656e745f3731aeff00146d696e6563726166743a656c656d656e745f3732adff00146d696e6563726166743a656c656d656e745f3735aaff00146d696e6563726166743a656c656d656e745f3736a9ff00196d696e6563726166743a6461726b5f6f616b5f627574746f6e72ff00146d696e6563726166743a656c656d656e745f3737a8ff00186d696e6563726166743a72656473746f6e655f746f7263684c0000186d696e6563726166743a64696f726974655f73746169727356ff00146d696e6563726166743a656c656d656e745f3739a6ff00146d696e6563726166743a656c656d656e745f3831a4ff00146d696e6563726166743a656c656d656e745f3832a3ff00226d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f77616c6cd7fe00146d696e6563726166743a656c656d656e745f3835a0ff00146d696e6563726166743a656c656d656e745f38379eff00146d696e6563726166743a656c656d656e745f38389dff00146d696e6563726166743a656c656d656e745f38399cff00146d696e6563726166743a656c656d656e745f39309bff00146d696e6563726166743a656c656d656e745f39319aff00146d696e6563726166743a656c656d656e745f393398ff00146d696e6563726166743a656c656d656e745f393497ff00146d696e6563726166743a656c656d656e745f393596ff00146d696e6563726166743a656c656d656e745f393695ff00146d696e6563726166743a656c656d656e745f393893ff00106d696e6563726166743a636163747573510000146d696e6563726166743a656c656d656e745f393992ff00156d696e6563726166743a656c656d656e745f3130358cff00156d696e6563726166743a656c656d656e745f3130368bff00206d696e6563726166743a6379616e5f676c617a65645f7465727261636f747461e50000156d696e6563726166743a656c656d656e745f3130378aff00156d696e6563726166743a656c656d656e745f31303889ff00156d696e6563726166743a656c656d656e745f31313087ff00156d696e6563726166743a656c656d656e745f31313285ff00176d696e6563726166743a7761727065645f627574746f6efbfe00156d696e6563726166743a656c656d656e745f31313384ff00166d696e6563726166743a62697263685f737461697273870000156d696e6563726166743a656c656d656e745f31313483ff001d6d696e6563726166743a6461726b5f6f616b5f66656e63655f67617465ba0000156d696e6563726166743a656c656d656e745f31313582ff00156d696e6563726166743a656c656d656e745f31313780ff00156d696e6563726166743a656c656d656e745f3131387fff00196d696e6563726166743a6e65746865726974655f626c6f636bf2fe00186d696e6563726166743a7265737061776e5f616e63686f72f0fe00196d696e6563726166743a637279696e675f6f6273696469616edffe000e6d696e6563726166743a626f6174630200186d696e6563726166743a62616e6e65725f7061747465726e650200156d696e6563726166743a656e645f6372797374616c6702000e6d696e6563726166743a736e6f77500000176d696e6563726166743a6465746563746f725f7261696c1c0000176d696e6563726166743a6163616369615f627574746f6e74ff00176d696e6563726166743a71756172747a5f7374616972739c00001b6d696e6563726166743a6163616369615f66656e63655f67617465bb00001e6d696e6563726166743a6163616369615f7374616e64696e675f7369676e42ff00196d696e6563726166743a6163616369615f74726170646f6f726fff00176d696e6563726166743a7075727075725f737461697273cb00001a6d696e6563726166743a6163616369615f77616c6c5f7369676e41ff000f6d696e6563726166743a616c6c6f77d20000196d696e6563726166743a7374616e64696e675f62616e6e6572b00000186d696e6563726166743a62616d626f6f5f7361706c696e675cff00156d696e6563726166743a66726f737465645f696365cf0000116d696e6563726166743a626172726965725fff00106d696e6563726166743a626173616c7416ff00126d696e6563726166743a6974656d2e6265641a0000116d696e6563726166743a626564726f636b070000126d696e6563726166743a6265655f6e65737426ff00116d696e6563726166743a6265656869766525ff00166d696e6563726166743a62697263685f627574746f6e73ff001a6d696e6563726166743a62697263685f66656e63655f67617465b800001e6d696e6563726166743a62697263685f70726573737572655f706c61746569ff00266d696e6563726166743a63686973656c65645f706f6c69736865645f626c61636b73746f6e65e9fe001d6d696e6563726166743a62697263685f7374616e64696e675f7369676e46ff00186d696e6563726166743a62697263685f74726170646f6f726eff00196d696e6563726166743a62697263685f77616c6c5f7369676e45ff00176d696e6563726166743a63686f7275735f666c6f776572c80000146d696e6563726166743a626c61636b73746f6e65effe00106d696e6563726166743a74617267657411ff00206d696e6563726166743a626c61636b73746f6e655f646f75626c655f736c6162e5fe001a6d696e6563726166743a64726965645f6b656c705f626c6f636b75ff001b6d696e6563726166743a626c61636b73746f6e655f737461697273ecfe00196d696e6563726166743a626c61636b73746f6e655f77616c6cebfe00206d696e6563726166743a626c75655f676c617a65645f7465727261636f747461e70000146d696e6563726166743a626f6e655f626c6f636bd80000166d696e6563726166743a626f726465725f626c6f636bd40000136d696e6563726166743a77616c6c5f7369676e440000226d696e6563726166743a6f72616e67655f676c617a65645f7465727261636f747461dd0000166d696e6563726166743a627269636b5f7374616972736c0000216d696e6563726166743a62726f776e5f676c617a65645f7465727261636f747461e80000176d696e6563726166743a627562626c655f636f6c756d6e60ff00156d696e6563726166743a6974656d2e63616d657261f20000176d696e6563726166743a6974656d2e6361756c64726f6e760000146d696e6563726166743a6974656d2e636861696ee2fe00176d696e6563726166743a6368656d6963616c5f68656174c00000146d696e6563726166743a676f6c645f626c6f636b290000166d696e6563726166743a63686f7275735f706c616e74f00000146d696e6563726166743a636f616c5f626c6f636bad00000f6d696e6563726166743a636f636f617f0000146d696e6563726166743a7061636b65645f696365ae0000186d696e6563726166743a636f72616c5f66616e5f68616e6779ff00196d696e6563726166743a636f72616c5f66616e5f68616e673377ff001f6d696e6563726166743a637261636b65645f6e65746865725f627269636b73d1fe002c6d696e6563726166743a637261636b65645f706f6c69736865645f626c61636b73746f6e655f627269636b73e8fe00186d696e6563726166743a6372696d736f6e5f627574746f6efcfe001d6d696e6563726166743a6372696d736f6e5f646f75626c655f736c6162f6fe001c6d696e6563726166743a6372696d736f6e5f66656e63655f67617465fefe00186d696e6563726166743a6372696d736f6e5f687970686165d5fe00156d696e6563726166743a656d6572616c645f6f7265810000186d696e6563726166743a6372696d736f6e5f706c616e6b730eff001b6d696e6563726166743a7370727563655f66656e63655f67617465b70000206d696e6563726166743a6372696d736f6e5f70726573737572655f706c617465fafe001f6d696e6563726166743a6372696d736f6e5f7374616e64696e675f7369676e06ff00166d696e6563726166743a6372696d736f6e5f7374656d1fff001b6d696e6563726166743a6372696d736f6e5f77616c6c5f7369676e04ff001b6d696e6563726166743a6461726b5f6f616b5f74726170646f6f726dff00206d696e6563726166743a6461726b5f707269736d6172696e655f737461697273fdff001f6d696e6563726166743a6461726b6f616b5f7374616e64696e675f7369676e40ff001b6d696e6563726166743a6461726b6f616b5f77616c6c5f7369676e3fff00126d696e6563726166743a6465616462757368200000156d696e6563726166743a6469616d6f6e645f6f7265380000136d696e6563726166743a64697370656e736572170000176d696e6563726166743a6c6176615f6361756c64726f6e2eff00146d696e6563726166743a647261676f6e5f6567677a0000176d696e6563726166743a6a756e676c655f737461697273880000116d696e6563726166743a64726f707065727d0000176d696e6563726166743a656d6572616c645f626c6f636b8500001a6d696e6563726166743a656e6368616e74696e675f7461626c657400001a6d696e6563726166743a656e645f627269636b5f7374616972734eff000e6d696e6563726166743a66697265330000116d696e6563726166743a6675726e6163653d00001b6d696e6563726166743a67696c6465645f626c61636b73746f6e65e7fe000f6d696e6563726166743a676c617373140000146d696e6563726166743a676c6173735f70616e65660000126d696e6563726166743a676f6c645f6f72650e0000156d696e6563726166743a676f6c64656e5f7261696c1b00000f6d696e6563726166743a6772617373020000146d696e6563726166743a67726173735f70617468c60000106d696e6563726166743a67726176656c0d0000206d696e6563726166743a677261795f676c617a65645f7465727261636f747461e30000216d696e6563726166743a677265656e5f676c617a65645f7465727261636f747461e90000146d696e6563726166743a686172645f676c617373fd0000196d696e6563726166743a686172645f676c6173735f70616e65be0000176d696e6563726166743a68617264656e65645f636c6179ac0000276d696e6563726166743a68656176795f77656967687465645f70726573737572655f706c617465940000156d696e6563726166743a696e666f5f757064617465f80000146d696e6563726166743a69726f6e5f626c6f636b2a0000176d696e6563726166743a6a756e676c655f627574746f6e71ff001a6d696e6563726166743a6974656d2e6a756e676c655f646f6f72c300001e6d696e6563726166743a6a756e676c655f7374616e64696e675f7369676e44ff00156d696e6563726166743a6c69745f6675726e6163653e00001a6d696e6563726166743a6a756e676c655f77616c6c5f7369676e43ff00136d696e6563726166743a6974656d2e6b656c7076ff001e6d696e6563726166743a756e6c69745f72656473746f6e655f746f7263684b0000106d696e6563726166743a6c6164646572410000156d696e6563726166743a6c617069735f626c6f636b160000136d696e6563726166743a6c617069735f6f72651500000e6d696e6563726166743a6c6176610b0000116d696e6563726166743a6c65637465726e3eff001b6d696e6563726166743a6d6f7373795f636f62626c6573746f6e653000000f6d696e6563726166743a6c65766572450000206d696e6563726166743a6c696d655f676c617a65645f7465727261636f747461e10000146d696e6563726166743a6c69745f736d6f6b657239ff00146d696e6563726166743a6d656c6f6e5f7374656d6900001d6d696e6563726166743a6974656d2e6e65746865725f7370726f75747312ff00226d696e6563726166743a6d6f7373795f73746f6e655f627269636b5f73746169727351ff00156d696e6563726166743a6d6f76696e67626c6f636bfa0000126d696e6563726166743a6d7963656c69756d6e0000166d696e6563726166743a6e65746865725f627269636b7000001c6d696e6563726166743a6e65746865725f627269636b5f66656e63657100001d6d696e6563726166743a6e65746865725f627269636b5f737461697273720000196d696e6563726166743a6e65746865725f676f6c645f6f7265e0fe001a6d696e6563726166743a6974656d2e6e65746865725f77617274730000146d696e6563726166743a6e65746865727261636b570000176d696e6563726166743a6e657468657272656163746f72f700001d6d696e6563726166743a6e6f726d616c5f73746f6e655f7374616972734cff00136d696e6563726166743a6e6f7465626c6f636b1900001a6d696e6563726166743a7761727065645f77616c6c5f7369676e03ff00146d696e6563726166743a6f616b5f737461697273350000206d696e6563726166743a70696e6b5f676c617a65645f7465727261636f747461e200001c6d696e6563726166743a706973746f6e61726d636f6c6c6973696f6e220000106d696e6563726166743a706f647a6f6cf30000196d696e6563726166743a706f6c69736865645f626173616c7415ff001d6d696e6563726166743a706f6c69736865645f626c61636b73746f6e65ddfe002f6d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f627269636b5f646f75626c655f736c6162e3fe001e6d696e6563726166743a7761727065645f7374616e64696e675f7369676e05ff00286d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f627269636b5f77616c6ceafe002c6d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f70726573737572655f706c617465d9fe00246d696e6563726166743a706f6c69736865645f626c61636b73746f6e655f737461697273dcfe001a6d696e6563726166743a706f77657265645f72657065617465725e00001b6d696e6563726166743a707269736d6172696e655f737461697273feff00166d696e6563726166743a70756d706b696e5f7374656d680000226d696e6563726166743a707572706c655f676c617a65645f7465727261636f747461db00001f6d696e6563726166743a7265645f676c617a65645f7465727261636f747461ea0000216d696e6563726166743a7265645f6e65746865725f627269636b5f73746169727348ff00176d696e6563726166743a72656473746f6e655f6c616d707b0000166d696e6563726166743a72656473746f6e655f6f7265490000176d696e6563726166743a72656473746f6e655f77697265370000216d696e6563726166743a726570656174696e675f636f6d6d616e645f626c6f636bbc00001a6d696e6563726166743a73616e6473746f6e655f737461697273800000156d696e6563726166743a7368726f6f6d6c696768741aff00146d696e6563726166743a6974656d2e736b756c6c900000256d696e6563726166743a736d6f6f74685f7265645f73616e6473746f6e655f73746169727350ff00216d696e6563726166743a736d6f6f74685f73616e6473746f6e655f7374616972734fff001c6d696e6563726166743a6974656d2e736f756c5f63616d7066697265defe00136d696e6563726166743a736f756c5f6669726513ff00166d696e6563726166743a736f756c5f6c616e7465726ef3fe00146d696e6563726166743a736f756c5f746f726368f4fe00146d696e6563726166743a6974656d2e77686561743b00001a6d696e6563726166743a6974656d2e7370727563655f646f6f72c100001f6d696e6563726166743a7370727563655f70726573737572655f706c61746566ff00196d696e6563726166743a7370727563655f74726170646f6f726bff00166d696e6563726166743a73746f6e655f627574746f6e4d0000166d696e6563726166743a73746f6e655f737461697273430000156d696e6563726166743a73746f6e65637574746572f500001c6d696e6563726166743a73747269707065645f62697263685f6c6f67faff00216d696e6563726166743a73747269707065645f6372696d736f6e5f687970686165d4fe001f6d696e6563726166743a73747269707065645f6461726b5f6f616b5f6c6f67f7ff001d6d696e6563726166743a73747269707065645f6a756e676c655f6c6f67f9ff001d6d696e6563726166743a73747269707065645f7370727563655f6c6f67fbff00206d696e6563726166743a73747269707065645f7761727065645f687970686165d3fe001e6d696e6563726166743a73747269707065645f7761727065645f7374656d0fff00196d696e6563726166743a7374727563747572655f626c6f636bfc0000186d696e6563726166743a7374727563747572655f766f6964d900001a6d696e6563726166743a73776565745f62657272795f6275736831ff000f6d696e6563726166743a746f726368320000176d696e6563726166743a74726970776972655f686f6f6b8300001a6d696e6563726166743a756e64657277617465725f746f726368ef00001c6d696e6563726166743a756e706f77657265645f72657065617465725d00001b6d696e6563726166743a7761727065645f776172745f626c6f636b1dff000e6d696e6563726166743a76696e656a0000156d696e6563726166743a77616c6c5f62616e6e6572b100001c6d696e6563726166743a7761727065645f646f75626c655f736c6162f5fe001b6d696e6563726166743a7761727065645f66656e63655f67617465fdfe00176d696e6563726166743a7761727065645f687970686165d6fe00176d696e6563726166743a7761727065645f6e796c69756d17ff00176d696e6563726166743a7761727065645f706c616e6b730dff001f6d696e6563726166743a7761727065645f70726573737572655f706c617465f9fe00176d696e6563726166743a7761727065645f73746169727301ff00156d696e6563726166743a7761727065645f7374656d1eff000f6d696e6563726166743a77617465720900000d6d696e6563726166743a7765621e0000216d696e6563726166743a77686974655f676c617a65645f7465727261636f747461dc00001f6d696e6563726166743a776f6f64656e5f70726573737572655f706c617465480000156d696e6563726166743a7769746865725f726f736528ff001a6d696e6563726166743a6974656d2e776f6f64656e5f646f6f724000002465303438386162302d333234362d346133372d386238332d38626435616239623433366601' + const buf = Buffer.from(s, 'hex') + const des = read(buf) + console.log(des.data.name) + const newBuf = write(des.data.name, des.data.params) + console.log(newBuf) + console.assert(newBuf.toString('hex')==s) + // console.log(serialize(des.data.params, 2)) + } + + async function testAdventureSettings() { + // const buf = Buffer.from('3720009f02010001000000fdffffff') + // const des = read(buf) + // console.log(serialize(des.data.params, 2)) + + const buf = write('adventure_settings', { + flags: { + world_immutable: true, + no_pvp: true + }, + command_permission: 'normal', + action_permissions: { + open_containers: true + }, + permission_level: 'member', + custom_stored_permissions: 0, + user_id: 0 + }) + const des = read(buf) + // fs.writeFileSync('cc.json', serialize(des.data.params, 2)) + console.log('Des', JSON.stringify(des, null, 2)) + } + + async function testInventory() { + const buf = Buffer.from('1e00020000008c0a419e0104060031bb2144723d8342aff19b420000403f0079873e8047513f8833', 'hex') + const des = read(buf) + console.log(JSON.stringify(des)) + } + + async function testInventory() { + const buf = Buffer.from('1e00020000008c0a419e0104060031bb2144723d8342aff19b420000403f0079873e8047513f8833', 'hex') + + } + // creativeTst() // availableCommands() // avaliableCmd() + // creativeTestNew() + // biomeDefinitions() + // startGame() + testInventory() } if (!module.parent) { test() +} + +function serialize(obj = {}, fmt) { + return JSON.stringify(obj, (k, v) => typeof v == 'bigint' ? v.toString() : v, fmt) } \ No newline at end of file From 9bd8f4c2bb59e2ab68acfb82b29d62ef5aa50b19 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 25 Feb 2021 13:11:22 -0500 Subject: [PATCH 099/106] server sending generated chunks --- .gitignore | 2 +- data/new/proto.yml | 2 +- data/newproto.json | 2 +- package.json | 1 + src/serverTest.js | 90 +++++++++++++++++++++++----------------------- 5 files changed, 50 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 4f37984..2f3cd51 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ npm-debug.log __* data/*.js src/**/*.json -src/*.txt +src/**/*.txt dist/ \ No newline at end of file diff --git a/data/new/proto.yml b/data/new/proto.yml index b209d4f..db42f42 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -1003,7 +1003,7 @@ packet_level_chunk: # true. If set to false, the payload is composed of multiple sub-chunks, each of which carry a version # which indicates the way they are serialised, followed by biomes, border blocks and tile entities. If # CacheEnabled is true, the payload consists out of the border blocks and tile entities only. - payload: string + payload: ByteArray packet_set_commands_enabled: !id: 0x3b diff --git a/data/newproto.json b/data/newproto.json index 689ff79..9779bac 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -4506,7 +4506,7 @@ }, { "name": "payload", - "type": "string" + "type": "ByteArray" } ] ], diff --git a/package.json b/package.json index 175c491..18a635e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@xboxreplay/xboxlive-auth": "^3.3.3", "aes-js": "^3.1.2", "asn1": "^0.2.4", + "bedrock-provider": "github:extremeheat/bedrock-provider", "bn.js": "^4.11.4", "debug": "^4.3.1", "ec-pem": "^0.18.0", diff --git a/src/serverTest.js b/src/serverTest.js index ad54097..6d01f96 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -4,6 +4,7 @@ const CreativeItems = require('../data/creativeitems.json') const NBT = require('prismarine-nbt') const fs = require('fs') + let server = new Server({ }) @@ -38,45 +39,7 @@ server.on('connect', ({ client }) => { }) client.once('resource_pack_client_response', async (packet) => { - // ran = true - // let items = [] - // let ids = 0 - // for (var item of CreativeItems) { - // let creativeitem = { runtime_id: items.length } - // const has_nbt = !!item.nbt_b64 - // if (item.id != 0) { - // creativeitem.item = { - // network_id: item.id, - // auxiliary_value: item.damage || 0, - // has_nbt, - // nbt: { - // version: 1, - // }, - // blocking_tick: 0, - // can_destroy: [], - // can_place_on: [] - // } - // if (has_nbt) { - // let nbtBuf = Buffer.from(item.nbt_b64, 'base64') - // let { parsed } = await NBT.parse(nbtBuf, 'little') - // creativeitem.item.nbt.nbt = parsed - // } - // } - // items.push(creativeitem) - // // console.log(creativeitem) - // } - - // console.log(items, ids) - - // client.write('creative_content', { items }) - // wait a bit just for easier debugging - // setTimeout(() => { - // const biomeDefs = fs.readFileSync('../data/biome_definitions.nbt') - // client.writeRaw('biome_definition_list', biomeDefs) - - // // TODO: send chunks so we can spawn player - // }, 1000) - + }) client.write('network_settings', { @@ -109,10 +72,14 @@ server.on('connect', ({ client }) => { client.queue('game_rules_changed', require('./packets/game_rules_changed.json')) client.queue('respawn', {"x":646.9405517578125,"y":65.62001037597656,"z":77.86255645751953,"state":0,"runtime_entity_id":0}) - for (const file of fs.readdirSync('chunks')) { - const buffer = Buffer.from(fs.readFileSync('./chunks/' + file, 'utf8'), 'hex') - // console.log('Sending chunk', chunk) - client.sendBuffer(buffer) + // for (const file of fs.readdirSync('chunks')) { + // const buffer = Buffer.from(fs.readFileSync('./chunks/' + file, 'utf8'), 'hex') + // // console.log('Sending chunk', chunk) + // client.sendBuffer(buffer) + // } + + for (const chunk of chunks) { + client.queue('level_chunk', chunk) } setInterval(() => { @@ -131,4 +98,39 @@ async function sleep(ms) { return new Promise(res => { setTimeout(() => { res() }, ms) }) -} \ No newline at end of file +} + +// CHUNKS +const { ChunkColumn, Version } = require('bedrock-provider') +const mcData = require('minecraft-data')('1.16') +var chunks = [] +async function buildChunks() { + // "x": 40, + // "z": 4, + + const stone = mcData.blocksByName.stone + + for (var cx = 35; cx < 45; cx++) { + for (var cz = 0; cz < 8; cz++) { + const column = new ChunkColumn(Version.v1_2_0_bis, x, z) + for (var x = 0; x < 16; x++) { + for (var y = 0; y < 60; y++) { + for (var z = 0; z < 16; z++) { + column.setBlock(x,y,z,stone) + } + } + } + + const ser = await column.networkEncodeNoCache() + + chunks.push({ + x:cx, z:cz, sub_chunk_count: column.sectionsLen, cache_enabled: false, + blobs: [], payload: ser + }) + } + } + + // console.log('Chunks',chunks) +} + +buildChunks() \ No newline at end of file From c7823ab71a79242bf92785e6f2f84600c893675c Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 25 Feb 2021 15:21:56 -0500 Subject: [PATCH 100/106] cleanup Update packages, remove junk --- .babelrc | 7 -- .eslintrc | 41 ---------- .gitignore | 1 + dist/createClient.js | 70 ---------------- dist/createServer.js | 147 ---------------------------------- dist/datatypes/minecraft.js | 139 -------------------------------- dist/index.js | 9 --- dist/transforms/serializer.js | 32 -------- package.json | 20 +---- src/ConnWorker.js | 2 +- src/old/createClient.js | 63 --------------- src/old/createServer.js | 138 ------------------------------- 12 files changed, 4 insertions(+), 665 deletions(-) delete mode 100644 .babelrc delete mode 100644 .eslintrc delete mode 100644 dist/createClient.js delete mode 100644 dist/createServer.js delete mode 100644 dist/datatypes/minecraft.js delete mode 100644 dist/index.js delete mode 100644 dist/transforms/serializer.js delete mode 100644 src/old/createClient.js delete mode 100644 src/old/createServer.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index f475336..0000000 --- a/.babelrc +++ /dev/null @@ -1,7 +0,0 @@ - -{ - "presets": [ - "@babel/preset-env", - "@babel/preset-typescript" - ] -} diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index bb70c93..0000000 --- a/.eslintrc +++ /dev/null @@ -1,41 +0,0 @@ -{ - "parser": "babel-eslint", - - "extends": [ - "eslint:recommended" - ], - - "plugins": [ - "@typescript-eslint", - "import" - ], - - "env": { - "es6": true, - "browser": true, - "node": true, - "jasmine": true - }, - - "parserOptions": { - "ecmaFeatures": { - "jsx": true, - "modules": true - } - }, - - "rules": { - "consistent-return": 2, - "no-mixed-operators": 0, - "no-useless-constructor": 0, - "standard/computed-property-even-spacing": 0, - "import/first": 0, - "no-unused-vars": 2, - "no-console": 2, - - "indent": ["error", 4, {"SwitchCase": 1}], - "semi": ["error", "always"], - "brace-style": ["error", "1tbs", { "allowSingleLine": true }], - "radix": ["off"] - } -} diff --git a/.gitignore b/.gitignore index 2f3cd51..f7f9591 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules/ npm-debug.log +package-lock.json __* data/*.js src/**/*.json diff --git a/dist/createClient.js b/dist/createClient.js deleted file mode 100644 index 13d4cd8..0000000 --- a/dist/createClient.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -var assert = require('assert'); - -var raknet = require('raknet'); - -var fs = require('fs'); - -var path = require('path'); - -var zlib = require('zlib'); - -var ProtoDef = require('protodef').ProtoDef; - -var batchProto = new ProtoDef(); -batchProto.addTypes(require("./datatypes/minecraft")); -batchProto.addType("insideBatch", ["endOfArray", { - "type": ["buffer", { - "countType": "i32" - }] -}]); - -function createClient(options) { - return null; //FIXME - - assert.ok(options, 'options is required'); - var port = options.port || 19132; - var host = options.host || 'localhost'; - assert.ok(options.username, 'username is required'); - options.customPackets = require('../data/protocol'); - options.customTypes = require('./datatypes/minecraft'); - var client = raknet.createClient(options); - client.username = options.username; - client.on('mcpe', function (packet) { - return client.emit(packet.name, packet.params); - }); - - client.writeMCPE = function (name, packet) { - client.writeEncapsulated('mcpe', { - name: name, - params: packet - }); - }; - - client.on('login', function () { - client.writeMCPE('game_login', { - username: client.username, - protocol: 70, - protocol2: 70, - clientId: [-1, -697896776], - clientUuid: '86372ed8-d055-b23a-9171-5e3ac594d766', - serverAddress: client.host + ":" + client.port, - clientSecret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g, ''), 'hex'), - skin: { - skinType: 'Standard_Steve', - texture: fs.readFileSync(path.join(__dirname, 'texture')) - } - }); - }); - client.on('batch', function (packet) { - var buf = zlib.inflateSync(packet.payload); - var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; - packets.forEach(function (packet) { - return client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet])); - }); - }); - return client; -} - -module.exports = createClient; \ No newline at end of file diff --git a/dist/createServer.js b/dist/createServer.js deleted file mode 100644 index e808cc9..0000000 --- a/dist/createServer.js +++ /dev/null @@ -1,147 +0,0 @@ -"use strict"; - -var _raknet = _interopRequireDefault(require("raknet")); - -var _zlib = _interopRequireDefault(require("zlib")); - -var _jwtSimple = _interopRequireDefault(require("jwt-simple")); - -var _protodef = require("protodef"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var batchProto = new _protodef.ProtoDef(); -var PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; // createServer (object, boolean) -// -// Create & launch a MCPE raknet-based server. -// object: raknet options -// encryption: enable/disable encryption - -function createServer(options, encryption) { - options = options || {}; - var port = options.port || options['server-port'] || 19132; - var host = options.host || '0.0.0.0'; - options.customPackets = (options.protocol ? options.protocol.packets : null) || require('../data/protocol'); - options.customTypes = (options.protocol ? options.protocol.types : null) || require('./datatypes/minecraft'); - batchProto.addTypes(options.customTypes); - batchProto.addType('insideBatch', ['endOfArray', { - 'type': ['buffer', { - 'countType': 'varint' - }] - }]); - - var server = _raknet["default"].createServer(options); - - server.name = options.name || 'Minecraft Server'; - server.motd = options.motd || 'A Minecraft server'; //FIXME - - server.maxPlayers = options['max-players'] || 20; //FIXME - - server.playerCount = 0; //FIXME - - server.on('connection', function (client) { - client.receiveCounter = 0; - client.sendCounter = 0; - client.encryptionEnabled = encryption ? true : false; - var proto = new _protodef.ProtoDef(); - proto.addTypes(options.customTypes); - proto.addTypes(options.customPackets.types); - client.mcpePacketSerializer = new _protodef.Serializer(proto, 'mcpe_packet'); - client.on('mcpe', function (packet) { - client.emit(packet.name, packet.params); - client.emit('debug', packet.name); - }); - client.on('batch', function (packets) { - var buf = _zlib["default"].inflateSync(packets.payload); - - var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; - packets.forEach(function (packet) { - return client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet])); - }); - }); // client.writePacket (string, object) - // Send data to the client - // - // string: packet name - // object: packet data - - client.writeMCPE = function (name, params) { - if (client.encryptionEnabled) { - client.mcpePacketSerializer.write({ - name: name, - params: params - }); - } else { - client.writeEncapsulated('mcpe', { - name: name, - params: params - }); - } - }; - - client.writePacket = client.writeMCPE; // client.writeData (array) - // Send data to the client - // - // array: packets to send - - client.writeBatch = function (packets) { - var payload = _zlib["default"].deflateSync(batchProto.createPacketBuffer('insideBatch', packets.map(function (packet) { - return client.mcpePacketSerializer.createPacketBuffer(packet); - }))); - - client.writePacket('batch', { - payload: payload - }); - }; - - client.writeData = client.writeBatch; // client.writeAll (string, object) - // Send data to the client - // - // string: packet name - // object: packet data - - client.writeAll = function (name, data) { - server._writeAll(name, data); - }; - - client.on('game_login', function (packet) { - try { - var dataProto = new _protodef.ProtoDef(); - dataProto.addType('data_chain', ['container', [{ - 'name': 'chain', - 'type': ['pstring', { - 'countType': 'li32' - }] - }, { - 'name': 'clientData', - 'type': ['pstring', { - 'countType': 'li32' - }] - }]]); //FIXME: Xbox & Non-Xbox support - - console.log(packet); - var body = dataProto.parsePacketBuffer('data_chain', _zlib["default"].inflateSync(packet.body)), - chain = null, - decode = null, - data = null; - body.data.chain = JSON.parse(body.data.chain); - chain = body.data.chain.chain[0]; - decode = _jwtSimple["default"].decode(chain, PUBLIC_KEY, 'ES384'); - data = _jwtSimple["default"].decode(body.data.clientData, decode.identityPublicKey, 'ES384'); - client.emit('mcpe_login', { - protocol: packet.protocol, - uuid: decode.extraData != null ? decode.extraData.identity : null, - id: decode.extraData != null ? decode.extraData.identityPublicKey : null, - username: decode.extraData != null ? decode.extraData.displayName : null, - skinData: data.SkinData, - skinId: data.SkinId - }); - } catch (err) { - console.error(err); - return null; - } - }); - }); - return server; -} - -module.exports = createServer; \ No newline at end of file diff --git a/dist/datatypes/minecraft.js b/dist/datatypes/minecraft.js deleted file mode 100644 index 9a1fcb8..0000000 --- a/dist/datatypes/minecraft.js +++ /dev/null @@ -1,139 +0,0 @@ -'use strict'; - -var nbt = require('prismarine-nbt'); - -var UUID = require('uuid-1345'); - -function readUUID(buffer, offset) { - if (offset + 16 > buffer.length) throw new PartialReadError(); - return { - value: UUID.stringify(buffer.slice(offset, 16 + offset)), - size: 16 - }; -} - -function writeUUID(value, buffer, offset) { - var buf = UUID.parse(value); - buf.copy(buffer, offset); - return offset + 16; -} - -function readNbt(buffer, offset) { - return nbt.protoLE.read(buffer, offset, "nbt"); -} - -function writeNbt(value, buffer, offset) { - return nbt.protoLE.write(value, buffer, offset, "nbt"); -} - -function sizeOfNbt(value) { - return nbt.protoLE.sizeOf(value, "nbt"); -} - -function readEntityMetadata(buffer, offset, _ref) { - var type = _ref.type; - var endVal = _ref.endVal; - var cursor = offset; - var metadata = []; - var item = undefined; - - while (true) { - if (offset + 1 > buffer.length) throw new PartialReadError(); - item = buffer.readUInt8(cursor); - - if (item === endVal) { - return { - value: metadata, - size: cursor + 1 - offset - }; - } - - var results = this.read(buffer, cursor, type, {}); - metadata.push(results.value); - cursor += results.size; - } -} - -function writeEntityMetadata(value, buffer, offset, _ref2) { - var type = _ref2.type; - var endVal = _ref2.endVal; - var self = this; - value.forEach(function (item) { - offset = self.write(item, buffer, offset, type, {}); - }); - buffer.writeUInt8(endVal, offset); - return offset + 1; -} - -function sizeOfEntityMetadata(value, _ref3) { - var type = _ref3.type; - var size = 1; - - for (var i = 0; i < value.length; ++i) { - size += this.sizeOf(value[i], type, {}); - } - - return size; -} - -function readIpAddress(buffer, offset) { - var address = buffer[offset] + '.' + buffer[offset + 1] + '.' + buffer[offset + 2] + '.' + buffer[offset + 3]; - return { - size: 4, - value: address - }; -} - -function writeIpAddress(value, buffer, offset) { - var address = value.split('.'); - address.forEach(function (b) { - buffer[offset] = parseInt(b); - offset++; - }); - return offset; -} - -function readEndOfArray(buffer, offset, typeArgs) { - var type = typeArgs.type; - var cursor = offset; - var elements = []; - - while (cursor < buffer.length) { - var results = this.read(buffer, cursor, type, {}); - elements.push(results.value); - cursor += results.size; - } - - return { - value: elements, - size: cursor - offset - }; -} - -function writeEndOfArray(value, buffer, offset, typeArgs) { - var type = typeArgs.type; - var self = this; - value.forEach(function (item) { - offset = self.write(item, buffer, offset, type, {}); - }); - return offset; -} - -function sizeOfEndOfArray(value, typeArgs) { - var type = typeArgs.type; - var size = 0; - - for (var i = 0; i < value.length; ++i) { - size += this.sizeOf(value[i], type, {}); - } - - return size; -} - -module.exports = { - 'uuid': [readUUID, writeUUID, 16], - 'nbt': [readNbt, writeNbt, sizeOfNbt], - 'entityMetadataLoop': [readEntityMetadata, writeEntityMetadata, sizeOfEntityMetadata], - 'ipAddress': [readIpAddress, writeIpAddress, 4], - 'endOfArray': [readEndOfArray, writeEndOfArray, sizeOfEndOfArray] -}; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9db82d4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -module.exports = { - createSerializer: require("./transforms/serializer").createSerializer, - createDeserializer: require("./transforms/serializer").createDeserializer, - createProtocol: require('./transforms/serializer').createProtocol, - createServer: require("./createServer"), - createClient: require("./createClient") -}; \ No newline at end of file diff --git a/dist/transforms/serializer.js b/dist/transforms/serializer.js deleted file mode 100644 index a1b0965..0000000 --- a/dist/transforms/serializer.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -var ProtoDef = require('protodef').ProtoDef; - -var Serializer = require('protodef').Serializer; - -var Parser = require('protodef').Parser; - -var protocol = require('../../data/protocol.json').types; - -function createProtocol() { - var proto = new ProtoDef(); - proto.addTypes(require('../datatypes/minecraft')); - proto.addTypes(protocol); - return proto; -} - -function createSerializer() { - var proto = createProtocol(); - return new Serializer(proto, 'packet'); -} - -function createDeserializer() { - var proto = createProtocol(); - return new Parser(proto, 'packet'); -} - -module.exports = { - createDeserializer: createDeserializer, - createSerializer: createSerializer, - createProtocol: createProtocol -}; \ No newline at end of file diff --git a/package.json b/package.json index 18a635e..90a49d6 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "description": "Parse and serialize Minecraft Bedrock Edition packets", "main": "index.js", "scripts": { - "build": "babel src --out-dir dist", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ @@ -15,34 +14,22 @@ "license": "MIT", "dependencies": { "@azure/msal-node": "^1.0.0-beta.6", - "@babel/core": "^7.5.4", - "@babel/preset-env": "^7.5.4", - "@babel/preset-typescript": "^7.3.3", - "@babel/register": "^7.4.4", "@jsprismarine/jsbinaryutils": "^2.1.8", - "@jsprismarine/raknet": "github:extremeheat/raknet#client", "@xboxreplay/xboxlive-auth": "^3.3.3", "aes-js": "^3.1.2", "asn1": "^0.2.4", "bedrock-provider": "github:extremeheat/bedrock-provider", - "bn.js": "^4.11.4", "debug": "^4.3.1", "ec-pem": "^0.18.0", "jsonwebtoken": "^8.5.1", "jsp-raknet": "github:extremeheat/raknet#client", - "jwt-simple": "^0.5.6", - "lodash.merge": "^4.4.0", "minecraft-folder-path": "^1.1.0", "prismarine-nbt": "github:extremeheat/prismarine-nbt#le", "protodef": "github:extremeheat/node-protodef#compiler", - "raknet": "git+https://github.com/mhsjlw/node-raknet.git#master", "uuid-1345": "^0.99.7" }, "devDependencies": { - "@babel/cli": "^7.5.0", - "buffer-equal": "^1.0.0", - "mocha": "^2.5.3", - "pre-commit": "^1.2.2" + "mocha": "^2.5.3" }, "repository": { "type": "git", @@ -51,8 +38,5 @@ "bugs": { "url": "https://github.com/mhsjlw/pocket-minecraft-protocol/issues" }, - "homepage": "https://github.com/mhsjlw/pocket-minecraft-protocol#readme", - "pre-commit": [ - "build" - ] + "homepage": "https://github.com/mhsjlw/pocket-minecraft-protocol#readme" } diff --git a/src/ConnWorker.js b/src/ConnWorker.js index 81e7507..996ed56 100644 --- a/src/ConnWorker.js +++ b/src/ConnWorker.js @@ -1,6 +1,6 @@ const RakClient = require('jsp-raknet/client') const { Worker, isMainThread, parentPort } = require('worker_threads') -const EncapsulatedPacket = require('@jsprismarine/raknet/protocol/encapsulated_packet') +const EncapsulatedPacket = require('jsp-raknet/protocol/encapsulated_packet') function connect(hostname, port) { if (isMainThread) { diff --git a/src/old/createClient.js b/src/old/createClient.js deleted file mode 100644 index 4e87d1c..0000000 --- a/src/old/createClient.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; -const assert = require('assert'); -const raknet = require('raknet'); -const fs = require('fs'); -const path = require('path'); -const zlib = require('zlib'); -const ProtoDef = require('protodef').ProtoDef; -const batchProto = new ProtoDef(); -batchProto.addTypes(require("./datatypes/minecraft")); -batchProto.addType("insideBatch", ["endOfArray", { "type": ["buffer", { "countType": "i32" }] }]); - -function createClient(options) { - return null; //FIXME - - assert.ok(options, 'options is required'); - var port = options.port || 19132; - var host = options.host || 'localhost'; - - assert.ok(options.username, 'username is required'); - - options.customPackets = require('../data/protocol'); - options.customTypes = require('./datatypes/minecraft'); - - var client = raknet.createClient(options); - client.username = options.username; - client.on('mcpe', packet => client.emit(packet.name, packet.params)) - client.writeMCPE = (name, packet) => { - client.writeEncapsulated('mcpe', { - name: name, - params: packet - }); - }; - - client.on('login', function () { - client.writeMCPE('game_login', - { - username: client.username, - protocol: 70, - protocol2: 70, - clientId: [-1, -697896776], - clientUuid: '86372ed8-d055-b23a-9171-5e3ac594d766', - serverAddress: client.host + ":" + client.port, - clientSecret: new Buffer('e8 88 db 7b 9f f2 f0 44 a3 51 08 18 4e 8c 7f 9a'.replace(/ /g, ''), 'hex'), - skin: - { - skinType: 'Standard_Steve', - texture: fs.readFileSync(path.join(__dirname, 'texture')) - } - } - ); - - }); - - client.on('batch', function (packet) { - var buf = zlib.inflateSync(packet.payload); - var packets = batchProto.parsePacketBuffer("insideBatch", buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); - }); - - return client; -} - -module.exports = createClient; diff --git a/src/old/createServer.js b/src/old/createServer.js deleted file mode 100644 index cbca2d9..0000000 --- a/src/old/createServer.js +++ /dev/null @@ -1,138 +0,0 @@ -import raknet from 'raknet'; -import zlib from 'zlib'; -import jwt from 'jwt-simple'; -import { ProtoDef, Parser, Serializer } from 'protodef'; - -let batchProto = new ProtoDef(); -const PUBLIC_KEY = 'MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V'; - -// createServer (object, boolean) -// -// Create & launch a MCPE raknet-based server. -// object: raknet options -// encryption: enable/disable encryption -function createServer(options, encryption) { - options = options || {}; - - const port = options.port || options['server-port'] || 19132; - const host = options.host || '0.0.0.0'; - - options.customPackets = (options.protocol ? options.protocol.packets : null) || require('../data/protocol'); - options.customTypes = (options.protocol ? options.protocol.types : null) || require('./datatypes/minecraft'); - - batchProto.addTypes(options.customTypes); - batchProto.addType('insideBatch', ['endOfArray', { - 'type': ['buffer', { - 'countType': 'varint', - }] - }]); - - let server = raknet.createServer(options); - server.name = options.name || 'Minecraft Server'; - server.motd = options.motd || 'A Minecraft server'; //FIXME - server.maxPlayers = options['max-players'] || 20; //FIXME - server.playerCount = 0; //FIXME - - server.on('connection', (client) => { - client.receiveCounter = 0; - client.sendCounter = 0; - client.encryptionEnabled = encryption ? true : false; - - let proto = new ProtoDef(); - proto.addTypes(options.customTypes); - proto.addTypes(options.customPackets.types); - client.mcpePacketSerializer = new Serializer(proto, 'mcpe_packet'); - - client.on('mcpe', packet => { - client.emit(packet.name, packet.params); - client.emit('debug', packet.name); - }); - client.on('batch', function (packets) { - var buf = zlib.inflateSync(packets.payload); - var packets = batchProto.parsePacketBuffer('insideBatch', buf).data; - packets.forEach(packet => client.readEncapsulatedPacket(Buffer.concat([new Buffer([0xfe]), packet]))); - }); - - // client.writePacket (string, object) - // Send data to the client - // - // string: packet name - // object: packet data - client.writeMCPE = (name, params) => { - if (client.encryptionEnabled) { - client.mcpePacketSerializer.write({ name, params }); - } else { - client.writeEncapsulated('mcpe', { name, params }); - } - }; - client.writePacket = client.writeMCPE; - - // client.writeData (array) - // Send data to the client - // - // array: packets to send - client.writeBatch = (packets) => { - const payload = zlib.deflateSync(batchProto.createPacketBuffer('insideBatch', - packets.map(packet => client.mcpePacketSerializer.createPacketBuffer(packet)))); - - client.writePacket('batch', { - payload: payload - }); - }; - client.writeData = client.writeBatch; - - // client.writeAll (string, object) - // Send data to the client - // - // string: packet name - // object: packet data - client.writeAll = (name, data) => { - server._writeAll(name, data); - }; - - client.on('game_login', (packet) => { - try { - let dataProto = new ProtoDef(); - dataProto.addType('data_chain', ['container', [{ - 'name': 'chain', - 'type': ['pstring', { - 'countType': 'li32' - }] - }, { - 'name': 'clientData', - 'type': ['pstring', { - 'countType': 'li32' - }] - }]]); - - //FIXME: Xbox & Non-Xbox support - console.log(packet); - let body = dataProto.parsePacketBuffer('data_chain', zlib.inflateSync(packet.body)), - chain = null, - decode = null, - data = null; - - body.data.chain = JSON.parse(body.data.chain); - chain = body.data.chain.chain[0]; - - decode = jwt.decode(chain, PUBLIC_KEY, 'ES384'); - data = jwt.decode(body.data.clientData, decode.identityPublicKey, 'ES384'); - - client.emit('mcpe_login', { - protocol: packet.protocol, - uuid: (decode.extraData != null) ? decode.extraData.identity : null, - id: (decode.extraData != null) ? decode.extraData.identityPublicKey : null, - username: (decode.extraData != null) ? decode.extraData.displayName : null, - skinData: data.SkinData, - skinId: data.SkinId - }) - } catch (err) { - console.error(err); - return null; - } - }); - }); - return server; -} - -module.exports = createServer; From b64a22a8fc99d37a8ce27311086d248ac0cf10bf Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 25 Feb 2021 17:47:14 -0500 Subject: [PATCH 101/106] protocol updates, movement fixes packet_map is now auto-generated --- data/new/compile.js | 40 ++++-- data/new/packet_map.yml | 6 +- data/new/proto.yml | 86 +++++++++++-- data/new/types.yaml | 139 +++++++++++++++++++++ data/newproto.json | 268 +++++++++++++++++++++++++++++++++++++--- package.json | 1 + src/serverTest.js | 33 +++-- 7 files changed, 531 insertions(+), 42 deletions(-) diff --git a/data/new/compile.js b/data/new/compile.js index 7ffca0e..9ba4669 100644 --- a/data/new/compile.js +++ b/data/new/compile.js @@ -1,17 +1,43 @@ +/** + * This is a utility script that converts the YAML here into ProtoDef schema code and (soon) docs/typescript definitions. + * It also pre-compiles JS code from the schema for easier development. + * + * You can run this with `npm run build` + * + */ const fs = require('fs') const { ProtoDefCompiler } = require('protodef').Compiler -let compile -try { - compile = require('protodef-yaml/compiler').compile -} catch (e) { - require('child_process').execSync('npx protodef-yaml proto.yml protocol.json') -} +function genProtoSchema() { + const { parse, compile } = require('protodef-yaml/compiler') + + // Create the packet_map.yml from proto.yml + const parsed = parse('./proto.yml') + const packets = [] + for (const key in parsed) { + if (key.startsWith('%container')) { + const [, name] = key.split(',') + if (name.startsWith('packet_')) { + const children = parsed[key] + const packetName = name.replace('packet_', '') + const packetID = children['!id'] + packets.push([packetID, packetName, name]) + } + } + } + let l1 = l2 = '' + for (const [id,name,fname] of packets) { + l1 += ` 0x${id.toString(16).padStart(2, '0')}: ${name}\n` + l2 += ` if ${name}: ${fname}\n` + } + const t = `!import: types.yaml\nmcpe_packet:\n name: varint =>\n${l1}\n params: name ?\n${l2}` + fs.writeFileSync('./packet_map.yml', t) -if (compile) { compile('./proto.yml', 'protocol.json') } +genProtoSchema() + fs.writeFileSync('../newproto.json', JSON.stringify({ types: require('./protocol.json') }, null, 2)) fs.unlinkSync('./protocol.json') //remove temp file diff --git a/data/new/packet_map.yml b/data/new/packet_map.yml index 6f698c9..ff3e7f0 100644 --- a/data/new/packet_map.yml +++ b/data/new/packet_map.yml @@ -1,4 +1,3 @@ - !import: types.yaml mcpe_packet: name: varint => @@ -64,6 +63,7 @@ mcpe_packet: 0x3e: set_player_game_type 0x3f: player_list 0x40: simple_event + 0x41: event 0x42: spawn_experience_orb 0x43: clientbound_map_item_data 0x44: map_info_request @@ -141,6 +141,7 @@ mcpe_packet: 0x9c: packet_violation_warning 0xa2: item_component 0xa3: filter_text_packet + params: name ? if login: packet_login if play_status: packet_play_status @@ -204,6 +205,7 @@ mcpe_packet: if set_player_game_type: packet_set_player_game_type if player_list: packet_player_list if simple_event: packet_simple_event + if event: packet_event if spawn_experience_orb: packet_spawn_experience_orb if clientbound_map_item_data: packet_clientbound_map_item_data if map_info_request: packet_map_info_request @@ -280,4 +282,4 @@ mcpe_packet: if update_player_game_type: packet_update_player_game_type if packet_violation_warning: packet_packet_violation_warning if item_component: packet_item_component - if filter_text_packet: packet_filter_text_packet \ No newline at end of file + if filter_text_packet: packet_filter_text_packet diff --git a/data/new/proto.yml b/data/new/proto.yml index db42f42..526273f 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -453,19 +453,52 @@ packet_move_entity: position: vec3f rotation: Rotation +# MovePlayer is sent by players to send their movement to the server, and by the server to update the +# movement of player entities to other players. packet_move_player: !id: 0x13 !bound: both - runtime_entity_id: varint - x: lf32 - y: lf32 - z: lf32 + # EntityRuntimeID is the runtime ID of the player. The runtime ID is unique for each world session, and + # entities are generally identified in packets using this runtime ID. + runtime_id: varint + # Position is the position to spawn the player on. If the player is on a distance that the viewer cannot + # see it, the player will still show up if the viewer moves closer. + position: vec3f + # Pitch is the vertical rotation of the player. Facing straight forward yields a pitch of 0. Pitch is + # measured in degrees. pitch: lf32 + # Yaw is the horizontal rotation of the player. Yaw is also measured in degrees yaw: lf32 + # HeadYaw is the same as Yaw, except that it applies specifically to the head of the player. A different + # value for HeadYaw than Yaw means that the player will have its head turned head_yaw: lf32 - mode: u8 + # Mode is the mode of the movement. It specifies the way the player's movement should be shown to other + # players. It is one of the constants below. + mode: u8 => + 0: normal + 1: reset + 2: teleport + 3: rotation + # OnGround specifies if the player is considered on the ground. Note that proxies or hacked clients could + # fake this to always be true, so it should not be taken for granted. on_ground: bool - other_runtime_entity_id: varint + # RiddenEntityRuntimeID is the runtime ID of the entity that the player might currently be riding. If not + # riding, this should be left 0. + ridden_runtime_id: varint + teleport: mode ? + if teleport: + # TeleportCause is written only if Mode is MoveModeTeleport. It specifies the cause of the teleportation, + # which is one of the constants above. + cause: li32 => + 0: unknown + 1: projectile + 2: chorus_fruit + 3: command + 4: behavior + # TeleportSourceEntityType is the entity type that caused the teleportation, for example an ender pearl. + # TODO: is this still a integer and not a string? + source_entity_type: LegacyEntityType + tick: varint64 packet_rider_jump: !id: 0x14 @@ -489,10 +522,20 @@ packet_add_painting: direction: zigzag32 title: string +# TickSync is sent by the client and the server to maintain a synchronized, server-authoritative tick between +# the client and the server. The client sends this packet first, and the server should reply with another one +# of these packets, including the response time. packet_tick_sync: !id: 0x17 !bound: both + # ClientRequestTimestamp is the timestamp on which the client sent this packet to the server. The server + # should fill out that same value when replying. + # The ClientRequestTimestamp is always 0 request_time: li64 + # ServerReceptionTimestamp is the timestamp on which the server received the packet sent by the client. + # When the packet is sent by the client, this value is 0. + # ServerReceptionTimestamp is generally the current tick of the server. It isn't an actual timestamp, as + # the field implies response_time: li64 packet_level_sound_event_old: @@ -1037,6 +1080,33 @@ packet_simple_event: !bound: client event_type: lu16 +# Event is sent by the server to send an event with additional data. It is typically sent to the client for +# telemetry reasons, much like the SimpleEvent packet. +packet_event: + !id: 0x41 + !bound: client + runtime_id: varint64 + event_type: varint => + 0: achievement_awarded + 1: entity_interact + 2: portal_built + 3: portal_used + 4: mob_killed + 5: cauldron_used + 6: player_death + 7: boss_killed + 8: agent_command + 9: agent_created + 10: banner_pattern_removed + 11: commaned_executed + 12: fish_bucketed + 13: mob_born + 14: pet_died + 15: cauldron_block_used + 16: composter_block_used + 17: bell_block_used + use_player_id: u8 + packet_spawn_experience_orb: !id: 0x42 !bound: client @@ -1374,7 +1444,7 @@ packet_update_trade: window_id: u8 # WindowType is an identifier specifying the type of the window opened. In vanilla, it appears this is # always filled out with 15. - window_type: u8 + window_type: WindowType # Size is the amount of trading options that the villager has. size: varint # TradeTier is the tier of the villager that the player is trading with. The tier starts at 0 with a @@ -1412,7 +1482,7 @@ packet_update_equipment: window_id: u8 # WindowType is the type of the window that was opened. Generally, this is the type of a horse inventory, # as the packet is specifically made for that. - window_type: u8 + window_type: WindowType # Size is the size of the horse inventory that should be opened. A bigger size does, in fact, change the # amount of slots displayed. size: u8 diff --git a/data/new/types.yaml b/data/new/types.yaml index 8f6b109..b3418ff 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -673,3 +673,142 @@ CommandOrigin: if dev_console or test: player_entity_id: zigzag64 + +WindowType: u8 => + 0: container + 1: workbench + 2: furnace + 3: enchantment + 4: brewing_stand + 5: anvil + 6: dispenser + 7: dropper + 8: hopper + 9: cauldron + 10: minecart_chest + 11: minecart_hopper + 12: horse + 13: beacon + 14: structure_editor + 15: trading + 16: command_block + 17: jukebox + 18: armor + 19: hand + 20: compound_creator + 21: element_constructor + 22: material_reducer + 23: lab_table + 24: loom + 25: lectern + 26: grindstone + 27: blast_furnace + 28: smoker + 29: stonecutter + 30: cartography + 31: hud + 32: jigsaw_editor + 33: smithing_table + +# TODO: remove? +LegacyEntityType: li32 => + 10: chicken + 11: cow + 12: pig + 13: sheep + 14: wolf + 15: villager + 16: mooshroom + 17: squid + 18: rabbit + 19: bat + 20: iron_golem + 21: snow_golem + 22: ocelot + 23: horse + 24: donkey + 25: mule + 26: skeleton_horse + 27: zombie_horse + 28: polar_bear + 29: llama + 30: parrot + 31: dolphin + 32: zombie + 33: creeper + 34: skeleton + 35: spider + 36: zombie_pigman + 37: slime + 38: enderman + 39: silverfish + 40: cave_spider + 41: ghast + 42: magma_cube + 43: blaze + 44: zombie_villager + 45: witch + 46: stray + 47: husk + 48: wither_skeleton + 49: guardian + 50: elder_guardian + 51: npc + 52: wither + 53: ender_dragon + 54: shulker + 55: endermite + 56: agent # LEARN_TO_CODE_MASCOT + 57: vindicator + 58: phantom + 61: armor_stand + 62: tripod_camera + 63: player + 64: item + 65: tnt + 66: falling_block + 67: moving_block + 68: xp_bottle + 69: xp_orb + 70: eye_of_ender_signal + 71: ender_crystal + 72: fireworks_rocket + 73: thrown_trident + 74: turtle + 75: cat + 76: shulker_bullet + 77: fishing_hook + 78: chalkboard + 79: dragon_fireball + 80: arrow + 81: snowball + 82: egg + 83: painting + 84: minecart + 85: fireball + 86: splash_potion + 87: ender_pearl + 88: leash_knot + 89: wither_skull + 90: boat + 91: wither_skull_dangerous + 93: lightning_bolt + 94: small_fireball + 95: area_effect_cloud + 96: hopper_minecart + 97: tnt_minecart + 98: chest_minecart + 100: command_block_minecart + 101: lingering_potion + 102: llama_spit + 103: evocation_fang + 104: evocation_illager + 105: vex + 106: ice_bomb + 107: balloon + 108: pufferfish + 109: salmon + 110: drowned + 111: tropicalfish + 112: cod + 113: panda \ No newline at end of file diff --git a/data/newproto.json b/data/newproto.json index 9779bac..3a31156 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -2371,6 +2371,156 @@ } ] ], + "WindowType": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "container", + "1": "workbench", + "2": "furnace", + "3": "enchantment", + "4": "brewing_stand", + "5": "anvil", + "6": "dispenser", + "7": "dropper", + "8": "hopper", + "9": "cauldron", + "10": "minecart_chest", + "11": "minecart_hopper", + "12": "horse", + "13": "beacon", + "14": "structure_editor", + "15": "trading", + "16": "command_block", + "17": "jukebox", + "18": "armor", + "19": "hand", + "20": "compound_creator", + "21": "element_constructor", + "22": "material_reducer", + "23": "lab_table", + "24": "loom", + "25": "lectern", + "26": "grindstone", + "27": "blast_furnace", + "28": "smoker", + "29": "stonecutter", + "30": "cartography", + "31": "hud", + "32": "jigsaw_editor", + "33": "smithing_table" + } + } + ], + "LegacyEntityType": [ + "mapper", + { + "type": "li32", + "mappings": { + "10": "chicken", + "11": "cow", + "12": "pig", + "13": "sheep", + "14": "wolf", + "15": "villager", + "16": "mooshroom", + "17": "squid", + "18": "rabbit", + "19": "bat", + "20": "iron_golem", + "21": "snow_golem", + "22": "ocelot", + "23": "horse", + "24": "donkey", + "25": "mule", + "26": "skeleton_horse", + "27": "zombie_horse", + "28": "polar_bear", + "29": "llama", + "30": "parrot", + "31": "dolphin", + "32": "zombie", + "33": "creeper", + "34": "skeleton", + "35": "spider", + "36": "zombie_pigman", + "37": "slime", + "38": "enderman", + "39": "silverfish", + "40": "cave_spider", + "41": "ghast", + "42": "magma_cube", + "43": "blaze", + "44": "zombie_villager", + "45": "witch", + "46": "stray", + "47": "husk", + "48": "wither_skeleton", + "49": "guardian", + "50": "elder_guardian", + "51": "npc", + "52": "wither", + "53": "ender_dragon", + "54": "shulker", + "55": "endermite", + "56": "agent", + "57": "vindicator", + "58": "phantom", + "61": "armor_stand", + "62": "tripod_camera", + "63": "player", + "64": "item", + "65": "tnt", + "66": "falling_block", + "67": "moving_block", + "68": "xp_bottle", + "69": "xp_orb", + "70": "eye_of_ender_signal", + "71": "ender_crystal", + "72": "fireworks_rocket", + "73": "thrown_trident", + "74": "turtle", + "75": "cat", + "76": "shulker_bullet", + "77": "fishing_hook", + "78": "chalkboard", + "79": "dragon_fireball", + "80": "arrow", + "81": "snowball", + "82": "egg", + "83": "painting", + "84": "minecart", + "85": "fireball", + "86": "splash_potion", + "87": "ender_pearl", + "88": "leash_knot", + "89": "wither_skull", + "90": "boat", + "91": "wither_skull_dangerous", + "93": "lightning_bolt", + "94": "small_fireball", + "95": "area_effect_cloud", + "96": "hopper_minecart", + "97": "tnt_minecart", + "98": "chest_minecart", + "100": "command_block_minecart", + "101": "lingering_potion", + "102": "llama_spit", + "103": "evocation_fang", + "104": "evocation_illager", + "105": "vex", + "106": "ice_bomb", + "107": "balloon", + "108": "pufferfish", + "109": "salmon", + "110": "drowned", + "111": "tropicalfish", + "112": "cod", + "113": "panda" + } + } + ], "mcpe_packet": [ "container", [ @@ -2443,6 +2593,7 @@ "62": "set_player_game_type", "63": "player_list", "64": "simple_event", + "65": "event", "66": "spawn_experience_orb", "67": "clientbound_map_item_data", "68": "map_info_request", @@ -2593,6 +2744,7 @@ "set_player_game_type": "packet_set_player_game_type", "player_list": "packet_player_list", "simple_event": "packet_simple_event", + "event": "packet_event", "spawn_experience_orb": "packet_spawn_experience_orb", "clientbound_map_item_data": "packet_clientbound_map_item_data", "map_info_request": "packet_map_info_request", @@ -3534,20 +3686,12 @@ "container", [ { - "name": "runtime_entity_id", + "name": "runtime_id", "type": "varint" }, { - "name": "x", - "type": "lf32" - }, - { - "name": "y", - "type": "lf32" - }, - { - "name": "z", - "type": "lf32" + "name": "position", + "type": "vec3f" }, { "name": "pitch", @@ -3563,15 +3707,67 @@ }, { "name": "mode", - "type": "u8" + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "normal", + "1": "reset", + "2": "teleport", + "3": "rotation" + } + } + ] }, { "name": "on_ground", "type": "bool" }, { - "name": "other_runtime_entity_id", + "name": "ridden_runtime_id", "type": "varint" + }, + { + "anon": true, + "type": [ + "switch", + { + "compareTo": "mode", + "fields": { + "teleport": [ + "container", + [ + { + "name": "teleport_cause", + "type": [ + "mapper", + { + "type": "li32", + "mappings": { + "0": "unknown", + "1": "projectile", + "2": "chorus_fruit", + "3": "command", + "4": "behavior" + } + } + ] + }, + { + "name": "source_entity_type", + "type": "LegacyEntityType" + } + ] + ] + }, + "default": "void" + } + ] + }, + { + "name": "tick", + "type": "varint64" } ] ], @@ -4572,6 +4768,48 @@ } ] ], + "packet_event": [ + "container", + [ + { + "name": "runtime_id", + "type": "varint64" + }, + { + "name": "event_type", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "achievement_awarded", + "1": "entity_interact", + "2": "portal_built", + "3": "portal_used", + "4": "mob_killed", + "5": "cauldron_used", + "6": "player_death", + "7": "boss_killed", + "8": "agent_command", + "9": "agent_created", + "10": "pattern_removed", + "11": "commaned_executed", + "12": "fish_bucketed", + "13": "mob_born", + "14": "pet_died", + "15": "cauldron_block_used", + "16": "composter_block_used", + "17": "bell_block_used" + } + } + ] + }, + { + "name": "use_player_id", + "type": "u8" + } + ] + ], "packet_spawn_experience_orb": [ "container", [ @@ -5115,7 +5353,7 @@ }, { "name": "window_type", - "type": "u8" + "type": "WindowType" }, { "name": "size", @@ -5160,7 +5398,7 @@ }, { "name": "window_type", - "type": "u8" + "type": "WindowType" }, { "name": "size", diff --git a/package.json b/package.json index 90a49d6..6f9b891 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Parse and serialize Minecraft Bedrock Edition packets", "main": "index.js", "scripts": { + "build": "cd data/new && node compile.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ diff --git a/src/serverTest.js b/src/serverTest.js index 6d01f96..ed6883a 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -54,6 +54,7 @@ server.on('connect', ({ client }) => { client.queue('player_list', require('./packets/player_list.json')) client.queue('start_game', require('./packets/start_game.json')) client.queue('item_component', {"entries":[]}) + client.queue('set_spawn_position', require('./packets/set_spawn_position.json')) client.queue('set_time', { time: 5433771 }) client.queue('set_difficulty', { difficulty: 1 }) client.queue('set_commands_enabled', { enabled: true }) @@ -64,24 +65,28 @@ server.on('connect', ({ client }) => { client.queue('update_attributes', require('./packets/update_attributes.json')) client.queue('creative_content', require('./packets/creative_content.json')) + client.queue('inventory_content', require('./packets/inventory_content.json')) client.queue('player_hotbar', {"selected_slot":3,"window_id":0,"select_slot":true}) client.queue('crafting_data', require('./packets/crafting_data.json')) client.queue('available_commands', require('./packets/available_commands.json')) + client.queue('chunk_radius_update', {"chunk_radius":5}) + + client.queue('set_entity_data', require('./packets/set_entity_data.json')) client.queue('game_rules_changed', require('./packets/game_rules_changed.json')) client.queue('respawn', {"x":646.9405517578125,"y":65.62001037597656,"z":77.86255645751953,"state":0,"runtime_entity_id":0}) - // for (const file of fs.readdirSync('chunks')) { - // const buffer = Buffer.from(fs.readFileSync('./chunks/' + file, 'utf8'), 'hex') - // // console.log('Sending chunk', chunk) - // client.sendBuffer(buffer) - // } - - for (const chunk of chunks) { - client.queue('level_chunk', chunk) + for (const file of fs.readdirSync('chunks')) { + const buffer = Buffer.from(fs.readFileSync('./chunks/' + file, 'utf8'), 'hex') + // console.log('Sending chunk', chunk) + client.sendBuffer(buffer) } + // for (const chunk of chunks) { + // client.queue('level_chunk', chunk) + // } + setInterval(() => { client.write('network_chunk_publisher_update', {"coordinates":{"x":646,"y":130,"z":77},"radius":64}) }, 9500) @@ -90,6 +95,14 @@ server.on('connect', ({ client }) => { setTimeout(() => { client.write('play_status', { status: 'player_spawn' }) }, 8000) + + // Respond to tick synchronization packets + client.on('tick_sync', ({ request_time }) => { + client.queue('tick_sync', { + request_time, + response_time: BigInt(Date.now()) + }) + }) }) }) }) @@ -101,7 +114,7 @@ async function sleep(ms) { } // CHUNKS -const { ChunkColumn, Version } = require('bedrock-provider') +// const { ChunkColumn, Version } = require('bedrock-provider') const mcData = require('minecraft-data')('1.16') var chunks = [] async function buildChunks() { @@ -133,4 +146,4 @@ async function buildChunks() { // console.log('Chunks',chunks) } -buildChunks() \ No newline at end of file +// buildChunks() \ No newline at end of file From 863d51c56adf1508f9ca1df8fa1955ebb283da74 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 25 Feb 2021 22:18:25 -0500 Subject: [PATCH 102/106] Protocol updates, new packets --- data/new/packet_map.yml | 22 ++ data/new/proto.yml | 315 ++++++++++++++++++++++++-- data/new/types.yaml | 10 + data/newproto.json | 474 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 784 insertions(+), 37 deletions(-) diff --git a/data/new/packet_map.yml b/data/new/packet_map.yml index ff3e7f0..45d1f33 100644 --- a/data/new/packet_map.yml +++ b/data/new/packet_map.yml @@ -124,6 +124,8 @@ mcpe_packet: 0x7c: level_event_generic 0x7d: lectern_update 0x7e: video_stream_connect + 0x7f: add_ecs_entity + 0x80: remove_ecs_entity 0x81: client_cache_status 0x82: on_screen_texture_animation 0x83: map_create_locked_copy @@ -132,12 +134,21 @@ mcpe_packet: 0x86: update_block_properties 0x87: client_cache_blob_status 0x88: client_cache_miss_response + 0x89: education_settings + 0x8b: multiplayer_settings + 0x8c: settings_command + 0x8d: anvil_damage + 0x8e: completed_using_item 0x8f: network_settings + 0x90: player_auth_input 0x91: creative_content 0x92: player_enchant_options 0x93: item_stack_request 0x94: item_stack_response + 0x95: player_armor_damage 0x97: update_player_game_type + 0x9a: position_tracking_db_request + 0x99: position_tracking_db_broadcast 0x9c: packet_violation_warning 0xa2: item_component 0xa3: filter_text_packet @@ -266,6 +277,8 @@ mcpe_packet: if level_event_generic: packet_level_event_generic if lectern_update: packet_lectern_update if video_stream_connect: packet_video_stream_connect + if add_ecs_entity: packet_add_ecs_entity + if remove_ecs_entity: packet_remove_ecs_entity if client_cache_status: packet_client_cache_status if on_screen_texture_animation: packet_on_screen_texture_animation if map_create_locked_copy: packet_map_create_locked_copy @@ -274,12 +287,21 @@ mcpe_packet: if update_block_properties: packet_update_block_properties if client_cache_blob_status: packet_client_cache_blob_status if client_cache_miss_response: packet_client_cache_miss_response + if education_settings: packet_education_settings + if multiplayer_settings: packet_multiplayer_settings + if settings_command: packet_settings_command + if anvil_damage: packet_anvil_damage + if completed_using_item: packet_completed_using_item if network_settings: packet_network_settings + if player_auth_input: packet_player_auth_input if creative_content: packet_creative_content if player_enchant_options: packet_player_enchant_options if item_stack_request: packet_item_stack_request if item_stack_response: packet_item_stack_response + if player_armor_damage: packet_player_armor_damage if update_player_game_type: packet_update_player_game_type + if position_tracking_db_request: packet_position_tracking_db_request + if position_tracking_db_broadcast: packet_position_tracking_db_broadcast if packet_violation_warning: packet_packet_violation_warning if item_component: packet_item_component if filter_text_packet: packet_filter_text_packet diff --git a/data/new/proto.yml b/data/new/proto.yml index 526273f..c2c5c1f 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -41,6 +41,7 @@ nbt: native packet_login: !id: 0x01 !bound: server + # Protocol version (Big Endian!) protocol_version: i32 # The combined size of the `chain` and `client_data` payload_size: varint @@ -205,13 +206,7 @@ packet_start_game: # creative spectator. # This field may be set to 5 to make the client fall back to the game mode set in the WorldGameMode # field. - player_gamemode: zigzag32 => - 0: survival - 1: creative - 2: adventure - 3: survival_spectator - 4: creative_spectator - 5: fallback + player_gamemode: GameMode # The spawn position of the player in the world. In servers this is often the same as the # world's spawn position found below. spawn: vec3f @@ -229,9 +224,9 @@ packet_start_game: # 4 being end worlds. A value of 0 will actually make the client stop rendering chunks you # send beyond the world limit. generator: zigzag32 - # The game mode that a player gets when it first spawns in the world. It is shown in the + # The world game mode that a player gets when it first spawns in the world. It is shown in the # settings and is used if the Player Gamemode is set to 5. - gamemode: zigzag32 + world_gamemode: GameMode # Difficulty is the difficulty of the world. It is a value from 0-3, with 0 being peaceful, # 1 being easy, 2 being normal and 3 being hard. difficulty: zigzag32 @@ -1065,10 +1060,14 @@ packet_change_dimension: position: vec3f respawn: bool +# SetPlayerGameType is sent by the server to update the game type (game mode) of the player packet_set_player_game_type: !id: 0x3e !bound: both - gamemode: zigzag32 + # The new gamemode for the player. + # Some of these game types require additional flags to be set in an AdventureSettings packet for + # the game mode to obtain its full functionality. + gamemode: GameMode packet_player_list: !id: 0x3f @@ -1658,10 +1657,15 @@ packet_show_profile: !bound: client xuid: string +# SetDefaultGameType is sent by the client when it toggles the default game type in the settings UI, and is +# sent by the server when it actually changes the default game type, resulting in the toggle being changed +# in the settings UI. packet_set_default_game_type: !id: 0x69 !bound: client - gamemode: varint + # GameType is the new game type that is set. When sent by the client, this is the requested new default + # game type. + gamemode: GameMode packet_remove_objective: !id: 0x6a @@ -1834,6 +1838,27 @@ packet_video_stream_connect: resolution_x: li32 resolution_y: li32 +# This is NOT a Minecraft entity, but an entity in the Entity Component System (ECS) +# for the game engine Minecrat Bedrock uses. Internally, all 'Minecraft entities' are +# known as Actors including in packet names and fields. However, these are irrelevant +# internal details so we don't do the renames in these protocol definitions, for simplicity we just use Entity. +# +# AddEntity is sent by the server to the client. Its function is not entirely clear: It does not add an +# entity in the sense of an in-game entity, but has to do with the ECS that Minecraft uses. +packet_add_ecs_entity: + !id: 0x7f + !bound: client + # EntityNetworkID is the network ID of the entity that should be added. + network_id: varint64 + +# RemoveEntity is sent by the server to the client. Its function is not entirely clear: It does not remove an +# entity in the sense of an in-game entity, but has to do with the ECS that Minecraft uses +packet_remove_ecs_entity: + !id: 0x80 + !bound: client + # EntityNetworkID is the network ID of the entity that should be removed. + network_id: varint64 + packet_client_cache_status: !id: 0x81 !bound: both @@ -1879,6 +1904,88 @@ packet_client_cache_miss_response: !bound: client blobs: Blob[]varint +# EducationSettings is a packet sent by the server to update Minecraft: Education Edition related settings. +# It is unused by the normal base game. +packet_education_settings: + !id: 0x89 + !bound: client + # CodeBuilderDefaultURI is the default URI that the code builder is ran on. Using this, a Code Builder + # program can make code directly affect the server. + CodeBuilderDefaultURI: string + # CodeBuilderTitle is the title of the code builder shown when connected to the CodeBuilderDefaultURI. + CodeBuilderTitle: string + # CanResizeCodeBuilder specifies if clients connected to the world should be able to resize the code + # builder when it is opened. + CanResizeCodeBuilder: bool + HasOverrideURI: bool + OverrideURI: HasOverrideURI? + if true: string + # HasQuiz specifies if the world has a quiz connected to it. + HasQuiz: bool + +# MultiPlayerSettings is sent by the client to update multi-player related settings server-side and sent back +# to online players by the server. +# The MultiPlayerSettings packet is a Minecraft: Education Edition packet. It has no functionality for the +# base game. +packet_multiplayer_settings: + !id: 0x8b + !bound: server + # ActionType is the action that should be done when this packet is sent. It is one of the constants that + # may be found above. + action_type: zigzag32 => + 0: enable_multiplayer + 1: disable_multiplayer + 2: refresh_join_code + +# SettingsCommand is sent by the client when it changes a setting in the settings that results in the issuing +# of a command to the server, such as when Show Coordinates is enabled. +packet_settings_command: + !id: 0x8c + !bound: server + # CommandLine is the full command line that was sent to the server as a result of the setting that the + # client changed. + command_line: string + # SuppressOutput specifies if the client requests the suppressing of the output of the command that was + # executed. Generally this is set to true, as the client won't need a message to confirm the output of + # the change. + suppress_output: bool + +# AnvilDamage is sent by the client to request the dealing damage to an anvil. This packet is completely +# pointless and the server should never listen to it. +packet_anvil_damage: + !id: 0x8d + !bound: server + # Damage is the damage that the client requests to be dealt to the anvil. + damage: u8 + # AnvilPosition is the position in the world that the anvil can be found at. + position: BlockCoordinates + +# CompletedUsingItem is sent by the server to tell the client that it should be done using the item it is +# currently using. +packet_completed_using_item: + !id: 0x8e + !bound: client + # UsedItemID is the item ID of the item that the client completed using. This should typically be the + # ID of the item held in the hand. + used_item_id: li16 + # UseMethod is the method of the using of the item that was completed. It is one of the constants that + # may be found above. + use_method: li32 => + 0: equip_armor + 1: eat + 2: attack + 3: consume + 4: throw + 5: shoot + 6: place + 7: fill_bottle + 8: fill_bucket + 9: pour_bucket + 10: use_tool + 11: interact + 12: retrieved + 13: dyed + 14: traded # NetworkSettings is sent by the server to update a variety of network settings. These settings modify the # way packets are sent over the network stack. @@ -1890,6 +1997,90 @@ packet_network_settings: # When set to 0, all packets will be left uncompressed. compression_threshold: u16 + +# PlayerAuthInput is sent by the client to allow for server authoritative movement. It is used to synchronise +# the player input with the position server-side. +# The client sends this packet when the ServerAuthoritativeMovementMode field in the StartGame packet is set +# to true, instead of the MovePlayer packet. The client will send this packet once every tick. +packet_player_auth_input: + !id: 0x90 + !bound: server + # Pitch that the player reports it has. + pitch: lf32 + # Yaw that player reports it has. + yaw: lf32 + # Position holds the position that the player reports it has. + position: vec3f + # MoveVector is a Vec2 that specifies the direction in which the player moved, as a combination of X/Z + # values which are created using the WASD/controller stick state. + move_vector: vec2f + # HeadYaw is the horizontal rotation of the head that the player reports it has. + head_yaw: lf32 + # InputData is a combination of bit flags that together specify the way the player moved last tick. It + # is a combination of the flags above. + input_data: InputFlag + # InputMode specifies the way that the client inputs data to the screen. It is one of the constants that + # may be found above. + input_mode: varint => + 0: mouse + 1: touch + 2: game_pad + 3: motion_controller + # PlayMode specifies the way that the player is playing. The values it holds, which are rather random, + # may be found above. + play_mode: varint => + 0: normal + 1: teaser + 2: screen + 3: viewer + 4: reality + 5: placement + 6: living_room + 7: exit_level + 8: exit_level_living_room + 9: num_modes + # GazeDirection is the direction in which the player is gazing, when the PlayMode is PlayModeReality: In + # other words, when the player is playing in virtual reality. + gaze_direction: play_mode ? + if reality: vec3f + # Tick is the server tick at which the packet was sent. It is used in relation to + # CorrectPlayerMovePrediction. + tick: varint64 + # Delta was the delta between the old and the new position. There isn't any practical use for this field + # as it can be calculated by the server itself. + delta: vec3f + +InputFlag: [ "bitflags", { + "type": "varint64", + "flags": { + "ascend": 0b1, + "descend": 0b10, + "north_jump": 0b100, + "jump_down": 0b1000, + "sprint_down": 0b10000, + "change_height": 0b100000, + "jumping": 0b1000000, + "auto_jumping_in_water": 0b10000000, + "sneaking": 0b100000000, + "sneak_down": 0b1000000000, + "up": 0b10000000000, + "down": 0b100000000000, + "left": 0b1000000000000, + "right": 0b10000000000000, + "up_left": 0b100000000000000, + "up_right": 0b1000000000000000, + "want_up": 0b10000000000000000, + "want_down": 0b100000000000000000, + "want_down_slow": 0b1000000000000000000, + "want_up_slow": 0b10000000000000000000, + "sprinting": 0b100000000000000000000, + "ascend_scaffolding": 0b1000000000000000000000, + "descend_scaffolding": 0b10000000000000000000000, + "sneak_toggle_down": 0b100000000000000000000000, + "persist_sneak": 0b1000000000000000000000000, + } +}] + packet_creative_content: !id: 0x91 !bound: client @@ -1910,25 +2101,123 @@ packet_item_stack_response: !bound: client responses: ItemStackResponses +# PlayerArmourDamage is sent by the server to damage the armour of a player. It is a very efficient packet, +# but generally it's much easier to just send a slot update for the damaged armour. +packet_player_armor_damage: + !id: 0x95 + !bound: client + # Bitset holds a bitset of 4 bits that indicate which pieces of armour need to have damage dealt to them. + # The first bit, when toggled, is for a helmet, the second for the chestplate, the third for the leggings + # and the fourth for boots. + type: ArmorDamageType + helmet_damage: type.head ? + if true: zigzag32 + chestplate_damage: type.chest ? + if true: zigzag32 + leggings_damage: type.legs ? + if true: zigzag32 + boots_damage: types.feet ? + if true: zigzag32 + +ArmorDamageType: [ "bitflags", + { + "type": "u8", + "flags": { + "head": 0b1, + "chest": 0b10, + "legs": 0b100, + "feet": 0b1000 + } + } +] + +# UpdatePlayerGameType is sent by the server to change the game mode of a player. It is functionally +# identical to the SetPlayerGameType packet. packet_update_player_game_type: !id: 0x97 !bound: server + # GameType is the new game type of the player. It is one of the constants that can be found in + # set_player_game_type.go. Some of these game types require additional flags to be set in an + # AdventureSettings packet for the game mode to obtain its full functionality. + gamemode: GameMode + # PlayerUniqueID is the entity unique ID of the player that should have its game mode updated. If this + # packet is sent to other clients with the player unique ID of another player, nothing happens. + player_unique_id: zigzag64 + +# PositionTrackingDBClientRequest is a packet sent by the client to request the position and dimension of a +# 'tracking ID'. These IDs are tracked in a database by the server. In 1.16, this is used for lodestones. +# The client will send this request to find the position a lodestone compass needs to point to. If found, it +# will point to the lodestone. If not, it will start spinning around. +# A PositionTrackingDBServerBroadcast packet should be sent in response to this packet. +packet_position_tracking_db_request: + !id: 0x9a + !bound: server + # RequestAction is the action that should be performed upon the receiving of the packet. It is one of the + # constants found above. + action: u8 => + 0: query + # TrackingID is a unique ID used to identify the request. The server responds with a + # PositionTrackingDBServerBroadcast packet holding the same ID, so that the client can find out what that + # packet was in response to. + tracking_id: zigzag32 + +# PositionTrackingDBServerBroadcast is sent by the server in response to the +# PositionTrackingDBClientRequest packet. This packet is, as of 1.16, currently only used for lodestones. The +# server maintains a database with tracking IDs and their position and dimension. The client will request +# these tracking IDs, (NBT tag set on the lodestone compass with the tracking ID?) and the server will +# respond with the status of those tracking IDs. +# What is actually done with the data sent depends on what the client chooses to do with it. For the +# lodestone compass, it is used to make the compass point towards lodestones and to make it spin if the +# lodestone at a position is no longer there. +packet_position_tracking_db_broadcast: + !id: 0x99 + !bound: client + # BroadcastAction specifies the status of the position tracking DB response. It is one of the constants + # above, specifying the result of the request with the ID below. + # The Update action is sent for setting the position of a lodestone compass, the Destroy and NotFound to + # indicate that there is not (no longer) a lodestone at that position. + broadcast_action: u8 => + 0: update + 1: destory + 2: not_found + # TrackingID is the ID of the PositionTrackingDBClientRequest packet that this packet was in response to. + # The tracking ID is also present as the 'id' field in the SerialisedData field. + tracking_id: zigzag32 + nbt: nbt + +# PacketViolationWarning is sent by the client when it receives an invalid packet from the server. It holds +# some information on the error that occurred. packet_packet_violation_warning: !id: 0x9c !bound: server - violation_type: zigzag32 - severity: zigzag32 + violation_type: zigzag32 => + 0: malformed + # Severity specifies the severity of the packet violation. The action the client takes after this + # violation depends on the severity sent. + severity: zigzag32 => + 0: warning + 1: final_warning + 2: terminating + # PacketID is the ID of the invalid packet that was received. packet_id: zigzag32 + # ViolationContext holds a description on the violation of the packet. reason: string +# ItemComponent is sent by the server to attach client-side components to a custom item. packet_item_component: !id: 0xa2 !bound: client + # `entries` holds a list of all custom items with their respective components set. entries: ItemComponentList +# FilterText is sent by the both the client and the server. The client sends the packet to the server to +# allow the server to filter the text server-side. The server then responds with the same packet and the +# safer version of the text. packet_filter_text_packet: !id: 0xa3 !bound: client + # Text is either the text from the client or the safer version of the text sent by the server. text: string + # FromServer indicates if the packet was sent by the server or not. from_server: bool diff --git a/data/new/types.yaml b/data/new/types.yaml index b3418ff..9be85ae 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -35,6 +35,14 @@ Experiment: Experiments: Experiment[]li32 +GameMode: zigzag32 => + 0: survival + 1: creative + 2: adventure + 3: survival_spectator + 4: creative_spectator + 5: fallback + GameRule: name: string type: varint => @@ -638,7 +646,9 @@ ItemStackResponses: []varint custom_name: string ItemComponentList: []varint + # Name is the name of the item, which is a name like 'minecraft:stick'. name: string + # Data is a map containing the components and properties of the item. nbt: nbt CommandOrigin: diff --git a/data/newproto.json b/data/newproto.json index 3a31156..38f4bfd 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -141,6 +141,20 @@ "type": "Experiment" } ], + "GameMode": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "survival", + "1": "creative", + "2": "adventure", + "3": "survival_spectator", + "4": "creative_spectator", + "5": "fallback" + } + } + ], "GameRule": [ "container", [ @@ -2654,6 +2668,8 @@ "124": "level_event_generic", "125": "lectern_update", "126": "video_stream_connect", + "127": "add_ecs_entity", + "128": "remove_ecs_entity", "129": "client_cache_status", "130": "on_screen_texture_animation", "131": "map_create_locked_copy", @@ -2662,12 +2678,21 @@ "134": "update_block_properties", "135": "client_cache_blob_status", "136": "client_cache_miss_response", + "137": "education_settings", + "139": "multiplayer_settings", + "140": "settings_command", + "141": "anvil_damage", + "142": "completed_using_item", "143": "network_settings", + "144": "player_auth_input", "145": "creative_content", "146": "player_enchant_options", "147": "item_stack_request", "148": "item_stack_response", + "149": "player_armor_damage", "151": "update_player_game_type", + "153": "position_tracking_db_broadcast", + "154": "position_tracking_db_request", "156": "packet_violation_warning", "162": "item_component", "163": "filter_text_packet" @@ -2805,6 +2830,8 @@ "level_event_generic": "packet_level_event_generic", "lectern_update": "packet_lectern_update", "video_stream_connect": "packet_video_stream_connect", + "add_ecs_entity": "packet_add_ecs_entity", + "remove_ecs_entity": "packet_remove_ecs_entity", "client_cache_status": "packet_client_cache_status", "on_screen_texture_animation": "packet_on_screen_texture_animation", "map_create_locked_copy": "packet_map_create_locked_copy", @@ -2813,12 +2840,21 @@ "update_block_properties": "packet_update_block_properties", "client_cache_blob_status": "packet_client_cache_blob_status", "client_cache_miss_response": "packet_client_cache_miss_response", + "education_settings": "packet_education_settings", + "multiplayer_settings": "packet_multiplayer_settings", + "settings_command": "packet_settings_command", + "anvil_damage": "packet_anvil_damage", + "completed_using_item": "packet_completed_using_item", "network_settings": "packet_network_settings", + "player_auth_input": "packet_player_auth_input", "creative_content": "packet_creative_content", "player_enchant_options": "packet_player_enchant_options", "item_stack_request": "packet_item_stack_request", "item_stack_response": "packet_item_stack_response", + "player_armor_damage": "packet_player_armor_damage", "update_player_game_type": "packet_update_player_game_type", + "position_tracking_db_request": "packet_position_tracking_db_request", + "position_tracking_db_broadcast": "packet_position_tracking_db_broadcast", "packet_violation_warning": "packet_packet_violation_warning", "item_component": "packet_item_component", "filter_text_packet": "packet_filter_text_packet" @@ -3177,20 +3213,7 @@ }, { "name": "player_gamemode", - "type": [ - "mapper", - { - "type": "zigzag32", - "mappings": { - "0": "survival", - "1": "creative", - "2": "adventure", - "3": "survival_spectator", - "4": "creative_spectator", - "5": "fallback" - } - } - ] + "type": "GameMode" }, { "name": "spawn", @@ -3221,8 +3244,8 @@ "type": "zigzag32" }, { - "name": "gamemode", - "type": "zigzag32" + "name": "world_gamemode", + "type": "GameMode" }, { "name": "difficulty", @@ -3729,7 +3752,7 @@ "type": "varint" }, { - "anon": true, + "name": "teleport", "type": [ "switch", { @@ -3739,7 +3762,7 @@ "container", [ { - "name": "teleport_cause", + "name": "cause", "type": [ "mapper", { @@ -4746,7 +4769,7 @@ [ { "name": "gamemode", - "type": "zigzag32" + "type": "GameMode" } ] ], @@ -4792,7 +4815,7 @@ "7": "boss_killed", "8": "agent_command", "9": "agent_created", - "10": "pattern_removed", + "10": "banner_pattern_removed", "11": "commaned_executed", "12": "fish_bucketed", "13": "mob_born", @@ -5835,7 +5858,7 @@ [ { "name": "gamemode", - "type": "varint" + "type": "GameMode" } ] ], @@ -6218,6 +6241,24 @@ } ] ], + "packet_add_ecs_entity": [ + "container", + [ + { + "name": "network_id", + "type": "varint64" + } + ] + ], + "packet_remove_ecs_entity": [ + "container", + [ + { + "name": "network_id", + "type": "varint64" + } + ] + ], "packet_client_cache_status": [ "container", [ @@ -6292,6 +6333,124 @@ } ] ], + "packet_education_settings": [ + "container", + [ + { + "name": "CodeBuilderDefaultURI", + "type": "string" + }, + { + "name": "CodeBuilderTitle", + "type": "string" + }, + { + "name": "CanResizeCodeBuilder", + "type": "bool" + }, + { + "name": "HasOverrideURI", + "type": "bool" + }, + { + "name": "OverrideURI", + "type": [ + "switch", + { + "compareTo": "HasOverrideURI", + "fields": { + "true": "string" + }, + "default": "void" + } + ] + }, + { + "name": "HasQuiz", + "type": "bool" + } + ] + ], + "packet_multiplayer_settings": [ + "container", + [ + { + "name": "action_type", + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "enable_multiplayer", + "1": "disable_multiplayer", + "2": "refresh_join_code" + } + } + ] + } + ] + ], + "packet_settings_command": [ + "container", + [ + { + "name": "command_line", + "type": "string" + }, + { + "name": "suppress_output", + "type": "bool" + } + ] + ], + "packet_anvil_damage": [ + "container", + [ + { + "name": "damage", + "type": "u8" + }, + { + "name": "position", + "type": "BlockCoordinates" + } + ] + ], + "packet_completed_using_item": [ + "container", + [ + { + "name": "used_item_id", + "type": "li16" + }, + { + "name": "use_method", + "type": [ + "mapper", + { + "type": "li32", + "mappings": { + "0": "equip_armor", + "1": "eat", + "2": "attack", + "3": "consume", + "4": "throw", + "5": "shoot", + "6": "place", + "7": "fill_bottle", + "8": "fill_bucket", + "9": "pour_bucket", + "10": "use_tool", + "11": "interact", + "12": "retrieved", + "13": "dyed", + "14": "traded" + } + } + ] + } + ] + ], "packet_network_settings": [ "container", [ @@ -6301,6 +6460,92 @@ } ] ], + "packet_player_auth_input": [ + "container", + [ + { + "name": "pitch", + "type": "lf32" + }, + { + "name": "yaw", + "type": "lf32" + }, + { + "name": "position", + "type": "vec3f" + }, + { + "name": "move_vector", + "type": "vec2f" + }, + { + "name": "head_yaw", + "type": "lf32" + }, + { + "name": "input_data", + "type": "InputFlag" + }, + { + "name": "input_mode", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "mouse", + "1": "touch", + "2": "game_pad", + "3": "motion_controller" + } + } + ] + }, + { + "name": "play_mode", + "type": [ + "mapper", + { + "type": "varint", + "mappings": { + "0": "normal", + "1": "teaser", + "2": "screen", + "3": "viewer", + "4": "reality", + "5": "placement", + "6": "living_room", + "7": "exit_level", + "8": "exit_level_living_room", + "9": "num_modes" + } + } + ] + }, + { + "name": "gaze_direction", + "type": [ + "switch", + { + "compareTo": "play_mode", + "fields": { + "reality": "vec3f" + }, + "default": "void" + } + ] + }, + { + "name": "tick", + "type": "varint64" + }, + { + "name": "delta", + "type": "vec3f" + } + ] + ], "packet_creative_content": [ "container", [ @@ -6337,20 +6582,156 @@ } ] ], + "packet_player_armor_damage": [ + "container", + [ + { + "name": "type", + "type": "ArmorDamageType" + }, + { + "name": "helmet_damage", + "type": [ + "switch", + { + "compareTo": "type.head", + "fields": { + "true": "zigzag32" + }, + "default": "void" + } + ] + }, + { + "name": "chestplate_damage", + "type": [ + "switch", + { + "compareTo": "type.chest", + "fields": { + "true": "zigzag32" + }, + "default": "void" + } + ] + }, + { + "name": "leggings_damage", + "type": [ + "switch", + { + "compareTo": "type.legs", + "fields": { + "true": "zigzag32" + }, + "default": "void" + } + ] + }, + { + "name": "boots_damage", + "type": [ + "switch", + { + "compareTo": "types.feet", + "fields": { + "true": "zigzag32" + }, + "default": "void" + } + ] + } + ] + ], "packet_update_player_game_type": [ "container", - [] + [ + { + "name": "gamemode", + "type": "GameMode" + }, + { + "name": "player_unique_id", + "type": "zigzag64" + } + ] + ], + "packet_position_tracking_db_request": [ + "container", + [ + { + "name": "action", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "query" + } + } + ] + }, + { + "name": "tracking_id", + "type": "zigzag32" + } + ] + ], + "packet_position_tracking_db_broadcast": [ + "container", + [ + { + "name": "broadcast_action", + "type": [ + "mapper", + { + "type": "u8", + "mappings": { + "0": "update", + "1": "destory", + "2": "not_found" + } + } + ] + }, + { + "name": "tracking_id", + "type": "zigzag32" + }, + { + "name": "nbt", + "type": "nbt" + } + ] ], "packet_packet_violation_warning": [ "container", [ { "name": "violation_type", - "type": "zigzag32" + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "malformed" + } + } + ] }, { "name": "severity", - "type": "zigzag32" + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "warning", + "1": "final_warning", + "2": "terminating" + } + } + ] }, { "name": "packet_id", @@ -6469,6 +6850,51 @@ "force_move": 256 } } + ], + "InputFlag": [ + "bitflags", + { + "type": "varint64", + "flags": { + "ascend": 1, + "descend": 2, + "north_jump": 4, + "jump_down": 8, + "sprint_down": 16, + "change_height": 32, + "jumping": 64, + "auto_jumping_in_water": 128, + "sneaking": 256, + "sneak_down": 512, + "up": 1024, + "down": 2048, + "left": 4096, + "right": 8192, + "up_left": 16384, + "up_right": 32768, + "want_up": 65536, + "want_down": 131072, + "want_down_slow": 262144, + "want_up_slow": 524288, + "sprinting": 1048576, + "ascend_scaffolding": 2097152, + "descend_scaffolding": 4194304, + "sneak_toggle_down": 8388608, + "persist_sneak": 16777216 + } + } + ], + "ArmorDamageType": [ + "bitflags", + { + "type": "u8", + "flags": { + "head": 1, + "chest": 2, + "legs": 4, + "feet": 8 + } + } ] } } \ No newline at end of file From f00357eca60fcd4ad26a3f04bf7a6d35c0474164 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 5 Mar 2021 02:13:40 -0500 Subject: [PATCH 103/106] Logging updates --- src/ConnWorker.js | 3 ++- src/auth/encryption.js | 1 + src/client.js | 26 ++++++++++++++++++-------- src/clientTest.js | 4 ++-- src/connection.js | 28 ++++++++++++++++++---------- src/server.js | 10 +++++++--- src/serverPlayer.js | 11 ++++++++--- src/serverTest.js | 2 +- 8 files changed, 57 insertions(+), 28 deletions(-) diff --git a/src/ConnWorker.js b/src/ConnWorker.js index 996ed56..e43aea5 100644 --- a/src/ConnWorker.js +++ b/src/ConnWorker.js @@ -1,6 +1,7 @@ const RakClient = require('jsp-raknet/client') const { Worker, isMainThread, parentPort } = require('worker_threads') const EncapsulatedPacket = require('jsp-raknet/protocol/encapsulated_packet') +const Reliability = require('jsp-raknet/protocol/reliability') function connect(hostname, port) { if (isMainThread) { @@ -49,7 +50,7 @@ function main() { console.log('SEND' , globalThis.raknetConnection, evt.packet) const sendPacket = new EncapsulatedPacket() - sendPacket.reliability = 0 + sendPacket.reliability = Reliability.ReliableOrdered sendPacket.buffer = evt.packet globalThis.raknetConnection?.addEncapsulatedToQueue(sendPacket) diff --git a/src/auth/encryption.js b/src/auth/encryption.js index 375fc27..d758f41 100644 --- a/src/auth/encryption.js +++ b/src/auth/encryption.js @@ -80,6 +80,7 @@ function Encrypt(client, server, options) { // It works! First encrypted packet :) client.write('client_to_server_handshake', {}) + this.emit('join') } client.on('server.client_handshake', startClientboundEncryption) diff --git a/src/client.js b/src/client.js index 6ceca76..6ed2816 100644 --- a/src/client.js +++ b/src/client.js @@ -8,13 +8,16 @@ const Options = require('./options') const debug = require('debug')('minecraft-protocol') const fs = require('fs') -const log = console.log const useWorkers = true class Client extends Connection { + /** + * + * @param {{ version: number, hostname: string, port: number }} options + */ constructor(options) { super() - this.options = { ...Options.defaultOptions, options } + this.options = { ...Options.defaultOptions, ...options } this.serializer = createSerializer() this.deserializer = createDeserializer() this.validateOptions() @@ -29,10 +32,14 @@ class Client extends Connection { this.on('session', this.connect) this.startQueue() + this.inLog = (...args) => console.info('C ->', ...args) + this.outLog = (...args) => console.info('C <-', ...args) // this.on('decrypted', this.onDecryptedPacket) } validateOptions() { + // console.log('Options', this.options) + if (!this.options.hostname || this.options.port == null) throw Error('Invalid hostname/port') if (this.options.version < Options.MIN_VERSION) { throw new Error(`Unsupported protocol version < ${Options.MIN_VERSION} : ${this.options.version}`) } @@ -45,8 +52,10 @@ class Client extends Connection { } connect = async (sessionData) => { + const hostname = this.options.hostname || '127.0.0.1' + const port = this.options.port || 19132 if (useWorkers) { - this.worker = ConnWorker.connect('127.0.0.1', 19132) + this.worker = ConnWorker.connect(hostname, port) this.worker.on('message', (evt) => { switch (evt.type) { case 'connected': @@ -103,6 +112,7 @@ class Client extends Connection { chain: encodedChain, client_data: this.clientUserChain }) + this.emit('loggingIn') } onDisconnectRequest(packet) { @@ -112,11 +122,11 @@ class Client extends Connection { process.exit(1) } + close() { + console.warn('Close not implemented!!') + } + tryRencode(name, params, actual) { - if (name == 'level_chunk') { - console.log("Skipping chunk validation, it's broken right now") - return - } const packet = this.serializer.createPacketBuffer({ name, params }) console.assert(packet.toString('hex') == actual.toString('hex')) @@ -138,7 +148,7 @@ class Client extends Connection { // console.log('packet', packet) const des = this.deserializer.parsePacketBuffer(packet) const pakData = { name: des.data.name, params: des.data.params } - console.log('->', pakData.name, serialize(pakData.params).slice(0, 100)) + this.inLog('-> C', pakData.name, serialize(pakData.params).slice(0, 100)) // No idea what this exotic 0xA0 packet is, it's not implemented anywhere // and seems empty. Possible gibberish from the raknet impl diff --git a/src/clientTest.js b/src/clientTest.js index 75a621d..4e0e620 100644 --- a/src/clientTest.js +++ b/src/clientTest.js @@ -1,4 +1,4 @@ -// process.env.DEBUG = 'minecraft-protocol raknet' +process.env.DEBUG = 'minecraft-protocol raknet' const { Client } = require('./client') const fs = require('fs') // console.log = () => @@ -6,7 +6,7 @@ const fs = require('fs') async function test() { const client = new Client({ hostname: '127.0.0.1', - port: 19132 + port: 19130 }) client.once('resource_packs_info', (packet) => { diff --git a/src/connection.js b/src/connection.js index 44f3891..3795b0e 100644 --- a/src/connection.js +++ b/src/connection.js @@ -3,19 +3,24 @@ const BatchPacket = require('./datatypes/BatchPacket') const cipher = require('./transforms/encryption') const { EventEmitter } = require('events') const EncapsulatedPacket = require('jsp-raknet/protocol/encapsulated_packet') +const Reliability = require('jsp-raknet/protocol/reliability') + const debug = require('debug')('minecraft-protocol') class Connection extends EventEmitter { startEncryption(iv) { this.encryptionEnabled = true - console.log('Started encryption', this.sharedSecret, iv) + this.inLog('Started encryption', this.sharedSecret, iv) this.decrypt = cipher.createDecryptor(this, iv) this.encrypt = cipher.createEncryptor(this, iv) + this.q2 = [] } write(name, params) { // TODO: Batch - console.log('Need to encode', name, params) - // console.log('<-', name) + // console.log('Need to encode', name, params) + var s = this.connect ? 'C' : 'S' + if (this.downQ) s += 'P' + this.outLog('<- ' + s, name) const batch = new BatchPacket() const packet = this.serializer.createPacketBuffer({ name, params }) // console.log('Sending buf', packet.toString('hex').) @@ -29,9 +34,10 @@ class Connection extends EventEmitter { } queue(name, params) { - console.log('<- ', name) + this.outLog('Q <- ', name) const packet = this.serializer.createPacketBuffer({ name, params }) this.q.push(packet) + this.q2.push(name) } startQueue() { @@ -40,9 +46,10 @@ class Connection extends EventEmitter { if (this.q.length) { //TODO: can we just build Batch before the queue loop? const batch = new BatchPacket() + this.outLog('<- BATCH', this.q2) // For now, we're over conservative so send max 3 packets // per batch and hold the rest for the next tick - for (let i = 0; i < 3 && i < this.q.length; i++) { + for (let i = 0; /*i < 10 &&*/ i < this.q.length; i++) { const packet = this.q.shift() batch.addEncodedPacket(packet) } @@ -51,6 +58,7 @@ class Connection extends EventEmitter { } else { this.sendDecryptedBatch(batch) } + this.q2 = [] } }, 100) } @@ -105,11 +113,11 @@ class Connection extends EventEmitter { // TODO: Rename this to sendEncapsulated sendMCPE(buffer, immediate) { if (this.worker) { - console.log('-> buf', buffer) + this.outLog('-> buf', buffer) this.worker.postMessage({ type: 'queueEncapsulated', packet: buffer, immediate }) } else { const sendPacket = new EncapsulatedPacket() - sendPacket.reliability = 0 + sendPacket.reliability = Reliability.ReliableOrdered sendPacket.buffer = buffer this.connection.addEncapsulatedToQueue(sendPacket) if (immediate) this.connection.sendQueue() @@ -118,10 +126,10 @@ class Connection extends EventEmitter { // These are callbacks called from encryption.js onEncryptedPacket = (buf) => { - console.log('ENC BUF', buf) + this.outLog('ENC BUF', buf) const packet = Buffer.concat([Buffer.from([0xfe]), buf]) // add header - console.log('Sending wrapped encrypted batch', packet) + this.outLog('Sending wrapped encrypted batch', packet) this.sendMCPE(packet) } @@ -145,7 +153,7 @@ class Connection extends EventEmitter { const batch = new BatchPacket(stream) batch.decode() const packets = batch.getPackets() - console.log('Reading ', packets.length, 'packets') + this.inLog('Reading ', packets.length, 'packets') for (var packet of packets) { this.readPacket(packet) } diff --git a/src/server.js b/src/server.js index f94b573..0ad023a 100644 --- a/src/server.js +++ b/src/server.js @@ -9,11 +9,14 @@ const debug = require('debug')('minecraft-protocol') class Server extends EventEmitter { constructor(options) { super() - this.options = { ...Options.defaultOptions, options } + this.options = { ...Options.defaultOptions, ...options } this.serializer = createSerializer() this.deserializer = createDeserializer() this.clients = {} + this.clientCount = 0 this.validateOptions() + this.inLog = (...args) => console.debug('S', ...args) + this.outLog = (...args) => console.debug('S', ...args) } validateOptions() { @@ -26,13 +29,14 @@ class Server extends EventEmitter { debug('new connection', conn) const player = new Player(this, conn) this.clients[hash(conn.address)] = player - + this.clientCount++ this.emit('connect', { client: player }) } onCloseConnection = (inetAddr, reason) => { debug('close connection', inetAddr, reason) delete this.clients[hash(inetAddr)] + this.clientCount-- } onEncapsulated = (encapsulated, inetAddr) => { @@ -45,7 +49,7 @@ class Server extends EventEmitter { client.handle(buffer) } - async create(serverIp, port) { + async create(serverIp = this.options.hostname, port = this.options.port) { this.listener = new Listener(this) this.raknet = await this.listener.listen(serverIp, port) console.debug('Listening on', serverIp, port) diff --git a/src/serverPlayer.js b/src/serverPlayer.js index 86d10bc..20c66ee 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -11,15 +11,20 @@ const ClientStatus = { } class Player extends Connection { - constructor(server, connection, options) { + constructor(server, connection) { super() this.server = server this.serializer = server.serializer + this.deserializer = server.deserializer + // console.log('serializer/des',this.serializer,this.deserializer) this.connection = connection - Encrypt(this, server, options) + this.options = server.options + Encrypt(this, server, this.options) this.startQueue() this.status = ClientStatus.Authenticating + this.inLog = (...args) => console.info('S ->', ...args) + this.outLog = (...args) => console.info('S <-', ...args) } getData() { @@ -103,7 +108,7 @@ class Player extends Connection { throw e } - console.log('->', des) + console.log('-> S', des) switch (des.data.name) { case 'login': console.log(des) diff --git a/src/serverTest.js b/src/serverTest.js index ed6883a..975e00e 100644 --- a/src/serverTest.js +++ b/src/serverTest.js @@ -1,4 +1,4 @@ -// process.env.DEBUG = 'minecraft-protocol raknet' +process.env.DEBUG = 'minecraft-protocol raknet' const { Server } = require('./server') const CreativeItems = require('../data/creativeitems.json') const NBT = require('prismarine-nbt') From 86dcbc1f493acdb67e9316215a4445bbb130532f Mon Sep 17 00:00:00 2001 From: extremeheat Date: Mon, 8 Mar 2021 02:36:25 -0500 Subject: [PATCH 104/106] use raknet-native with js fallback --- package.json | 1 + {src => samples}/clientTest.js | 4 +- {src => samples}/serverTest.js | 34 +++--- src/client.js | 54 ++------- src/connection.js | 22 ++-- src/datatypes/promises.js | 12 ++ src/index.js | 7 -- src/rak.js | 179 ++++++++++++++++++++++++++++ src/{ConnWorker.js => rakWorker.js} | 1 - src/server.js | 37 +++--- src/texture | Bin 16384 -> 0 bytes src/transforms/encryption.js | 49 +++----- 12 files changed, 262 insertions(+), 138 deletions(-) rename {src => samples}/clientTest.js (95%) rename {src => samples}/serverTest.js (71%) create mode 100644 src/datatypes/promises.js delete mode 100644 src/index.js create mode 100644 src/rak.js rename src/{ConnWorker.js => rakWorker.js} (98%) delete mode 100644 src/texture diff --git a/package.json b/package.json index 6f9b891..b5647f9 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "minecraft-folder-path": "^1.1.0", "prismarine-nbt": "github:extremeheat/prismarine-nbt#le", "protodef": "github:extremeheat/node-protodef#compiler", + "raknet-native": "^0.0.4", "uuid-1345": "^0.99.7" }, "devDependencies": { diff --git a/src/clientTest.js b/samples/clientTest.js similarity index 95% rename from src/clientTest.js rename to samples/clientTest.js index 4e0e620..11b9b3a 100644 --- a/src/clientTest.js +++ b/samples/clientTest.js @@ -1,12 +1,12 @@ process.env.DEBUG = 'minecraft-protocol raknet' -const { Client } = require('./client') +const { Client } = require('../src/client') const fs = require('fs') // console.log = () => async function test() { const client = new Client({ hostname: '127.0.0.1', - port: 19130 + port: 19132 }) client.once('resource_packs_info', (packet) => { diff --git a/src/serverTest.js b/samples/serverTest.js similarity index 71% rename from src/serverTest.js rename to samples/serverTest.js index 975e00e..ac50b53 100644 --- a/src/serverTest.js +++ b/samples/serverTest.js @@ -1,5 +1,5 @@ process.env.DEBUG = 'minecraft-protocol raknet' -const { Server } = require('./server') +const { Server } = require('../src/server') const CreativeItems = require('../data/creativeitems.json') const NBT = require('prismarine-nbt') const fs = require('fs') @@ -50,35 +50,35 @@ server.on('connect', ({ client }) => { client.queue('inventory_slot', {"inventory_id":120,"slot":i,"uniqueid":0,"item":{"network_id":0}}) } - client.queue('inventory_transaction', require('./packets/inventory_transaction.json')) - client.queue('player_list', require('./packets/player_list.json')) - client.queue('start_game', require('./packets/start_game.json')) + client.queue('inventory_transaction', require('../src/packets/inventory_transaction.json')) + client.queue('player_list', require('../src/packets/player_list.json')) + client.queue('start_game', require('../src/packets/start_game.json')) client.queue('item_component', {"entries":[]}) - client.queue('set_spawn_position', require('./packets/set_spawn_position.json')) + client.queue('set_spawn_position', require('../src/packets/set_spawn_position.json')) client.queue('set_time', { time: 5433771 }) client.queue('set_difficulty', { difficulty: 1 }) client.queue('set_commands_enabled', { enabled: true }) - client.queue('adventure_settings', require('./packets/adventure_settings.json')) + client.queue('adventure_settings', require('../src/packets/adventure_settings.json')) - client.queue('biome_definition_list', require('./packets/biome_definition_list.json')) - client.queue('available_entity_identifiers', require('./packets/available_entity_identifiers.json')) + client.queue('biome_definition_list', require('../src/packets/biome_definition_list.json')) + client.queue('available_entity_identifiers', require('../src/packets/available_entity_identifiers.json')) - client.queue('update_attributes', require('./packets/update_attributes.json')) - client.queue('creative_content', require('./packets/creative_content.json')) - client.queue('inventory_content', require('./packets/inventory_content.json')) + client.queue('update_attributes', require('../src/packets/update_attributes.json')) + client.queue('creative_content', require('../src/packets/creative_content.json')) + client.queue('inventory_content', require('../src/packets/inventory_content.json')) client.queue('player_hotbar', {"selected_slot":3,"window_id":0,"select_slot":true}) - client.queue('crafting_data', require('./packets/crafting_data.json')) - client.queue('available_commands', require('./packets/available_commands.json')) + client.queue('crafting_data', require('../src/packets/crafting_data.json')) + client.queue('available_commands', require('../src/packets/available_commands.json')) client.queue('chunk_radius_update', {"chunk_radius":5}) - client.queue('set_entity_data', require('./packets/set_entity_data.json')) + client.queue('set_entity_data', require('../src/packets/set_entity_data.json')) - client.queue('game_rules_changed', require('./packets/game_rules_changed.json')) + client.queue('game_rules_changed', require('../src/packets/game_rules_changed.json')) client.queue('respawn', {"x":646.9405517578125,"y":65.62001037597656,"z":77.86255645751953,"state":0,"runtime_entity_id":0}) - for (const file of fs.readdirSync('chunks')) { - const buffer = Buffer.from(fs.readFileSync('./chunks/' + file, 'utf8'), 'hex') + for (const file of fs.readdirSync('../src/chunks')) { + const buffer = Buffer.from(fs.readFileSync('../src/chunks/' + file, 'utf8'), 'hex') // console.log('Sending chunk', chunk) client.sendBuffer(buffer) } diff --git a/src/client.js b/src/client.js index 6ed2816..24d0b96 100644 --- a/src/client.js +++ b/src/client.js @@ -1,20 +1,14 @@ -const RakClient = require('jsp-raknet/client') +const fs = require('fs') +const debug = require('debug')('minecraft-protocol') const { Connection } = require('./connection') const { createDeserializer, createSerializer } = require('./transforms/serializer') -const ConnWorker = require('./ConnWorker') const { Encrypt } = require('./auth/encryption') const auth = require('./client/auth') const Options = require('./options') -const debug = require('debug')('minecraft-protocol') -const fs = require('fs') - -const useWorkers = true +const { RakClient } = require('./Rak') class Client extends Connection { - /** - * - * @param {{ version: number, hostname: string, port: number }} options - */ + /** @param {{ version: number, hostname: string, port: number }} options */ constructor(options) { super() this.options = { ...Options.defaultOptions, ...options } @@ -54,41 +48,11 @@ class Client extends Connection { connect = async (sessionData) => { const hostname = this.options.hostname || '127.0.0.1' const port = this.options.port || 19132 - if (useWorkers) { - this.worker = ConnWorker.connect(hostname, port) - this.worker.on('message', (evt) => { - switch (evt.type) { - case 'connected': - this.sendLogin() - break - case 'encapsulated': - this.onEncapsulated(...evt.args) - break - } - }) - - } else { - if (this.raknet) return - - this.raknet = new RakClient('127.0.0.1', 19132) - await this.raknet.connect() - - this.raknet.on('connecting', () => { - // console.log(`[client] connecting to ${hostname}/${port}`) - }) - this.raknet.on('connected', (connection) => { - console.log(`[client] connected!`) - this.connection = connection - this.sendLogin() - }) - - this.raknet.on('encapsulated', this.onEncapsulated) - - this.raknet.on('raw', (buffer, inetAddr) => { - console.log('Raw packet', buffer, inetAddr) - }) - } + this.connection = new RakClient({ useWorkers: true, hostname, port }) + this.connection.onConnected = () => this.sendLogin() + this.connection.onEncapsulated = this.onEncapsulated + this.connection.connect() } sendLogin() { @@ -100,7 +64,7 @@ class Client extends Connection { ] const encodedChain = JSON.stringify({ chain }) - const skinChain = JSON.stringify({}) + // const skinChain = JSON.stringify({}) const bodyLength = this.clientUserChain.length + encodedChain.length + 8 diff --git a/src/connection.js b/src/connection.js index 3795b0e..8cd8dad 100644 --- a/src/connection.js +++ b/src/connection.js @@ -2,7 +2,6 @@ const BinaryStream = require('@jsprismarine/jsbinaryutils').default const BatchPacket = require('./datatypes/BatchPacket') const cipher = require('./transforms/encryption') const { EventEmitter } = require('events') -const EncapsulatedPacket = require('jsp-raknet/protocol/encapsulated_packet') const Reliability = require('jsp-raknet/protocol/reliability') const debug = require('debug')('minecraft-protocol') @@ -112,16 +111,17 @@ class Connection extends EventEmitter { // TODO: Rename this to sendEncapsulated sendMCPE(buffer, immediate) { - if (this.worker) { - this.outLog('-> buf', buffer) - this.worker.postMessage({ type: 'queueEncapsulated', packet: buffer, immediate }) - } else { - const sendPacket = new EncapsulatedPacket() - sendPacket.reliability = Reliability.ReliableOrdered - sendPacket.buffer = buffer - this.connection.addEncapsulatedToQueue(sendPacket) - if (immediate) this.connection.sendQueue() - } + this.connection.sendReliable(buffer, immediate) + // if (this.worker) { + // this.outLog('-> buf', buffer) + // this.worker.postMessage({ type: 'queueEncapsulated', packet: buffer, immediate }) + // } else { + // const sendPacket = new EncapsulatedPacket() + // sendPacket.reliability = Reliability.ReliableOrdered + // sendPacket.buffer = buffer + // this.connection.addEncapsulatedToQueue(sendPacket) + // if (immediate) this.connection.sendQueue() + // } } // These are callbacks called from encryption.js diff --git a/src/datatypes/promises.js b/src/datatypes/promises.js new file mode 100644 index 0000000..c3763e1 --- /dev/null +++ b/src/datatypes/promises.js @@ -0,0 +1,12 @@ +module.exports = { + sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) + }, + + waitFor(cb, withTimeout) { + return Promise.race([ + new Promise((res, rej) => cb(res)), + sleep(withTimeout) + ]) + } +} \ No newline at end of file diff --git a/src/index.js b/src/index.js deleted file mode 100644 index b02489a..0000000 --- a/src/index.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - createSerializer: require("./transforms/serializer").createSerializer, - createDeserializer: require("./transforms/serializer").createDeserializer, - createProtocol: require('./transforms/serializer').createProtocol, - createServer: require("./createServer"), - createClient: require("./createClient") -}; diff --git a/src/rak.js b/src/rak.js new file mode 100644 index 0000000..c9a60a6 --- /dev/null +++ b/src/rak.js @@ -0,0 +1,179 @@ +const { EventEmitter } = require('events') +const Listener = require('jsp-raknet/listener') +const EncapsulatedPacket = require('jsp-raknet/protocol/encapsulated_packet') +const RakClient = require('jsp-raknet/client') +const ConnWorker = require('./rakWorker') +try { + var { Client, Server, PacketPriority, PacketReliability, McPingMessage } = require('raknet-native') +} catch (e) { + console.debug('[raknet] native not found, using js', e) +} + +class RakNativeClient extends EventEmitter { + constructor(options) { + super() + this.onConnected = () => {} + this.onCloseConnection = () => {} + this.onEncapsulated = () => {} + + this.raknet = new Client(options.hostname, options.port, 'minecraft') + this.raknet.on('encapsulated', thingy => { + console.log('Encap',thingy) + const { buffer, address, guid }=thingy + this.onEncapsulated(buffer, address) + }) + this.raknet.on('connected', () => { + this.onConnected() + }) + } + + async ping() { + this.raknet.ping() + return waitFor((done) => { + this.raknet.on('pong', (ret) => { + if (ret.extra) { + done(ret.extra.toString()) + } + }) + }, 1000) + } + + connect() { + this.raknet.connect() + } + + sendReliable(buffer, immediate) { + const priority = immediate ? PacketPriority.IMMEDIATE_PRIORITY : PacketPriority.MEDIUM_PRIORITY + return this.raknet.send(buffer, priority, PacketReliability.RELIABLE_ORDERED, 0) + } +} + +class RakNativeServer extends EventEmitter { + constructor(options = {}) { + super() + console.log('opts',options) + this.onOpenConnection = () => {} + this.onCloseConnection = () => {} + this.onEncapsulated = () => {} + this.raknet = new Server(options.hostname, options.port, { + maxConnections: options.maxConnections || 3, + minecraft: { message: new McPingMessage().toString() } + }) + + this.raknet.on('openConnection', (client) => { + client.sendReliable = function(buffer, immediate) { + const priority = immediate ? PacketPriority.IMMEDIATE_PRIORITY : PacketPriority.MEDIUM_PRIORITY + return this.send(buffer, priority, PacketReliability.RELIABLE_ORDERED, 0) + } + this.onOpenConnection(client) + }) + + this.raknet.on('closeConnection', (client) => { + console.log('!!! Client CLOSED CONNECTION!') + this.onCloseConnection(client) + }) + + this.raknet.on('encapsulated', (thingy) => { + const { buffer, address, guid }=thingy + console.log('ENCAP',thingy) + this.onEncapsulated(buffer, address) + }) + } + + listen() { + this.raknet.listen() + } +} + +class RakJsClient extends EventEmitter { + constructor(options = {}) { + super() + this.onConnected = () => {} + this.onEncapsulated = () => {} + if (options.useWorkers) { + this.connect = this.workerConnect + this.sendReliable = this.workerSendReliable + } else { + this.connect = this.plainConnect + this.sendReliable = this.plainSendReliable + } + } + + workerConnect(hostname = this.options.hostname, port = this.options.port) { + this.worker = ConnWorker.connect(hostname, port) + + this.worker.on('message', (evt) => { + switch (evt.type) { + case 'connected': + this.onConnected() + break + case 'encapsulated': + const [ecapsulated, address] = evt.args + this.onEncapsulated(ecapsulated.buffer, address.hash) + break + } + }) + } + + async plainConnect(hostname = this.options.hostname, port = this.options.port) { + this.raknet = new RakClient(hostname, port) + await this.raknet.connect() + + this.raknet.on('connecting', () => { + console.log(`[client] connecting to ${hostname}/${port}`) + }) + + this.raknet.on('connected', this.onConnected) + this.raknet.on('encapsulated', (encapsulated, addr) => this.onEncapsulated(encapsulated.buffer, addr.hash)) + } + + workerSendReliable(buffer, immediate) { + this.worker.postMessage({ type: 'queueEncapsulated', packet: buffer, immediate }) + } + + plainSendReliable(buffer, immediate) { + const sendPacket = new EncapsulatedPacket() + sendPacket.reliability = Reliability.ReliableOrdered + sendPacket.buffer = buffer + this.connection.addEncapsulatedToQueue(sendPacket) + if (immediate) this.connection.sendQueue() + } +} + +class RakJsServer extends EventEmitter { + constructor(options = {}) { + super() + this.options = options + this.onOpenConnection = () => {} + this.onCloseConnection = () => {} + this.onEncapsulated = () => {} + + if (options.useWorkers) { + throw Error('nyi') + } else { + this.listen = this.plainListen + } + } + + async plainListen() { + this.raknet = new Listener() + await this.raknet.listen(this.options.hostname, this.options.port) + this.raknet.on('openConnection', (conn) => { + conn.sendReliable = function(buffer, immediate) { + const sendPacket = new EncapsulatedPacket() + sendPacket.reliability = Reliability.ReliableOrdered + sendPacket.buffer = buffer + this.connection.addEncapsulatedToQueue(sendPacket) + if (immediate) this.raknet.sendQueue() + } + this.onOpenConnection(conn) + }) + this.raknet.on('closeConnection', this.onCloseConnection) + this.raknet.on('encapsulated', this.onEncapsulated) + } +} + +module.exports = { + RakClient: Client ? RakNativeClient : RakJsClient, + RakServer: Server ? RakNativeServer : RakJsServer +} \ No newline at end of file diff --git a/src/ConnWorker.js b/src/rakWorker.js similarity index 98% rename from src/ConnWorker.js rename to src/rakWorker.js index e43aea5..3dc837a 100644 --- a/src/ConnWorker.js +++ b/src/rakWorker.js @@ -16,7 +16,6 @@ var raknet function main() { parentPort.on('message', (evt) => { if (evt.type == 'connect') { - console.warn('-------- ', evt) const { hostname, port } =evt raknet = new RakClient(hostname, port) diff --git a/src/server.js b/src/server.js index 0ad023a..2e3a924 100644 --- a/src/server.js +++ b/src/server.js @@ -1,8 +1,7 @@ -const Listener = require('jsp-raknet/listener') const { EventEmitter } = require('events') const { createDeserializer, createSerializer } = require('./transforms/serializer') const { Player } = require('./serverPlayer') - +const { RakServer } = require('./rak') const Options = require('./options') const debug = require('debug')('minecraft-protocol') @@ -26,41 +25,35 @@ class Server extends EventEmitter { } onOpenConnection = (conn) => { - debug('new connection', conn) + this.inLog('new connection', conn) const player = new Player(this, conn) - this.clients[hash(conn.address)] = player + this.clients[conn.address] = player this.clientCount++ this.emit('connect', { client: player }) } onCloseConnection = (inetAddr, reason) => { debug('close connection', inetAddr, reason) - delete this.clients[hash(inetAddr)] + delete this.clients[inetAddr] this.clientCount-- } - onEncapsulated = (encapsulated, inetAddr) => { - debug(inetAddr.address, 'Encapsulated', encapsulated) - const buffer = encapsulated.buffer - const client = this.clients[hash(inetAddr)] + onEncapsulated = (buffer, address) => { + debug(address, 'Encapsulated', buffer) + const client = this.clients[address] if (!client) { - throw new Error(`packet from unknown inet addr: ${inetAddr.address}/${inetAddr.port}`) + throw new Error(`packet from unknown inet addr: ${address}`) } client.handle(buffer) } - async create(serverIp = this.options.hostname, port = this.options.port) { - this.listener = new Listener(this) - this.raknet = await this.listener.listen(serverIp, port) - console.debug('Listening on', serverIp, port) - - this.raknet.on('openConnection', this.onOpenConnection) - this.raknet.on('closeConnection', this.onCloseConnection) - this.raknet.on('encapsulated', this.onEncapsulated) - - this.raknet.on('raw', (buffer, inetAddr) => { - debug('Raw packet', buffer, inetAddr) - }) + async create(hostname = this.options.hostname, port = this.options.port) { + this.raknet = new RakServer({ hostname, port }) + await this.raknet.listen() + console.debug('Listening on', hostname, port) + this.raknet.onOpenConnection = this.onOpenConnection + this.raknet.onCloseConnection = this.onCloseConnection + this.raknet.onEncapsulated = this.onEncapsulated } } diff --git a/src/texture b/src/texture deleted file mode 100644 index 83c6355c885f2aee7dc4b597942800afa91a8e45..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI2-)~e!6vy{bTR=)QHvA}POI-_Qso(=8TBP#J7>y8(QiBAHAf+K`P!ov(l?c^D zeIkKWOiWCO(eR+?gTY6i`ad1#Gu`j?FzoJK=&rkIZR$VBf2E-{p1u2{;;n3a#4ugMkHLR>_cr_T@Q%#WmM+~-*m#BT zihX!(PhI}O!9nweCTP%j_U?~TV_$dlkS2K5-?P(RD*T?6`eWJ;%Y`4#lwEtGUi}Z1 zhnK|u7dyO9uU`>$;JKgjv)@x&3im(!;?^F((~rT}$h!RrS6y50>4z9Lm zHZ53X(@NViu<#jBUf&x(^T?$Se&sO+otT5T=9Nx7M}3=X_ED$x(K=Z(wsl}tzU9#XTN-O#CB|66LZLA3}dr_sqLD)`W0;FJbCtuKT&wot z#!C}?r|YkMiXUFP!Ui9I*e<^{W^*U@+F1F~$Zp~1(DSo)`~1nsPMaUJA%|SXFqS#| zoSs$phW0~O@rQa1$35F;mky2E)puXCD@S$)wte>7`Q!HI=QG*o+uv8t*pH|8+r{ub zpB!=-vvr^^&Y{|)1B_V8u4h4~>(72=o$T4;6BYaZ^lNtg#7pt-89vv(J30~gcH75$ zp1aGwJ^F%uc6ev}?Bnkp#xRyS;{FeFGPl^_)w98Wf9NznYuEbmb0-hPdVclxE<1Oi zVrTbmwdskG$O`W#uWq+5-q;n5HaX<}aOz+jd;Pta7kpJi=0r!;U!Fcc#J3@xPxnvOe~M*2}s)4{g8Jw9UAb&(B4E8c*kFH$Qt`Otk&)7r*bTmyb^5!ROm4 zA9HHH|Ed0d4{*lSzhcUDdU&>!A02A($Ns8D&D0-8nP;P&%b(t#ti2Jx&li8HRUQ6x zf2aJ?$M1nw@Jkzfs!zk`udlxtJwI(}RmZFT@}5onxQ~;>)RcM4 z_+i0RJJ0U-b;|Gar4fC!!#K~D)*metmydnby^lV5^%s}CXQQot`819`dN$%y{kY~? znLQ5zKY1FXc+AmrAn{Y$QQW0UTMB^G{*Bw2XV)}A2blR z;`hs+w?B$_p+KQPp+KQPp+KQPp+KQPp+KQPp+KQPp+KQPp+Ks@qR&rx2c+}u&|d8M zX1cz1UoV

{Y+)_q}c)@~V55m)swD>uYyhT=FTO`sLHO=Tm+CJ>cU}gC)qX+Qxkz_{1NdbGk3&Tg?A2 DCE}OY diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index 670d8a9..36f7c18 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -72,43 +72,24 @@ function createEncryptor(client, iv) { // A packet is encrypted via AES256(plaintext + SHA256(send_counter + plaintext + secret_key)[0:8]). // The send counter is represented as a little-endian 64-bit long and incremented after each packet. - const addChecksum = new Transform({ // append checksum - transform(chunk, enc, cb) { - // console.log('Encryptor: checking checksum', chunk) - // Here we concat the payload + checksum before the encryption - const packet = Buffer.concat([chunk, computeCheckSum(chunk, client.sendCounter, client.secretKeyBytes)]) - client.sendCounter++ - this.push(packet) - cb() - } - }) + function process(chunk) { + const buffer = Zlib.deflateRawSync(chunk, { level: 7 }) + // client.outLog('🟡 Compressed', buffer, client.sendCounter) + const packet = Buffer.concat([buffer, computeCheckSum(buffer, client.sendCounter, client.secretKeyBytes)]) + client.sendCounter++ + // client.outLog('writing to cipher...', packet, client.secretKeyBytes, iv) + client.cipher.write(packet) + } - // https://stackoverflow.com/q/25971715/11173996 - // TODO: Fix deflate stream - for some reason using .pipe() doesn't work using zlib.createDeflateRaw() - // so we define our own compressor transform - // const compressor = Zlib.createDeflateRaw({ level: 7, chunkSize: 1024 * 1024 * 2, flush: Zlib.Z_SYNC_FLUSH }) - const compressor = new Transform({ - transform(chunk, enc, cb) { - Zlib.deflateRaw(chunk, { level: 7 }, (err, res) => { - if (err) { - console.error(err) - throw new Error(`Failed to deflate stream`) - } - this.push(res) - cb() - }) - } - }) + // const stream = new PassThrough() + client.cipher.on('data', client.onEncryptedPacket) - const stream = new PassThrough() - - stream - .pipe(compressor) - .pipe(addChecksum).pipe(client.cipher).on('data', client.onEncryptedPacket) return (blob) => { - stream.write(blob) + client.outLog(client.options ? 'C':'S', '🟡 Encrypting', blob) + // stream.write(blob) + process(blob) } } @@ -119,7 +100,7 @@ function createDecryptor(client, iv) { function verify(chunk) { // console.log('Decryptor: checking checksum', client.receiveCounter, chunk) - + // client.outLog('🔵 Inflating', chunk) // First try to zlib decompress, then see how much bytes get read const { buffer, engine } = Zlib.inflateRawSync(chunk, { chunkSize: 1024 * 1024 * 2, @@ -158,6 +139,8 @@ function createDecryptor(client, iv) { client.decipher.on('data', verify) return (blob) => { + // client.inLog(client.options ? 'C':'S', ' 🔵 Decrypting', client.receiveCounter, blob) + // client.inLog('Using shared key', client.secretKeyBytes, iv) client.decipher.write(blob) } } From 9e1500ec775501f824098cc4ec46dd19c8dfaee2 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 9 Mar 2021 02:13:47 -0500 Subject: [PATCH 105/106] add new packets and working proxy --- data/new/packet_map.yml | 10 ++ data/new/proto.yml | 82 ++++++++++++++ data/newproto.json | 115 ++++++++++++++++++++ src/client.js | 4 +- src/connection.js | 20 +++- src/rak.js | 3 +- src/relay.js | 202 +++++++++++++++++++++++++++++++++++ src/serverPlayer.js | 1 + src/transforms/encryption.js | 2 +- 9 files changed, 430 insertions(+), 9 deletions(-) create mode 100644 src/relay.js diff --git a/data/new/packet_map.yml b/data/new/packet_map.yml index 45d1f33..3734525 100644 --- a/data/new/packet_map.yml +++ b/data/new/packet_map.yml @@ -150,6 +150,11 @@ mcpe_packet: 0x9a: position_tracking_db_request 0x99: position_tracking_db_broadcast 0x9c: packet_violation_warning + 0x9d: motion_prediction_hints + 0x9e: animate_entity + 0x9f: camera_shake + 0xa0: player_fog + 0xa1: correct_player_move_prediction 0xa2: item_component 0xa3: filter_text_packet @@ -303,5 +308,10 @@ mcpe_packet: if position_tracking_db_request: packet_position_tracking_db_request if position_tracking_db_broadcast: packet_position_tracking_db_broadcast if packet_violation_warning: packet_packet_violation_warning + if motion_prediction_hints: packet_motion_prediction_hints + if animate_entity: packet_animate_entity + if camera_shake: packet_camera_shake + if player_fog: packet_player_fog + if correct_player_move_prediction: packet_correct_player_move_prediction if item_component: packet_item_component if filter_text_packet: packet_filter_text_packet diff --git a/data/new/proto.yml b/data/new/proto.yml index c2c5c1f..0965d3d 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -2204,6 +2204,87 @@ packet_packet_violation_warning: # ViolationContext holds a description on the violation of the packet. reason: string + +# MotionPredictionHints is sent by the server to the client. There is a predictive movement component for +# entities. This packet fills the "history" of that component and entity movement is computed based on the +# points. Vanilla sends this packet instead of the SetActorMotion packet when 'spatial optimisations' are +# enabled. +packet_motion_prediction_hints: + !id: 0x9d + !bound: client + # EntityRuntimeID is the runtime ID of the entity whose velocity is sent to the client. + entity_runtime_id: varint64 + # Velocity is the server-calculated velocity of the entity at the point of sending the packet. + velocity: vec3f + # OnGround specifies if the server currently thinks the entity is on the ground. + on_ground: bool + + +# AnimateEntity is sent by the server to animate an entity client-side. It may be used to play a single +# animation, or to activate a controller which can start a sequence of animations based on different +# conditions specified in an animation controller. +# Much of the documentation of this packet can be found at +# https://minecraft.gamepedia.com/Bedrock_Edition_beta_animation_documentation. +packet_animate_entity: + !id: 0x9e + !bound: client + # Animation is the name of a single animation to start playing. + animation: string + # NextState is the first state to start with. These states are declared in animation controllers (which, + # in themselves, are animations too). These states in turn may have animations and transitions to move to + # a next state. + next_state: string + # StopCondition is a MoLang expression that specifies when the animation should be stopped. + stop_condition: string + # Controller is the animation controller that is used to manage animations. These controllers decide when + # to play which animation. + controller: string + # BlendOutTime does not currently seem to be used. + blend_out_time: lf32 + # EntityRuntimeIDs is list of runtime IDs of entities that the animation should be applied to. + runtime_entity_ids: varint64[]varint + +# CameraShake is sent by the server to make the camera shake client-side. This feature was added for map- +# making partners. +packet_camera_shake: + !id: 0x9f + !bound: client + # Intensity is the intensity of the shaking. The client limits this value to 4, so anything higher may + # not work. + intensity: lf32 + # Duration is the number of seconds the camera will shake for. + duration: lf32 + # Type is the type of shake, and is one of the constants listed above. The different type affects how + # the shake looks in game. + type: u8 + +# PlayerFog is sent by the server to render the different fogs in the Stack. The types of fog are controlled +# by resource packs to change how they are rendered, and the ability to create custom fog. +packet_player_fog: + !id: 0xa0 + !bound: client + # Stack is a list of fog identifiers to be sent to the client. Examples of fog identifiers are + # "minecraft:fog_ocean" and "minecraft:fog_hell". + stack: string[]varint + + +# CorrectPlayerMovePrediction is sent by the server if and only if StartGame.ServerAuthoritativeMovementMode +# is set to AuthoritativeMovementModeServerWithRewind. The packet is used to correct movement at a specific +# point in time. +packet_correct_player_move_prediction: + !id: 0xa1 + !bound: client + # Position is the position that the player is supposed to be at at the tick written in the field below. + # The client will change its current position based on movement after that tick starting from the + # Position. + position: vec3f + # Delta is the change in position compared to what the client sent as its position at that specific tick. + delta: vec3f + # OnGround specifies if the player was on the ground at the time of the tick below. + on_ground: bool + # Tick is the tick of the movement which was corrected by this packet. + tick: varint64 + # ItemComponent is sent by the server to attach client-side components to a custom item. packet_item_component: !id: 0xa2 @@ -2221,3 +2302,4 @@ packet_filter_text_packet: text: string # FromServer indicates if the packet was sent by the server or not. from_server: bool + diff --git a/data/newproto.json b/data/newproto.json index 38f4bfd..bbce33d 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -2694,6 +2694,11 @@ "153": "position_tracking_db_broadcast", "154": "position_tracking_db_request", "156": "packet_violation_warning", + "157": "motion_prediction_hints", + "158": "animate_entity", + "159": "camera_shake", + "160": "player_fog", + "161": "correct_player_move_prediction", "162": "item_component", "163": "filter_text_packet" } @@ -2856,6 +2861,11 @@ "position_tracking_db_request": "packet_position_tracking_db_request", "position_tracking_db_broadcast": "packet_position_tracking_db_broadcast", "packet_violation_warning": "packet_packet_violation_warning", + "motion_prediction_hints": "packet_motion_prediction_hints", + "animate_entity": "packet_animate_entity", + "camera_shake": "packet_camera_shake", + "player_fog": "packet_player_fog", + "correct_player_move_prediction": "packet_correct_player_move_prediction", "item_component": "packet_item_component", "filter_text_packet": "packet_filter_text_packet" }, @@ -6743,6 +6753,111 @@ } ] ], + "packet_motion_prediction_hints": [ + "container", + [ + { + "name": "entity_runtime_id", + "type": "varint64" + }, + { + "name": "velocity", + "type": "vec3f" + }, + { + "name": "on_ground", + "type": "bool" + } + ] + ], + "packet_animate_entity": [ + "container", + [ + { + "name": "animation", + "type": "string" + }, + { + "name": "next_state", + "type": "string" + }, + { + "name": "stop_condition", + "type": "string" + }, + { + "name": "controller", + "type": "string" + }, + { + "name": "blend_out_time", + "type": "lf32" + }, + { + "name": "runtime_entity_ids", + "type": [ + "array", + { + "countType": "varint", + "type": "varint64" + } + ] + } + ] + ], + "packet_camera_shake": [ + "container", + [ + { + "name": "intensity", + "type": "lf32" + }, + { + "name": "duration", + "type": "lf32" + }, + { + "name": "type", + "type": "u8" + } + ] + ], + "packet_player_fog": [ + "container", + [ + { + "name": "stack", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] + } + ] + ], + "packet_correct_player_move_prediction": [ + "container", + [ + { + "name": "position", + "type": "vec3f" + }, + { + "name": "delta", + "type": "vec3f" + }, + { + "name": "on_ground", + "type": "bool" + }, + { + "name": "tick", + "type": "varint64" + } + ] + ], "packet_item_component": [ "container", [ diff --git a/src/client.js b/src/client.js index 24d0b96..9419202 100644 --- a/src/client.js +++ b/src/client.js @@ -112,7 +112,7 @@ class Client extends Connection { // console.log('packet', packet) const des = this.deserializer.parsePacketBuffer(packet) const pakData = { name: des.data.name, params: des.data.params } - this.inLog('-> C', pakData.name, serialize(pakData.params).slice(0, 100)) + this.inLog('-> C', pakData.name/*, serialize(pakData.params).slice(0, 100)*/) // No idea what this exotic 0xA0 packet is, it's not implemented anywhere // and seems empty. Possible gibberish from the raknet impl @@ -149,7 +149,7 @@ class Client extends Connection { fs.writeFileSync('start_game.json', JSON.stringify(des.data.params, (k, v) => typeof v == 'bigint' ? v.toString() : v)) break case 'level_chunk': - fs.writeFileSync(`./chunks/chunk-${chunks++}.txt`, packet.toString('hex')) + // fs.writeFileSync(`./chunks/chunk-${chunks++}.txt`, packet.toString('hex')) break default: // console.log('Sending to listeners') diff --git a/src/connection.js b/src/connection.js index 8cd8dad..e621446 100644 --- a/src/connection.js +++ b/src/connection.js @@ -19,7 +19,7 @@ class Connection extends EventEmitter { // console.log('Need to encode', name, params) var s = this.connect ? 'C' : 'S' if (this.downQ) s += 'P' - this.outLog('<- ' + s, name) + this.outLog('NB <- ' + s, name,params) const batch = new BatchPacket() const packet = this.serializer.createPacketBuffer({ name, params }) // console.log('Sending buf', packet.toString('hex').) @@ -33,8 +33,13 @@ class Connection extends EventEmitter { } queue(name, params) { - this.outLog('Q <- ', name) + this.outLog('Q <- ', name, params) const packet = this.serializer.createPacketBuffer({ name, params }) + if (name == 'level_chunk') { + // Skip queue + this.sendMCPE(packet) + return + } this.q.push(packet) this.q2.push(name) } @@ -48,16 +53,19 @@ class Connection extends EventEmitter { this.outLog('<- BATCH', this.q2) // For now, we're over conservative so send max 3 packets // per batch and hold the rest for the next tick - for (let i = 0; /*i < 10 &&*/ i < this.q.length; i++) { + const sending = [] + for (let i = 0; i < 3 && i < this.q.length; i++) { const packet = this.q.shift() + sending.push(this.q2.shift()) batch.addEncodedPacket(packet) } + // console.warn('~~ Sending', sending) if (this.encryptionEnabled) { this.sendEncryptedBatch(batch) } else { this.sendDecryptedBatch(batch) } - this.q2 = [] + // this.q2 = [] } }, 100) } @@ -162,5 +170,7 @@ class Connection extends EventEmitter { // console.log('[client] handled incoming ', buffer) } } - +function serialize(obj = {}, fmt) { + return JSON.stringify(obj, (k, v) => typeof v == 'bigint' ? v.toString() : v, fmt) +} module.exports = { Connection } \ No newline at end of file diff --git a/src/rak.js b/src/rak.js index c9a60a6..5a16182 100644 --- a/src/rak.js +++ b/src/rak.js @@ -57,7 +57,8 @@ class RakNativeServer extends EventEmitter { this.onEncapsulated = () => {} this.raknet = new Server(options.hostname, options.port, { maxConnections: options.maxConnections || 3, - minecraft: { message: new McPingMessage().toString() } + minecraft: { }, + message: new McPingMessage().toBuffer() }) this.raknet.on('openConnection', (client) => { diff --git a/src/relay.js b/src/relay.js new file mode 100644 index 0000000..6fdc890 --- /dev/null +++ b/src/relay.js @@ -0,0 +1,202 @@ +process.env.DEBUG = 'minecraft-protocol raknet' +const { Client } = require("./client") +const { Server } = require("./server") +const { Player } = require("./serverPlayer") +const debug = require('debug')('minecraft-protocol relay') + +/** @typedef {{ hostname: string, port: number, auth: 'client' | 'server' | null, destination?: { hostname: string, port: number } }} Options */ + +class RelayPlayer extends Player { + constructor(server, conn) { + super(server, conn) + this.server = server + this.conn = conn + + this.startRelaying = false + this.once('join', () => { + this.write('client_cache_status', {enabled:false}) // disable this asap on join + + this.flushDownQueue() + this.startRelaying = true + }) + this.downQ = [] + this.upQ = [] + this.upInLog = (...msg) => console.info('** Backend -> Proxy', ...msg) + this.upOutLog = (...msg) => console.info('** Proxy -> Backend', ...msg) + this.downInLog = (...msg) => console.info('** Client -> Proxy', ...msg) + this.downOutLog = (...msg) => console.info('** Proxy -> Client', ...msg) + + this.outLog = this.downOutLog + this.inLog = this.downInLog + } + + // Called when we get a packet from backend server (Backend -> PROXY -> Client) + readUpstream(packet) { + if (!this.startRelaying) { + console.warn('The downstream client is not ready yet !!') + this.downQ.push(packet) + return + } + this.upInLog('Recv packet', packet) + const des = this.server.deserializer.parsePacketBuffer(packet) + const name = des.data.name + const params = des.data.params + this.upInLog('~~ Bounce B->C', name, serialize(params).slice(0, 100)) + this.upInLog('~~ ', des.buffer) + if (name == 'play_status' && params.status == 'login_success') return + + if (name == 'level_chunk') { //send chunk directly + this.upInLog('Would send chunk', params) + this.sendBuffer(packet) + return + } else this.upInLog('?',name) + + // if (name == 'network_chunk_publisher_update') return + // if (name == 'crafting_data' || name == 'level_chunk') return // Alex breaks + this.queue(name, params) + // this.sendBuffer(packet) + } + + flushDownQueue() { + for (const packet of this.downQ) { + const des = this.server.deserializer.parsePacketBuffer(packet) + this.write(des.data.name, des.data.params) + } + this.downQ = [] + } + + flushUpQueue() { + for (var e of this.upQ) { // Send the queue + const des = this.server.deserializer.parsePacketBuffer(e) + if (des.data.name == 'client_cache_status') { // already disabled on join + // this.upstream.write('client_cache_status', {enabled:false}) + } else { + this.upstream.write(des.data.name, des.data.params) + } + } + this.upQ = [] + } + + // Called when the server gets a packet from the downstream player (Client -> PROXY -> Backend) + readPacket(packet) { + if (this.startRelaying) { // The DS client conn is established & we got a packet to send to US server + if (!this.upstream) { // Upstream is still connecting/handshaking + debug('Got downstream connected packet but upstream is not connected yet, added to q', this.queue.length) + this.upQ.push(packet) // Put into a queue + return + } + this.flushUpQueue() // Send queued packets + this.downInLog('Recv packet', packet) + const des = this.server.deserializer.parsePacketBuffer(packet) + switch (des.data.name) { + case 'client_cache_status': + this.upstream.queue('client_cache_status', {enabled:false}) + break + // case 'request_chunk_radius': + // this.upstream.queue('request_chunk_radius', {chunk_radius: 1}) + // break + default: + // Emit the packet as-is back to the upstream server + this.upstream.queue(des.data.name, des.data.params) + } + } else { + super.readPacket(packet) + } + } +} + +class Relay extends Server { + /** + * Creates a new non-transparent proxy connection to a destination server + * @param {Options} options + */ + constructor(options) { + super(options) + this.RelayPlayer = options.relayPlayer || RelayPlayer + this.forceSingle = true + this.upstreams = new Map() + } + + openUpstreamConnection(ds, clientAddr) { + const client = new Client({ + hostname: this.options.destination.hostname, + port: this.options.destination.port, + encrypt: this.options.encrypt + }) + client.outLog = ds.upOutLog + client.inLog = ds.upInLog + // console.log('Set upstream logs', client.outLog, client.inLog) + client.once('join', () => { // Intercept once handshaking done + ds.upstream = client + ds.flushUpQueue() + console.log('UPSTREAM HAS JOINED') + client.readPacket = (packet) => ds.readUpstream(packet) + }) + this.upstreams.set(clientAddr.hash, client) + } + + closeUpstreamConnection(clientAddr) { + const up = this.upstreams.get(clientAddr.hash) + if (!up) throw Error(`unable to close non-existant connection ${clientAddr.hash}`) + up.close() + this.upstreams.delete(clientAddr.hash) + debug('relay closed connection', clientAddr) + } + + onOpenConnection = (conn) => { + debug('new connection', conn) + if (this.forceSingle && this.clientCount > 0) { + debug('dropping connection as single client relay', conn) + conn.close() + } else { + const player = new this.RelayPlayer(this, conn) + console.log('NEW CONNECTION', conn.address) + this.clients[conn.address] = player + this.emit('connect', { client: player }) + this.openUpstreamConnection(player, conn.address) + } + } +} +console.log = () => {} + + +function serialize(obj = {}, fmt) { + return JSON.stringify(obj, (k, v) => typeof v == 'bigint' ? v.toString() : v, fmt) +} + +function createRelay() { + console.log('Creating relay') + /** + * Example to create a non-transparent proxy (or 'Relay') connection to destination server + * In Relay we de-code and re-encode packets + */ + const relay = new Relay({ + /* Hostname and port for clients to listen to */ + hostname: '0.0.0.0', + port: 19130, + /** + * Who does the authentication + * If set to `client`, all connecting clients will be sent a message with a link to authenticate + * If set to `server`, the server will authenticate and only one client will be able to join + * (Default) If set to `none`, no authentication will be done + */ + auth: 'server', + + /** + * Sets if packets will automatically be forwarded. If set to false, you must listen for on('packet') + * events and + */ + auto: true, + + /* Where to send upstream packets to */ + destination: { + hostname: '127.0.0.1', + port: 19132, + encryption: true + } + }) + + relay.create() +} + +createRelay() \ No newline at end of file diff --git a/src/serverPlayer.js b/src/serverPlayer.js index 20c66ee..8d05c6a 100644 --- a/src/serverPlayer.js +++ b/src/serverPlayer.js @@ -90,6 +90,7 @@ class Player extends Connection { // After sending Server to Client Handshake, this handles the client's // Client to Server handshake response. This indicates successful encryption onHandshake() { + // this.outLog('Sending login success!', this.status) // https://wiki.vg/Bedrock_Protocol#Play_Status this.write('play_status', { status: 'login_success' }) this.status = ClientStatus.Initializing diff --git a/src/transforms/encryption.js b/src/transforms/encryption.js index 36f7c18..dee6469 100644 --- a/src/transforms/encryption.js +++ b/src/transforms/encryption.js @@ -87,7 +87,7 @@ function createEncryptor(client, iv) { return (blob) => { - client.outLog(client.options ? 'C':'S', '🟡 Encrypting', blob) + // client.outLog(client.options ? 'C':'S', '🟡 Encrypting', client.sendCounter, blob) // stream.write(blob) process(blob) } From 667030370e38ff42cfeb8af160ad60c3b7a33207 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Thu, 11 Mar 2021 06:05:04 -0500 Subject: [PATCH 106/106] varint64 impl, inventory and other packet fixes --- data/new/proto.yml | 120 +++++++++++-- data/new/types.yaml | 157 +++++++++++++---- data/newproto.json | 250 ++++++++++++++++++++++------ package.json | 4 +- src/connection.js | 13 +- src/datatypes/compiler-minecraft.js | 66 ++++++-- src/datatypes/varlong.js | 63 +++++++ src/rak.js | 4 +- src/relay.js | 84 ++++++---- test/serialization.js | 39 ++++- 10 files changed, 645 insertions(+), 155 deletions(-) create mode 100644 src/datatypes/varlong.js diff --git a/data/new/proto.yml b/data/new/proto.yml index 0965d3d..0a3bd85 100644 --- a/data/new/proto.yml +++ b/data/new/proto.yml @@ -1,9 +1,9 @@ # Created from MiNET docs string: ["pstring",{"countType":"varint"}] ByteArray: ["buffer",{"countType":"varint"}] +SignedByteArray: ["buffer",{"countType":"zigzag32"}] LittleString: ["pstring",{"countType":"li32"}] varint32: varint -varint64: varint bool: native zigzag32: native zigzag64: native @@ -166,6 +166,7 @@ packet_text: _: type? if chat or whisper or announcement: source_name: string + message: string if raw or tip or system or json_whisper or json: message: string if translation or popup or jukebox_popup: @@ -718,7 +719,7 @@ packet_mob_equipment: item: Item slot: u8 selected_slot: u8 - windows_id: u8 + windows_id: WindowID packet_mob_armor_equipment: !id: 0x20 @@ -865,46 +866,94 @@ packet_respawn: state: u8 runtime_entity_id: varint +# ContainerOpen is sent by the server to open a container client-side. This container must be physically +# present in the world, for the packet to have any effect. Unlike Java Edition, Bedrock Edition requires that +# chests for example must be present and in range to open its inventory. packet_container_open: !id: 0x2e !bound: client + # WindowID is the ID representing the window that is being opened. It may be used later to close the + # container using a ContainerClose packet. window_id: u8 - type: u8 + # ContainerType is the type ID of the container that is being opened when opening the container at the + # position of the packet. It depends on the block/entity, and could, for example, be the window type of + # a chest or a hopper, but also a horse inventory. + window_type: WindowType + # ContainerPosition is the position of the container opened. The position must point to a block entity + # that actually has a container. If that is not the case, the window will not be opened and the packet + # will be ignored, if a valid ContainerEntityUniqueID has not also been provided. coordinates: BlockCoordinates + # ContainerEntityUniqueID is the unique ID of the entity container that was opened. It is only used if + # the ContainerType is one that points to an entity, for example a horse. runtime_entity_id: zigzag64 +# ContainerClose is sent by the server to close a container the player currently has opened, which was opened +# using the ContainerOpen packet, or by the client to tell the server it closed a particular container, such +# as the crafting grid. packet_container_close: !id: 0x2f !bound: both + # WindowID is the ID representing the window of the container that should be closed. It must be equal to + # the one sent in the ContainerOpen packet to close the designated window. window_id: u8 + # ServerSide determines whether or not the container was force-closed by the server. If this value is + # not set correctly, the client may ignore the packet and respond with a PacketViolationWarning. server: bool +# PlayerHotBar is sent by the server to the client. It used to be used to link hot bar slots of the player to +# actual slots in the inventory, but as of 1.2, this was changed and hot bar slots are no longer a free +# floating part of the inventory. +# Since 1.2, the packet has been re-purposed, but its new functionality is not clear. packet_player_hotbar: !id: 0x30 !bound: both selected_slot: varint - window_id: u8 + window_id: WindowID select_slot: bool +# InventoryContent is sent by the server to update the full content of a particular inventory. It is usually +# sent for the main inventory of the player, but also works for other inventories that are currently opened +# by the player. packet_inventory_content: !id: 0x31 !bound: both + # WindowID is the ID that identifies one of the windows that the client currently has opened, or one of + # the consistent windows such as the main inventory. inventory_id: varint + # Content is the new content of the inventory. The length of this slice must be equal to the full size of + # the inventory window updated. input: ItemStacks +# InventorySlot is sent by the server to update a single slot in one of the inventory windows that the client +# currently has opened. Usually this is the main inventory, but it may also be the off hand or, for example, +# a chest inventory. packet_inventory_slot: !id: 0x32 !bound: both - inventory_id: varint + # WindowID is the ID of the window that the packet modifies. It must point to one of the windows that the + # client currently has opened. + window_id: varint + # Slot is the index of the slot that the packet modifies. The new item will be set to the slot at this + # index. slot: varint + # NewItem is the item to be put in the slot at Slot. It will overwrite any item that may currently + # be present in that slot. uniqueid: zigzag32 item: Item +# ContainerSetData is sent by the server to update specific data of a single container, meaning a block such +# as a furnace or a brewing stand. This data is usually used by the client to display certain features +# client-side. packet_container_set_data: !id: 0x33 !bound: client - window_id: u8 + # WindowID is the ID of the window that should have its data set. The player must have a window open with + # the window ID passed, or nothing will happen. + window_id: WindowID + # Key is the key of the property. It is one of the constants that can be found above. Multiple properties + # share the same key, but the functionality depends on the type of the container that the data is set to. property: zigzag32 + # Value is the value of the property. Its use differs per property. value: zigzag32 packet_crafting_data: @@ -915,20 +964,33 @@ packet_crafting_data: potion_container_recipes: PotionContainerChangeRecipes is_clean: bool +# CraftingEvent is sent by the client when it crafts a particular item. Note that this packet may be fully +# ignored, as the InventoryTransaction packet provides all the information required. packet_crafting_event: !id: 0x35 !bound: both - window_id: u8 - recipe_type: zigzag32 + # WindowID is the ID representing the window that the player crafted in. + window_id: WindowID + # CraftingType is a type that indicates the way the crafting was done, for example if a crafting table + # was used. + recipe_type: zigzag32 => + 0: inventory + 1: crafting + 2: workbench + # RecipeUUID is the UUID of the recipe that was crafted. It points to the UUID of the recipe that was + # sent earlier in the CraftingData packet. recipe_id: uuid - input: ItemStacks - result: ItemStacks + # Input is a list of items that the player put into the recipe so that it could create the Output items. + # These items are consumed in the process. + input: Item[]varint + # Output is a list of items that were obtained as a result of crafting the recipe. + result: Item[]varint + packet_gui_data_pick_item: !id: 0x36 !bound: client - # AdventureSettings is sent by the server to update game-play related features, in particular permissions to # access these features for the client. It includes allowing the player to fly, build and mine, and attack # entities. Most of these flags should be checked server-side instead of using this packet only. @@ -1085,7 +1147,7 @@ packet_event: !id: 0x41 !bound: client runtime_id: varint64 - event_type: varint => + event_type: zigzag32 => 0: achievement_awarded 1: entity_interact 2: portal_built @@ -1105,6 +1167,7 @@ packet_event: 16: composter_block_used 17: bell_block_used use_player_id: u8 + event_data: restBuffer # Unknown data, TODO: add packet_spawn_experience_orb: !id: 0x42 @@ -1821,13 +1884,36 @@ packet_level_sound_event: is_baby_mob: bool is_global: bool +# LevelEventGeneric is sent by the server to send a 'generic' level event to the client. This packet sends an +# NBT serialised object and may for that reason be used for any event holding additional data. packet_level_event_generic: !id: 0x7c !bound: client + # EventID is a unique identifier that identifies the event called. The data that follows has fields in + # the NBT depending on what event it is. + event_id: varint + # SerialisedEventData is a network little endian serialised object of event data, with fields that vary + # depending on EventID. + # Unlike many other NBT structures, this data is not actually in a compound but just loosely floating + # NBT tags. To decode using the nbt package, you would need to append 0x0a00 at the start (compound id + # and name length) and add 0x00 at the end, to manually wrap it in a compound. Likewise, you would have + # to remove these bytes when encoding. + nbt: nbtLoop +# LecternUpdate is sent by the client to update the server on which page was opened in a book on a lectern, +# or if the book should be removed from it. packet_lectern_update: !id: 0x7d !bound: client + # Page is the page number in the book that was opened by the player on the lectern. + page: u8 + # PageCount is the number of pages that the book opened in the lectern has. + page_count: u8 + # Position is the position of the lectern that was updated. If no lectern is at the block position, + # the packet should be ignored. + position: vec3i + # DropBook specifies if the book currently set on display in the lectern should be dropped server-side. + drop_book: bool packet_video_stream_connect: !id: 0x7e @@ -1890,11 +1976,15 @@ packet_update_block_properties: packet_client_cache_blob_status: !id: 0x87 !bound: client + # The number of MISSes in this packet + misses: varint + # The number of HITs in this packet + haves: varint # A list of blob hashes that the client does not have a blob available for. The server # should send the blobs matching these hashes as soon as possible. - missing: lu64[]varint + missing: lu64[]$misses # A list of hashes that the client does have a cached blob for. Server doesn't need to send. - have: lu64[]varint + have: lu64[]$haves # ClientCacheMissResponse is part of the blob cache protocol. It is sent by the server in response to a # ClientCacheBlobStatus packet and contains the blob data of all blobs that the client acknowledged not to @@ -2051,7 +2141,7 @@ packet_player_auth_input: delta: vec3f InputFlag: [ "bitflags", { - "type": "varint64", + "type": "varint", "flags": { "ascend": 0b1, "descend": 0b10, diff --git a/data/new/types.yaml b/data/new/types.yaml index 9be85ae..adf7b3b 100644 --- a/data/new/types.yaml +++ b/data/new/types.yaml @@ -64,7 +64,7 @@ Blob: hash: lu64 # Payload is the data of the blob. When sent, the client will associate the Hash of the blob with the # Payload in it. - payload: string + payload: ByteArray BlockPalette: []varint name: string @@ -586,52 +586,121 @@ StackRequestSlotInfo: # ItemStackRequests: []varint + # RequestID is a unique ID for the request. This ID is used by the server to send a response for this + # specific request in the ItemStackResponse packet. request_id: zigzag32 actions: []varint type_id: u8 => - '0': 'TAKE' - '1': 'PLACE' - '2': 'SWAP' - '3': 'DROP' - '4': 'DESTROY' - '5': 'CRAFTING_CONSUME_INPUT' - '6': 'create' - '7': 'LAB_TABLE_COMBINE' - '8': 'BEACON_PAYMENT' - '9': 'CRAFTING_RECIPE' - '10': 'CRAFTING_RECIPE_AUTO' #recipe book? - '11': 'CREATIVE_CREATE' - '12': 'CRAFTING_NON_IMPLEMENTED_DEPRECATED' #anvils aren't fully implemented yet - '13': 'CRAFTING_RESULTS_DEPRECATED' #no idea what this is for + # TakeStackRequestAction is sent by the client to the server to take x amount of items from one slot in a + # container to the cursor. + 0: take + # PlaceStackRequestAction is sent by the client to the server to place x amount of items from one slot into + # another slot, such as when shift clicking an item in the inventory to move it around or when moving an item + # in the cursor into a slot. + 1: place + # SwapStackRequestAction is sent by the client to swap the item in its cursor with an item present in another + # container. The two item stacks swap places. + 2: swap + # DropStackRequestAction is sent by the client when it drops an item out of the inventory when it has its + # inventory opened. This action is not sent when a player drops an item out of the hotbar using the Q button + # (or the equivalent on mobile). The InventoryTransaction packet is still used for that action, regardless of + # whether the item stack network IDs are used or not. + 3: drop + # DestroyStackRequestAction is sent by the client when it destroys an item in creative mode by moving it + # back into the creative inventory. + 4: destroy + # ConsumeStackRequestAction is sent by the client when it uses an item to craft another item. The original + # item is 'consumed'. + 5: consume + # CreateStackRequestAction is sent by the client when an item is created through being used as part of a + # recipe. For example, when milk is used to craft a cake, the buckets are leftover. The buckets are moved to + # the slot sent by the client here. + # Note that before this is sent, an action for consuming all items in the crafting table/grid is sent. Items + # that are not fully consumed when used for a recipe should not be destroyed there, but instead, should be + # turned into their respective resulting items. + 6: create + # LabTableCombineStackRequestAction is sent by the client when it uses a lab table to combine item stacks. + 7: lab_table_combine + # BeaconPaymentStackRequestAction is sent by the client when it submits an item to enable effects from a + # beacon. These items will have been moved into the beacon item slot in advance. + 8: beacon_payment + # CraftRecipeStackRequestAction is sent by the client the moment it begins crafting an item. This is the + # first action sent, before the Consume and Create item stack request actions. + # This action is also sent when an item is enchanted. Enchanting should be treated mostly the same way as + # crafting, where the old item is consumed. + 9: craft_recipe + # AutoCraftRecipeStackRequestAction is sent by the client similarly to the CraftRecipeStackRequestAction. The + # only difference is that the recipe is automatically created and crafted by shift clicking the recipe book. + 10: craft_recipe_auto #recipe book? + # CraftCreativeStackRequestAction is sent by the client when it takes an item out fo the creative inventory. + # The item is thus not really crafted, but instantly created. + 11: craft_creative + # CraftRecipeOptionalStackRequestAction is sent when using an anvil. When this action is sent, the + # CustomNames field in the respective stack request is non-empty and contains the name of the item created + # using the anvil. + 12: optional + # CraftNonImplementedStackRequestAction is an action sent for inventory actions that aren't yet implemented + # in the new system. These include, for example, anvils. + 13: non_implemented #anvils aren't fully implemented yet + # CraftResultsDeprecatedStackRequestAction is an additional, deprecated packet sent by the client after + # crafting. It holds the final results and the amount of times the recipe was crafted. It shouldn't be used. + # This action is also sent when an item is enchanted. Enchanting should be treated mostly the same way as + # crafting, where the old item is consumed. + 14: results_deprecated _: type_id ? - if TAKE or PLACE: + if take or place: count: u8 source: StackRequestSlotInfo destination: StackRequestSlotInfo - if SWAP: + if swap: + # Source and Destination point to the source slot from which Count of the item stack were taken and the + # destination slot to which this item was moved. source: StackRequestSlotInfo destination: StackRequestSlotInfo - if DROP: + if drop: + # Count is the count of the item in the source slot that was taken towards the destination slot. count: u8 + # Source is the source slot from which items were dropped to the ground. source: StackRequestSlotInfo + # Randomly seems to be set to false in most cases. I'm not entirely sure what this does, but this is what + # vanilla calls this field. randomly: bool - if DESTROY or CRAFTING_CONSUME_INPUT: + if destroy or consume: + # Count is the count of the item in the source slot that was destroyed. count: u8 + # Source is the source slot from which items came that were destroyed by moving them into the creative + # inventory. source: StackRequestSlotInfo if create: + # ResultsSlot is the slot in the inventory in which the results of the crafting ingredients are to be + # placed. result_slot_id: u8 - if BEACON_PAYMENT: - primary_effect: varint - secondary_effect: varint - if CRAFTING_RECIPE or CRAFTING_RECIPE_AUTO: - recipe_network_id: varint32 - if CREATIVE_CREATE: + if beacon_payment: + # PrimaryEffect and SecondaryEffect are the effects that were selected from the beacon. + primary_effect: zigzag32 + secondary_effect: zigzag32 + if craft_recipe or craft_recipe_auto: + # RecipeNetworkID is the network ID of the recipe that is about to be crafted. This network ID matches + # one of the recipes sent in the CraftingData packet, where each of the recipes have a RecipeNetworkID as + # of 1.16. + recipe_network_id: varint + if craft_creative: + # CreativeItemNetworkID is the network ID of the creative item that is being created. This is one of the + # creative item network IDs sent in the CreativeContent packet. creative_item_network_id: varint32 - if CRAFTING_NON_IMPLEMENTED_DEPRECATED: void - if CRAFTING_RESULTS_DEPRECATED: - result_items: ItemStacks + if optional: + # For the cartography table, if a certain MULTI recipe is being called, this points to the network ID that was assigned. + recipe_network_id: varint + # Most likely the index in the request's filter strings that this action is using + filtered_string_index: li32 + if non_implemented: void + if results_deprecated: + result_items: Item[]varint times_crafted: u8 - + # CustomNames is a list of custom names involved in the request. This is typically filled with one string + # when an anvil is used. + # * Used for the server to determine which strings should be filtered. Used in anvils to verify a renamed item. + custom_names: string[]varint ItemStackResponses: []varint result: u8 @@ -683,6 +752,36 @@ CommandOrigin: if dev_console or test: player_entity_id: zigzag64 +# Some arbitrary definitions from CBMC, Window IDs are normally +# unique + sequential +WindowID: i8 => + -100: drop_contents + -24: beacon + -23: trading_output + -22: trading_use_inputs + -21: trading_input_2 + -20: trading_input_1 + -17: enchant_output + -16: enchant_material + -15: enchant_input + -13: anvil_output + -12: anvil_result + -11: anvil_material + -10: container_input + -5: crafting_use_ingredient + -4: crafting_result + -3: crafting_remove_ingredient + -2: crafting_add_ingredient + -1: none + 0: inventory + 1: first + 100: last + 119: offhand + 120: armor + 121: creative + 122: hotbar + 123: fixed_inventory + 124: ui WindowType: u8 => 0: container diff --git a/data/newproto.json b/data/newproto.json index bbce33d..4c90341 100644 --- a/data/newproto.json +++ b/data/newproto.json @@ -1,7 +1,6 @@ { "types": { "varint32": "varint", - "varint64": "varint", "bool": "native", "zigzag32": "native", "zigzag64": "native", @@ -209,7 +208,7 @@ }, { "name": "payload", - "type": "string" + "type": "ByteArray" } ] ], @@ -2037,20 +2036,21 @@ { "type": "u8", "mappings": { - "0": "TAKE", - "1": "PLACE", - "2": "SWAP", - "3": "DROP", - "4": "DESTROY", - "5": "CRAFTING_CONSUME_INPUT", + "0": "take", + "1": "place", + "2": "swap", + "3": "drop", + "4": "destroy", + "5": "consume", "6": "create", - "7": "LAB_TABLE_COMBINE", - "8": "BEACON_PAYMENT", - "9": "CRAFTING_RECIPE", - "10": "CRAFTING_RECIPE_AUTO", - "11": "CREATIVE_CREATE", - "12": "CRAFTING_NON_IMPLEMENTED_DEPRECATED", - "13": "CRAFTING_RESULTS_DEPRECATED" + "7": "lab_table_combine", + "8": "beacon_payment", + "9": "craft_recipe", + "10": "craft_recipe_auto", + "11": "craft_creative", + "12": "optional", + "13": "non_implemented", + "14": "results_deprecated" } } ] @@ -2062,7 +2062,7 @@ { "compareTo": "type_id", "fields": { - "TAKE": [ + "take": [ "container", [ { @@ -2079,7 +2079,7 @@ } ] ], - "PLACE": [ + "place": [ "container", [ { @@ -2096,7 +2096,7 @@ } ] ], - "SWAP": [ + "swap": [ "container", [ { @@ -2109,7 +2109,7 @@ } ] ], - "DROP": [ + "drop": [ "container", [ { @@ -2126,7 +2126,7 @@ } ] ], - "DESTROY": [ + "destroy": [ "container", [ { @@ -2139,7 +2139,7 @@ } ] ], - "CRAFTING_CONSUME_INPUT": [ + "consume": [ "container", [ { @@ -2161,38 +2161,38 @@ } ] ], - "BEACON_PAYMENT": [ + "beacon_payment": [ "container", [ { "name": "primary_effect", - "type": "varint" + "type": "zigzag32" }, { "name": "secondary_effect", + "type": "zigzag32" + } + ] + ], + "craft_recipe": [ + "container", + [ + { + "name": "recipe_network_id", "type": "varint" } ] ], - "CRAFTING_RECIPE": [ + "craft_recipe_auto": [ "container", [ { "name": "recipe_network_id", - "type": "varint32" + "type": "varint" } ] ], - "CRAFTING_RECIPE_AUTO": [ - "container", - [ - { - "name": "recipe_network_id", - "type": "varint32" - } - ] - ], - "CREATIVE_CREATE": [ + "craft_creative": [ "container", [ { @@ -2201,13 +2201,32 @@ } ] ], - "CRAFTING_NON_IMPLEMENTED_DEPRECATED": "void", - "CRAFTING_RESULTS_DEPRECATED": [ + "optional": [ + "container", + [ + { + "name": "recipe_network_id", + "type": "varint" + }, + { + "name": "filtered_string_index", + "type": "li32" + } + ] + ], + "non_implemented": "void", + "results_deprecated": [ "container", [ { "name": "result_items", - "type": "ItemStacks" + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] }, { "name": "times_crafted", @@ -2224,6 +2243,16 @@ ] } ] + }, + { + "name": "custom_names", + "type": [ + "array", + { + "countType": "varint", + "type": "string" + } + ] } ] ] @@ -2385,6 +2414,41 @@ } ] ], + "WindowID": [ + "mapper", + { + "type": "i8", + "mappings": { + "0": "inventory", + "1": "first", + "100": "last", + "119": "offhand", + "120": "armor", + "121": "creative", + "122": "hotbar", + "123": "fixed_inventory", + "124": "ui", + "-100": "drop_contents", + "-24": "beacon", + "-23": "trading_output", + "-22": "trading_use_inputs", + "-21": "trading_input_2", + "-20": "trading_input_1", + "-17": "enchant_output", + "-16": "enchant_material", + "-15": "enchant_input", + "-13": "anvil_output", + "-12": "anvil_result", + "-11": "anvil_material", + "-10": "container_input", + "-5": "crafting_use_ingredient", + "-4": "crafting_result", + "-3": "crafting_remove_ingredient", + "-2": "crafting_add_ingredient", + "-1": "none" + } + } + ], "WindowType": [ "mapper", { @@ -3063,6 +3127,10 @@ { "name": "source_name", "type": "string" + }, + { + "name": "message", + "type": "string" } ] ], @@ -3072,6 +3140,10 @@ { "name": "source_name", "type": "string" + }, + { + "name": "message", + "type": "string" } ] ], @@ -3081,6 +3153,10 @@ { "name": "source_name", "type": "string" + }, + { + "name": "message", + "type": "string" } ] ], @@ -4166,7 +4242,7 @@ }, { "name": "windows_id", - "type": "u8" + "type": "WindowID" } ] ], @@ -4457,8 +4533,8 @@ "type": "u8" }, { - "name": "type", - "type": "u8" + "name": "window_type", + "type": "WindowType" }, { "name": "coordinates", @@ -4492,7 +4568,7 @@ }, { "name": "window_id", - "type": "u8" + "type": "WindowID" }, { "name": "select_slot", @@ -4517,7 +4593,7 @@ "container", [ { - "name": "inventory_id", + "name": "window_id", "type": "varint" }, { @@ -4539,7 +4615,7 @@ [ { "name": "window_id", - "type": "u8" + "type": "WindowID" }, { "name": "property", @@ -4577,11 +4653,21 @@ [ { "name": "window_id", - "type": "u8" + "type": "WindowID" }, { "name": "recipe_type", - "type": "zigzag32" + "type": [ + "mapper", + { + "type": "zigzag32", + "mappings": { + "0": "inventory", + "1": "crafting", + "2": "workbench" + } + } + ] }, { "name": "recipe_id", @@ -4589,11 +4675,23 @@ }, { "name": "input", - "type": "ItemStacks" + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] }, { "name": "result", - "type": "ItemStacks" + "type": [ + "array", + { + "countType": "varint", + "type": "Item" + } + ] } ] ], @@ -4813,7 +4911,7 @@ "type": [ "mapper", { - "type": "varint", + "type": "zigzag32", "mappings": { "0": "achievement_awarded", "1": "entity_interact", @@ -4840,6 +4938,10 @@ { "name": "use_player_id", "type": "u8" + }, + { + "name": "event_data", + "type": "restBuffer" } ] ], @@ -6220,11 +6322,37 @@ ], "packet_level_event_generic": [ "container", - [] + [ + { + "name": "event_id", + "type": "varint" + }, + { + "name": "nbt", + "type": "nbtLoop" + } + ] ], "packet_lectern_update": [ "container", - [] + [ + { + "name": "page", + "type": "u8" + }, + { + "name": "page_count", + "type": "u8" + }, + { + "name": "position", + "type": "vec3i" + }, + { + "name": "drop_book", + "type": "bool" + } + ] ], "packet_video_stream_connect": [ "container", @@ -6306,12 +6434,20 @@ "packet_client_cache_blob_status": [ "container", [ + { + "name": "misses", + "type": "varint" + }, + { + "name": "haves", + "type": "varint" + }, { "name": "missing", "type": [ "array", { - "countType": "varint", + "count": "misses", "type": "lu64" } ] @@ -6321,7 +6457,7 @@ "type": [ "array", { - "countType": "varint", + "count": "haves", "type": "lu64" } ] @@ -6892,6 +7028,12 @@ "countType": "varint" } ], + "SignedByteArray": [ + "buffer", + { + "countType": "zigzag32" + } + ], "LittleString": [ "pstring", { @@ -6969,7 +7111,7 @@ "InputFlag": [ "bitflags", { - "type": "varint64", + "type": "varint", "flags": { "ascend": 1, "descend": 2, diff --git a/package.json b/package.json index b5647f9..043dc14 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,9 @@ "jsonwebtoken": "^8.5.1", "jsp-raknet": "github:extremeheat/raknet#client", "minecraft-folder-path": "^1.1.0", - "prismarine-nbt": "github:extremeheat/prismarine-nbt#le", + "prismarine-nbt": "^1.5.0", "protodef": "github:extremeheat/node-protodef#compiler", - "raknet-native": "^0.0.4", + "raknet-native": "^0.1.0", "uuid-1345": "^0.99.7" }, "devDependencies": { diff --git a/src/connection.js b/src/connection.js index e621446..367896c 100644 --- a/src/connection.js +++ b/src/connection.js @@ -35,9 +35,9 @@ class Connection extends EventEmitter { queue(name, params) { this.outLog('Q <- ', name, params) const packet = this.serializer.createPacketBuffer({ name, params }) - if (name == 'level_chunk') { - // Skip queue - this.sendMCPE(packet) + if (name == 'level_chunk' || name=='client_cache_blob_status' || name == 'client_cache_miss_response') { + // Skip queue, send ASAP + this.sendBuffer(packet) return } this.q.push(packet) @@ -54,12 +54,12 @@ class Connection extends EventEmitter { // For now, we're over conservative so send max 3 packets // per batch and hold the rest for the next tick const sending = [] - for (let i = 0; i < 3 && i < this.q.length; i++) { + for (let i = 0; i < this.q.length; i++) { const packet = this.q.shift() sending.push(this.q2.shift()) batch.addEncodedPacket(packet) } - // console.warn('~~ Sending', sending) + // this.outLog('~~ Sending', sending) if (this.encryptionEnabled) { this.sendEncryptedBatch(batch) } else { @@ -67,7 +67,7 @@ class Connection extends EventEmitter { } // this.q2 = [] } - }, 100) + }, 20) } writeRaw(name, buffer) { // skip protodef serializaion @@ -102,6 +102,7 @@ class Connection extends EventEmitter { } } else { this.q.push(buffer) + this.q2.push('rawBuffer') } } diff --git a/src/datatypes/compiler-minecraft.js b/src/datatypes/compiler-minecraft.js index 8d1e10f..a4ab558 100644 --- a/src/datatypes/compiler-minecraft.js +++ b/src/datatypes/compiler-minecraft.js @@ -1,9 +1,6 @@ const UUID = require('uuid-1345') const minecraft = require('./minecraft') - -const Read = {} -const Write = {} -const SizeOf = {} +const { Read, Write, SizeOf } = require('./varlong') /** * UUIDs @@ -38,6 +35,39 @@ SizeOf.restBuffer = ['native', (value) => { return value.length }] +/** + * Read NBT until end of buffer or \0 + */ +Read.nbtLoop = ['context', (buffer, offset) => { + const values = [] + while (buffer[offset] != 0) { + // console.log('offs',offset, buffer.length,buffer.slice(offset)) + const n = ctx.nbt(buffer, offset) + // console.log('read',n) + values.push(n.value) + offset += n.size + } + // console.log('Ext',offset, buffer.length,buffer.slice(offset)) + return { value: values, size: buffer.length - offset } +}] +Write.nbtLoop = ['context', (value, buffer, offset) => { + for (const val of value) { + // console.log('val',val,offset) + offset = ctx.nbt(val, buffer, offset) + } + // offset += 1 + // console.log('writing 0', offset) + buffer.writeUint8(0, offset) + return offset + 1 +}] +SizeOf.nbtLoop = ['context', (value, buffer, offset) => { + let size = 1 + for (const val of value) { + size += ctx.nbt(val, buffer, offset) + } + return size +}] + /** * NBT */ @@ -50,19 +80,19 @@ SizeOf.nbt = ['native', minecraft.nbt[2]] */ // nvm, // Read.bitflags = ['parametrizable', (compiler, { type, flags }) => { - // return compiler.wrapCode(` - // const { value, size } = ${compiler.callType('buffer, offset', type)} - // const val = {} - // for (let i = 0; i < size; i++) { - // const hi = (value >> i) & 1 - // if () - // const v = value & - // if (flags[i]) - // } - // ` +// return compiler.wrapCode(` +// const { value, size } = ${compiler.callType('buffer, offset', type)} +// const val = {} +// for (let i = 0; i < size; i++) { +// const hi = (value >> i) & 1 +// if () +// const v = value & +// if (flags[i]) +// } +// ` // }] -Read.bitflags = ['parametrizable', (compiler, { type, flags }) => { +Read.bitflags = ['parametrizable', (compiler, { type, flags }) => { return compiler.wrapCode(` const { value: _value, size } = ${compiler.callType(type, 'offset')} const value = { _value } @@ -75,7 +105,7 @@ Read.bitflags = ['parametrizable', (compiler, { type, flags }) => { }] -Write.bitflags = ['parametrizable', (compiler, { type, flags }) => { +Write.bitflags = ['parametrizable', (compiler, { type, flags }) => { return compiler.wrapCode(` const flags = ${JSON.stringify(flags)} let val = value._value @@ -86,7 +116,7 @@ Write.bitflags = ['parametrizable', (compiler, { type, flags }) => { `.trim()) }] -SizeOf.bitflags = ['parametrizable', (compiler, { type, flags }) => { +SizeOf.bitflags = ['parametrizable', (compiler, { type, flags }) => { return compiler.wrapCode(` const flags = ${JSON.stringify(flags)} let val = value._value @@ -117,7 +147,7 @@ Write.enum_size_based_on_values_len = ['parametrizable', (compiler) => { }) }] SizeOf.enum_size_based_on_values_len = ['parametrizable', (compiler) => { - return str(() => { + return str(() => { if (value.values_len <= 0xff) _enum_type = 'byte' else if (value.values_len <= 0xffff) _enum_type = 'short' else if (value.values_len <= 0xffffff) _enum_type = 'int' diff --git a/src/datatypes/varlong.js b/src/datatypes/varlong.js new file mode 100644 index 0000000..fa1059f --- /dev/null +++ b/src/datatypes/varlong.js @@ -0,0 +1,63 @@ +function sizeOfVarLong(value) { + if (typeof value.valueOf() === 'object') { + value = (BigInt(value[0]) << 32n) | BigInt(value[1]) + } else if (typeof value !== 'bigint') value = BigInt(value) + + let cursor = 0 + while (value > 127n) { + value >>= 7n + cursor++ + } + return cursor + 1 +} + +/** + * Reads a 64-bit VarInt as a BigInt + */ +function readVarLong(buffer, offset) { + let result = BigInt(0) + let shift = 0n + let cursor = offset + let size = 0 + + while (true) { + if (cursor + 1 > buffer.length) { throw new Error('unexpected buffer end') } + const b = buffer.readUInt8(cursor) + result |= (BigInt(b) & 0x7fn) << shift // Add the bits to our number, except MSB + cursor++ + if (!(b & 0x80)) { // If the MSB is not set, we return the number + size = cursor - offset + break + } + shift += 7n // we only have 7 bits, MSB being the return-trigger + if (shift > 63n) throw new Error(`varint is too big: ${shift}`) + } + + return { value: result, size } +} + +/** + * Writes a zigzag encoded 64-bit VarInt as a BigInt + */ +function writeVarLong(value, buffer, offset) { + // if an array, turn it into a BigInt + if (typeof value.valueOf() === 'object') { + value = BigInt.asIntN(64, (BigInt(value[0]) << 32n)) | BigInt(value[1]) + } else if (typeof value !== 'bigint') value = BigInt(value) + + let cursor = 0 + while (value > 127n) { // keep writing in 7 bit slices + const num = Number(value & 0xFFn) + buffer.writeUInt8(num | 0x80, offset + cursor) + cursor++ + value >>= 7n + } + buffer.writeUInt8(Number(value), offset + cursor) + return offset + cursor + 1 +} + +module.exports = { + Read: { varint64: ['native', readVarLong] }, + Write: { varint64: ['native', writeVarLong] }, + SizeOf: { varint64: ['native', sizeOfVarLong] } +} \ No newline at end of file diff --git a/src/rak.js b/src/rak.js index 5a16182..ad216a0 100644 --- a/src/rak.js +++ b/src/rak.js @@ -18,7 +18,7 @@ class RakNativeClient extends EventEmitter { this.raknet = new Client(options.hostname, options.port, 'minecraft') this.raknet.on('encapsulated', thingy => { - console.log('Encap',thingy) + // console.log('Encap',thingy) const { buffer, address, guid }=thingy this.onEncapsulated(buffer, address) }) @@ -76,7 +76,7 @@ class RakNativeServer extends EventEmitter { this.raknet.on('encapsulated', (thingy) => { const { buffer, address, guid }=thingy - console.log('ENCAP',thingy) + // console.log('ENCAP',thingy) this.onEncapsulated(buffer, address) }) } diff --git a/src/relay.js b/src/relay.js index 6fdc890..0fee6af 100644 --- a/src/relay.js +++ b/src/relay.js @@ -1,4 +1,5 @@ -process.env.DEBUG = 'minecraft-protocol raknet' +// process.env.DEBUG = 'minecraft-protocol raknet' +const fs = require('fs') const { Client } = require("./client") const { Server } = require("./server") const { Player } = require("./serverPlayer") @@ -6,6 +7,8 @@ const debug = require('debug')('minecraft-protocol relay') /** @typedef {{ hostname: string, port: number, auth: 'client' | 'server' | null, destination?: { hostname: string, port: number } }} Options */ +const debugging = true // Do re-encoding tests + class RelayPlayer extends Player { constructor(server, conn) { super(server, conn) @@ -13,10 +16,8 @@ class RelayPlayer extends Player { this.conn = conn this.startRelaying = false - this.once('join', () => { - this.write('client_cache_status', {enabled:false}) // disable this asap on join - - this.flushDownQueue() + this.once('join', () => { // The client has joined our proxy + this.flushDownQueue() // Send queued packets from the upstream backend this.startRelaying = true }) this.downQ = [] @@ -26,6 +27,20 @@ class RelayPlayer extends Player { this.downInLog = (...msg) => console.info('** Client -> Proxy', ...msg) this.downOutLog = (...msg) => console.info('** Proxy -> Client', ...msg) + if (!server.options.logging) { + this.upInLog = () => { } + this.upOutLog = () => { } + this.downInLog = () => { } + this.downOutLog = () => { } + } + + // this.upOutLog = (...msg) => { + // if (msg.includes('player_auth_input')) { + // // stream.write(msg) + // console.info('INPUT', msg) + // } + // } + this.outLog = this.downOutLog this.inLog = this.downInLog } @@ -41,22 +56,26 @@ class RelayPlayer extends Player { const des = this.server.deserializer.parsePacketBuffer(packet) const name = des.data.name const params = des.data.params - this.upInLog('~~ Bounce B->C', name, serialize(params).slice(0, 100)) - this.upInLog('~~ ', des.buffer) - if (name == 'play_status' && params.status == 'login_success') return + this.upInLog('~ Bounce B->C', name, serialize(params).slice(0, 100)) + // this.upInLog('~ ', des.buffer) + if (name == 'play_status' && params.status == 'login_success') return // We already sent this, this needs to be sent ASAP or client will disconnect - if (name == 'level_chunk') { //send chunk directly - this.upInLog('Would send chunk', params) - this.sendBuffer(packet) - return - } else this.upInLog('?',name) + if (debugging) { // some packet encode/decode testing stuff + const rpacket = this.server.serializer.createPacketBuffer({ name, params }) + if (rpacket.toString('hex') !== packet.toString('hex')) { + console.warn('New', rpacket.toString('hex')) + console.warn('Old', packet.toString('hex')) + console.log('Failed to re-encode', name, params) + process.exit(1) + throw Error('re-encoding fail for' + name + ' - ' + JSON.stringify(params)) + } + } - // if (name == 'network_chunk_publisher_update') return - // if (name == 'crafting_data' || name == 'level_chunk') return // Alex breaks this.queue(name, params) // this.sendBuffer(packet) } + // Send queued packets to the connected client flushDownQueue() { for (const packet of this.downQ) { const des = this.server.deserializer.parsePacketBuffer(packet) @@ -65,11 +84,12 @@ class RelayPlayer extends Player { this.downQ = [] } + // Send queued packets to the backend upstream server from the client flushUpQueue() { for (var e of this.upQ) { // Send the queue const des = this.server.deserializer.parsePacketBuffer(e) - if (des.data.name == 'client_cache_status') { // already disabled on join - // this.upstream.write('client_cache_status', {enabled:false}) + if (des.data.name == 'client_cache_status') { // Currently broken, force off the chunk cache + this.upstream.write('client_cache_status', { enabled: false }) } else { this.upstream.write(des.data.name, des.data.params) } @@ -79,25 +99,35 @@ class RelayPlayer extends Player { // Called when the server gets a packet from the downstream player (Client -> PROXY -> Backend) readPacket(packet) { - if (this.startRelaying) { // The DS client conn is established & we got a packet to send to US server + if (this.startRelaying) { // The downstream client conn is established & we got a packet to send to upstream server if (!this.upstream) { // Upstream is still connecting/handshaking - debug('Got downstream connected packet but upstream is not connected yet, added to q', this.queue.length) + this.downInLog('Got downstream connected packet but upstream is not connected yet, added to q', this.upQ.length) this.upQ.push(packet) // Put into a queue return } this.flushUpQueue() // Send queued packets this.downInLog('Recv packet', packet) const des = this.server.deserializer.parsePacketBuffer(packet) + + if (debugging) { // some packet encode/decode testing stuff + const rpacket = this.server.serializer.createPacketBuffer(des.data) + if (rpacket.toString('hex') !== packet.toString('hex')) { + console.warn('New', rpacket.toString('hex')) + console.warn('Old', packet.toString('hex')) + console.log('Failed to re-encode', des.data) + process.exit(1) + } + } + switch (des.data.name) { case 'client_cache_status': - this.upstream.queue('client_cache_status', {enabled:false}) + this.upstream.queue('client_cache_status', { enabled: false }) break - // case 'request_chunk_radius': - // this.upstream.queue('request_chunk_radius', {chunk_radius: 1}) - // break default: // Emit the packet as-is back to the upstream server - this.upstream.queue(des.data.name, des.data.params) + // this.upstream.queue(des.data.name, des.data.params) + this.downInLog('Relaying', des.data) + this.upstream.sendBuffer(packet) } } else { super.readPacket(packet) @@ -150,15 +180,13 @@ class Relay extends Server { conn.close() } else { const player = new this.RelayPlayer(this, conn) - console.log('NEW CONNECTION', conn.address) + console.debug('New connection from', conn.address) this.clients[conn.address] = player this.emit('connect', { client: player }) this.openUpstreamConnection(player, conn.address) } } } -console.log = () => {} - function serialize(obj = {}, fmt) { return JSON.stringify(obj, (k, v) => typeof v == 'bigint' ? v.toString() : v, fmt) @@ -192,7 +220,7 @@ function createRelay() { destination: { hostname: '127.0.0.1', port: 19132, - encryption: true + // encryption: true } }) diff --git a/test/serialization.js b/test/serialization.js index 6c1cbe5..bde8b37 100644 --- a/test/serialization.js +++ b/test/serialization.js @@ -241,13 +241,50 @@ function test() { } + function testLevelEventGeneric() { + const s = '7cce1f0305436f756e74800205084469725363616c65cdcc4c3e0504456e647800a01c440504456e647900001a420504456e647a00008942050653746172747899ef1944050653746172747900002042050653746172747a4583a042050a566172696174696f6e789a99193f050a566172696174696f6e799a99394000' + const buf = Buffer.from(s, 'hex') + const des = read(buf) + console.log(JSON.stringify(des)) + + console.log(des.data.name) + const newBuf = write(des.data.name, des.data.params) + console.log(newBuf.toString('hex'), s) + console.assert(newBuf.toString('hex')==s) + } + + function testEvent() { + const s = '41fdffffff5f2801001203e1417678933fdf294642a034a03e57b65b40' + const buf = Buffer.from(s, 'hex') + const des = read(buf) + console.log(serialize(des)) + + console.log(des.data.name) + const newBuf = write(des.data.name, des.data.params) + console.log(newBuf.toString('hex'), s) + console.assert(newBuf.toString('hex')==s) + } + + function testItemStackReq() { + const s = '93010105030b9d050e01920502000000000100013b32053a000000' + const buf = Buffer.from(s, 'hex') + const des = read(buf) + console.log(serialize(des)) + + console.log(des.data.name) + const newBuf = write(des.data.name, des.data.params) + console.log(newBuf.toString('hex'), 'OLD:', s) + console.assert(newBuf.toString('hex')==s) + } + // creativeTst() // availableCommands() // avaliableCmd() // creativeTestNew() // biomeDefinitions() // startGame() - testInventory() + // testLevelEventGeneric() + testItemStackReq() } if (!module.parent) {