From de058638150e3fba55aa26eec3609b76bdfa1128 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 10 Jun 2016 02:26:23 +0200 Subject: [PATCH] use mcdata --- data/protocol.json | 1936 ---------------------------------- package.json | 1 + src/createClient.js | 2 +- src/createServer.js | 2 +- src/transforms/serializer.js | 2 +- 5 files changed, 4 insertions(+), 1939 deletions(-) delete mode 100644 data/protocol.json diff --git a/data/protocol.json b/data/protocol.json deleted file mode 100644 index 8964c20..0000000 --- a/data/protocol.json +++ /dev/null @@ -1,1936 +0,0 @@ -{ - "types": { - "string": [ - "pstring", - { - "countType":"i16" - } - ], - "lstring": [ - "pstring", - { - "countType":"li16" - } - ], - "shapeless_recipe": [ - "container", - [ - { - "name":"ingredientList", - "type": - [ - "array", - { - "countType":"i32", - "type":"slot" - } - ] - }, - { - "name": "result_count", - "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": "result_count", - "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", - "id": "i32" - } - ] - } - ] - }, - { - "name": "name", - "type": "string" - } - ] - } - ], - "entityMetadataItem": [ - "switch", - { - "compareTo": "$compareTo", - "fields": { - "0": "li8", - "1": "li16", - "2": "li32", - "3": "lf32", - "4": "lstring", - "5": ["container",[ - { - "name":"block_id", - "type":"li16" - }, - { - "name":"item_count", - "type":"li8" - }, - { - "name":"item_damage", - "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": "block_id", - "type": "i16" - }, - { - "anon": true, - "type": [ - "switch", - { - "compareTo": "block_id", - "fields": { - "0": "void" - }, - "default": [ - "container", - [ - { - "name": "item_count", - "type": "i8" - }, - { - "name": "item_damage", - "type": "i16" - }, - { - "name": "nbt_data", - "type": ["buffer",{"countType":"li16"}] - } - ] - ] - } - ] - } - ] - ], - "itemstacks": [ - "array", - { - "countType":"i16", - "type": [ - "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": "block_id", - "type": "i8" - }, - { - "anon": true, - "type": [ - "bitfield", - [ - { - "name": "block_data", - "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": "min_value", - "type": "f32" - }, - { - "name": "max_value", - "type": "f32" - }, - { - "name": "id", - "type": "f32" - }, - { - "name": "name", - "type": "string" - } - ] - ] - } - ], - "entitymotions": [ - "array", - { - "countType":"i16", - "type": [ - "container", - [ - { - "name": "eid", - "type": "i64" - }, - { - "name": "mot_x", - "type": "f32" - }, - { - "name": "mot_y", - "type": "f32" - }, - { - "name": "mot_z", - "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": "head_yaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - } - ] - ] - } - ], - "encapsulated_packet":[ - "container", - [ - { - "name": "name", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0x8e": "mcpe" - } - } - ] - }, - { - "name": "params", - "type": [ - "switch", - { - "compareTo": "name", - "fields": { - "mcpe":"mcpe_packet" - } - } - ] - } - ] - ], - "mcpe_packet": [ - "container", - [ - { - "name": "name", - "type": [ - "mapper", - { - "type": "u8", - "mappings": { - "0x04": "id_detect_lost_connections", - "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" - } - } - ] - }, - { - "name": "params", - "type": [ - "switch", - { - "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", - "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", - "tile_event": "packet_tile_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", - "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", - "tile_entity_data": "packet_tile_entity_data", - "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" - } - } - ] - } - ] - ], - "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_game_login": [ - "container", - [ - { - "name": "username", - "type": "string" - }, - { - "name": "protocol", - "type": "i32" - }, - { - "name": "protocol2", - "type": "i32" - }, - { - "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" - } - ] - ], - "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": "i32" - }, - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "spawn_x", - "type": "i32" - }, - { - "name": "spawn_y", - "type": "i32" - }, - { - "name": "spawn_z", - "type": "i32" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "unknown1", - "type": "i8" - }, - { - "name": "unknown2", - "type": "i8" - }, - { - "name": "unknown3", - "type": "i8" - }, - { - "name": "unknown4", - "type": "string" - } - ] - ], - "packet_add_player": [ - "container", - [ - { - "name": "uuid", - "type": "uuid" - }, - { - "name": "username", - "type": "string" - }, - { - "name": "entity_id", - "type": "i64" - }, - { - "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": "head_yaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - }, - { - "name": "item", - "type": "slot" - }, - { - "name": "metadata", - "type": "metadatadictionary" - } - ] - ], - "packet_remove_player": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "client_uuid", - "type": "uuid" - } - ] - ], - "packet_add_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "entity_type", - "type": "i32" - }, - { - "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": "metadata", - "type": "metadatadictionary" - }, - { - "name": "links", - "type": "i16" - } - ] - ], - "packet_remove_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - } - ] - ], - "packet_add_item_entity": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "item", - "type": "slot" - }, - { - "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" - } - ] - ], - "packet_take_item_entity": [ - "container", - [ - { - "name": "target", - "type": "i64" - }, - { - "name": "entity_id", - "type": "i64" - } - ] - ], - "packet_move_entity": [ - "container", - [ - { - "name": "entities", - "type": "entitylocations" - } - ] - ], - "packet_move_player": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "yaw", - "type": "f32" - }, - { - "name": "head_yaw", - "type": "f32" - }, - { - "name": "pitch", - "type": "f32" - }, - { - "name": "mode", - "type": "i8" - }, - { - "name": "on_ground", - "type": "i8" - } - ] - ], - "packet_remove_block": [ - "container", - [ - { - "name": "entity_id", - "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": "entity_id", - "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": "event_id", - "type": "i16" - }, - { - "name": "x", - "type": "f32" - }, - { - "name": "y", - "type": "f32" - }, - { - "name": "z", - "type": "f32" - }, - { - "name": "data", - "type": "i32" - } - ] - ], - "packet_tile_event": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "case_1", - "type": "i32" - }, - { - "name": "case_2", - "type": "i32" - } - ] - ], - "packet_entity_event": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "event_id", - "type": "i8" - } - ] - ], - "packet_mob_effect": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "event_id", - "type": "i8" - }, - { - "name": "effect_id", - "type": "i8" - }, - { - "name": "amplifier", - "type": "i8" - }, - { - "name": "particles", - "type": "i8" - }, - { - "name": "duration", - "type": "i32" - } - ] - ], - "packet_update_attributes": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "attributes", - "type": "playerattributes" - } - ] - ], - "packet_player_equipment": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "item", - "type": "slot" - }, - { - "name": "slot", - "type": "i8" - }, - { - "name": "selected_slot", - "type": "i8" - } - ] - ], - "packet_player_armor_equipment": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "helmet", - "type": "slot" - }, - { - "name": "chestplate", - "type": "slot" - }, - { - "name": "leggings", - "type": "slot" - }, - { - "name": "boots", - "type": "slot" - } - ] - ], - "packet_interact": [ - "container", - [ - { - "name": "action_id", - "type": "i8" - }, - { - "name": "target_entity_id", - "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": "entity_id", - "type": "i64" - }, - { - "name": "action_id", - "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": "rider_id", - "type": "i64" - }, - { - "name": "ridden_id", - "type": "i64" - }, - { - "name": "link_type", - "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": "action_id", - "type": "i8" - }, - { - "name": "entity_id", - "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": "window_id", - "type": "i8" - }, - { - "name": "type", - "type": "i8" - }, - { - "name": "slot_count", - "type": "i16" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - } - ] - ], - "packet_container_close": [ - "container", - [ - { - "name": "window_id", - "type": "i8" - } - ] - ], - "packet_container_set_slot": [ - "container", - [ - { - "name": "window_id", - "type": "i8" - }, - { - "name": "slot", - "type": "i16" - }, - { - "name": "unknown", - "type": "i16" - }, - { - "name": "item", - "type": "slot" - } - ] - ], - "packet_container_set_data": [ - "container", - [ - { - "name": "window_id", - "type": "i8" - }, - { - "name": "property", - "type": "i16" - }, - { - "name": "value", - "type": "i16" - } - ] - ], - "packet_container_set_content": [ - "container", - [ - { - "name": "window_id", - "type": "i8" - }, - { - "name": "slot_data", - "type": "itemstacks" - }, - { - "name": "hotbar_data", - "type": [ - "switch", - { - "compareTo": "window_id", - "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": "shapeless_recipe", - "1": "shaped_recipe", - "2": "furnace_recipe", - "3": "furnace_recipe_data", - "4": "enchant_list" - }, - "default":"void" - } - ] - } - ] - } - ] - ] - }, - { - "name": "cleanRecipes", - "type": "i8" - } - ] - ], - "packet_crafting_event": [ - "container", - [ - { - "name": "window_id", - "type": "i8" - }, - { - "name": "recipe_type", - "type": "i32" - }, - { - "name": "recipe_id", - "type": "uuid" - }, - { - "name": "input", - "type": "itemstacks" - }, - { - "name": "result", - "type": "itemstacks" - } - ] - ], - "packet_adventure_settings": [ - "container", - [ - { - "name": "flags", - "type": "i32" - }, - { - "name": "user_permission", - "type": "i32" - }, - { - "name": "global_permission", - "type": "i32" - } - ] - ], - "packet_tile_entity_data": [ - "container", - [ - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "namedtag", - "type": "restBuffer" - } - ] - ], - "packet_full_chunk_data": [ - "container", - [ - { - "name": "chunk_x", - "type": "i32" - }, - { - "name": "chunk_z", - "type": "i32" - }, - { - "name": "order", - "type": "i8" - }, - { - "name": "chunk_data", - "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": "client_uuid", - "type": "uuid" - }, - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "display_name", - "type": "string" - }, - { - "name": "skin", - "type": "skin" - } - ] - ], - "1": [ - "container", - [ - { - "name": "client_uuid", - "type": "uuid" - } - ] - ] - } - } - ] - } - ] - } - ] - ], - "packet_request_chunk_radius": [ - "container", - [ - { - "name": "chunk_radius", - "type": "i32" - } - ] - ], - "packet_chunk_radius_update": [ - "container", - [ - { - "name": "chunk_radius", - "type": "i32" - } - ] - ], - "packet_transfer": [ - "container", - [ - { - "name": "endpoint", - "type": "ipAddress" - } - ] - ], - "packet_spawn_experience_orb": [ - "container", - [ - { - "name": "entity_id", - "type": "i64" - }, - { - "name": "x", - "type": "i32" - }, - { - "name": "y", - "type": "i32" - }, - { - "name": "z", - "type": "i32" - }, - { - "name": "count", - "type": "i32" - } - ] - ] - } -} diff --git a/package.json b/package.json index 6847f96..64b98ca 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ ], "license": "MIT", "dependencies": { + "minecraft-data": "^2.4.0", "prismarine-nbt": "^1.0.0", "protodef": "^1.2.0", "raknet": "^1.7.3", diff --git a/src/createClient.js b/src/createClient.js index cace13d..f1be549 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -16,7 +16,7 @@ function createClient(options) { assert.ok(options.username, 'username is required'); - options.customPackets=require('../data/protocol'); + options.customPackets=require('minecraft-data')('pe_0.14').protocol; options.customTypes=require('./datatypes/minecraft'); var client=raknet.createClient(options); diff --git a/src/createServer.js b/src/createServer.js index 943f34f..88b47f8 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -14,7 +14,7 @@ function createServer(options) { 19132; var host = options.host || '0.0.0.0'; - options.customPackets=require("../data/protocol"); + options.customPackets=require('minecraft-data')('pe_0.14').protocol; options.customTypes=require("./datatypes/minecraft"); var server = raknet.createServer(options); diff --git a/src/transforms/serializer.js b/src/transforms/serializer.js index bda77e3..1471408 100644 --- a/src/transforms/serializer.js +++ b/src/transforms/serializer.js @@ -2,7 +2,7 @@ var ProtoDef = require('protodef').ProtoDef; var Serializer = require('protodef').Serializer; var Parser = require('protodef').Parser; -var protocol = require('../../data/protocol.json').types; +var protocol = require('minecraft-data')('pe_0.14').protocol; function createProtocol() { var proto = new ProtoDef();