From 91ef126fc461f9b4b50973c36e8ff2614dc2981c Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Sat, 13 Feb 2016 13:09:13 -0500 Subject: [PATCH] initial commit --- .gitignore | 3 + .npmignore | 2 + Gulpfile.js | 27 + LICENSE | 21 + README.md | 27 + data/protocol.json | 1940 ++++++++++++++++++++++++++++++++++++++++++++ examples/client.js | 1 + examples/server.js | 1 + index.js | 1 + package.json | 35 + src/index.js | 0 11 files changed, 2058 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 Gulpfile.js create mode 100644 LICENSE create mode 100644 README.md create mode 100644 data/protocol.json create mode 100644 examples/client.js create mode 100644 examples/server.js create mode 100644 index.js create mode 100644 package.json create mode 100644 src/index.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f8deb35 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +npm-debug.log +dist/ \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..9303c34 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +node_modules/ +npm-debug.log \ No newline at end of file diff --git a/Gulpfile.js b/Gulpfile.js new file mode 100644 index 0000000..12f1f3a --- /dev/null +++ b/Gulpfile.js @@ -0,0 +1,27 @@ +var gulp = require('gulp'); +var plumber = require('gulp-plumber'); +var babel = require('gulp-babel'); +var sourcemaps = require('gulp-sourcemaps'); +var options = { stage: 0, optional: ["runtime"] }; + +gulp.task('compile', function() { + return gulp + .src('src/**/*.js') + .pipe(plumber({ + errorHandler: function(err) { + console.error(err.stack); + this.emit('end'); + } + })) + .pipe(sourcemaps.init()) + .pipe(babel(options)) + .pipe(plumber.stop()) + .pipe(sourcemaps.write('maps/')) + .pipe(gulp.dest('dist/')); +}); + +gulp.task('watch', function() { + return gulp.watch('src/**/*.js', ['compile']); +}); + +gulp.task('default', ['compile']); \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..53368f0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 mhsjlw + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d7930b3 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +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/node-minecraft-protocol](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg)](https://gitter.im/PrismarineJS/node-minecraft-protocol) + +Parse and serialize Minecraft pocket edition packets. + +## Features + + * Supports Minecraft PE `0.13.x` + * Pure javascript + * Easily send and listen for any packet + * RakNet support through node-raknet + +## Installation +Simply run + + npm install pocket-minecraft-protcol + +Then view our `examples` for inspiration! + +## Contributors +This project is run by these guys: + + - [mhsjlw](https://github.com/mhsjlw) ([mhsjlw@aol.com](mailto:mhsjlw@aol.com)) + - [rom1504](https://github.com/rom1504) \ No newline at end of file diff --git a/data/protocol.json b/data/protocol.json new file mode 100644 index 0000000..c78b121 --- /dev/null +++ b/data/protocol.json @@ -0,0 +1,1940 @@ +{ + "toServer": { + "id_connected_ping": { + "id": "0x00", + "online": "false", + "fields": [ + { + "name": "sendpingtime", + "type": "long" + } + ] + }, + "id_connected_pong": { + "id": "0x03", + "online": "false", + "fields": [ + { + "name": "sendpingtime", + "type": "long" + }, + { + "name": "sendpongtime", + "type": "long" + } + ] + }, + "id_detect_lost_connections": { + "id": "0x04", + "online": "false", + "fields": [] + }, + "id_open_connection_reply_1": { + "id": "0x06", + "fields": [ + { + "name": "offline_message_data_id", + "type": "offline_message_data_id" + }, + { + "name": "server_guid", + "type": "long" + }, + { + "name": "server_has_security", + "type": "byte" + }, + { + "name": "mtu_size", + "type": "short" + } + ] + }, + "id_open_connection_reply_2": { + "id": "0x08", + "fields": [ + { + "name": "offline_message_data_id", + "type": "offline_message_data_id" + }, + { + "name": "server_guid", + "type": "long" + }, + { + "name": "clientendpoint", + "type": "ipendpoint" + }, + { + "name": "mtu_size", + "type": "short" + }, + { + "name": "do_security_and_handshake", + "type": "byte[]" + } + ] + }, + "id_connection_request": { + "id": "0x09", + "online": "false", + "fields": [ + { + "name": "client_guid", + "type": "long" + }, + { + "name": "timestamp", + "type": "long" + }, + { + "name": "do_security", + "type": "byte" + } + ] + }, + "id_connection_request_accepted": { + "id": "0x10", + "online": "false", + "fields": [ + { + "name": "system_address", + "type": "ipendpoint" + }, + { + "name": "system_addresses", + "type": "ipendpoint[]" + }, + { + "name": "incoming_timestamp", + "type": "long" + }, + { + "name": "server_timestamp", + "type": "long" + } + ] + }, + "id_no_free_incoming_connections": { + "id": "0x14", + "online": "false", + "fields": [] + }, + "id_disconnection_notification": { + "id": "0x15", + "online": "false", + "fields": [] + }, + "id_connection_banned": { + "id": "0x17", + "online": "false", + "fields": [] + }, + "id_ip_recently_connected": { + "id": "0x1A", + "online": "false", + "fields": [] + }, + "mcpe_player_status": { + "id": "0x90", + "online": "false", + "fields": [ + { + "name": "status", + "type": "int" + } + ] + }, + "mcpe_disconnect": { + "id": "0x91", + "online": "false", + "fields": [ + { + "name": "message", + "type": "string" + } + ] + }, + "mcpe_batch": { + "id": "0x92", + "online": "false", + "fields": [ + { + "name": "payload_size", + "type": "int" + }, + { + "name": "payload", + "type": "byte[]" + } + ] + }, + "mcpe_text": { + "id": "0x93", + "online": "false", + "fields": [ + { + "name": "type", + "type": "byte" + } + ] + }, + "mcpe_set_time": { + "id": "0x94", + "online": "false", + "fields": [ + { + "name": "time", + "type": "int" + }, + { + "name": "started", + "type": "byte" + } + ] + }, + "mcpe_start_game": { + "id": "0x95", + "online": "false", + "fields": [ + { + "name": "seed", + "type": "int" + }, + { + "name": "dimension", + "type": "byte" + }, + { + "name": "generator", + "type": "int" + }, + { + "name": "gamemode", + "type": "int" + }, + { + "name": "entity_id", + "type": "long" + }, + { + "name": "spawn_x", + "type": "int" + }, + { + "name": "spawn_y", + "type": "int" + }, + { + "name": "spawn_z", + "type": "int" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "unknown", + "type": "byte" + } + ] + }, + "mcpe_add_player": { + "id": "0x96", + "online": "false", + "fields": [ + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "username", + "type": "string" + }, + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "speed_x", + "type": "float" + }, + { + "name": "speed_y", + "type": "float" + }, + { + "name": "speed_z", + "type": "float" + }, + { + "name": "yaw", + "type": "float" + }, + { + "name": "head_yaw", + "type": "float" + }, + { + "name": "pitch", + "type": "float" + }, + { + "name": "item", + "type": "item" + }, + { + "name": "metadata", + "type": "metadatadictionary" + } + ] + }, + "mcpe_remove_player": { + "id": "0x97", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "client_uuid", + "type": "uuid" + } + ] + }, + "mcpe_add_entity": { + "id": "0x98", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "entity_type", + "type": "int" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "speed_x", + "type": "float" + }, + { + "name": "speed_y", + "type": "float" + }, + { + "name": "speed_z", + "type": "float" + }, + { + "name": "yaw", + "type": "float" + }, + { + "name": "pitch", + "type": "float" + }, + { + "name": "metadata", + "type": "metadatadictionary" + }, + { + "name": "links", + "type": "short" + } + ] + }, + "mcpe_remove_entity": { + "id": "0x99", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + } + ] + }, + "mcpe_add_item_entity": { + "id": "0x9a", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "item", + "type": "item" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "speed_x", + "type": "float" + }, + { + "name": "speed_y", + "type": "float" + }, + { + "name": "speed_z", + "type": "float" + } + ] + }, + "mcpe_take_item_entity": { + "id": "0x9b", + "online": "false", + "fields": [ + { + "name": "target", + "type": "long" + }, + { + "name": "entity_id", + "type": "long" + } + ] + }, + "mcpe_move_entity": { + "id": "0x9c", + "online": "false", + "fields": [ + { + "name": "entities", + "type": "entitylocations" + } + ] + }, + "mcpe_move_player": { + "id": "0x9d", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "yaw", + "type": "float" + }, + { + "name": "head_yaw", + "type": "float" + }, + { + "name": "pitch", + "type": "float" + }, + { + "name": "mode", + "type": "byte" + }, + { + "name": "on_ground", + "type": "byte" + } + ] + }, + "mcpe_remove_block": { + "id": "0x9e", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "y", + "type": "byte" + } + ] + }, + "mcpe_update_block": { + "id": "0x9f", + "online": "false", + "fields": [ + { + "name": "blocks", + "type": "blockrecords" + } + ] + }, + "mcpe_add_painting": { + "id": "0xa0", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "direction", + "type": "int" + }, + { + "name": "title", + "type": "string" + } + ] + }, + "mcpe_explode": { + "id": "0xa1", + "online": "false", + "fields": [ + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "radius", + "type": "float" + }, + { + "name": "records", + "type": "records" + } + ] + }, + "mcpe_level_event": { + "id": "0xa2", + "online": "false", + "fields": [ + { + "name": "event_id", + "type": "short" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "data", + "type": "int" + } + ] + }, + "mcpe_tile_event": { + "id": "0xa3", + "online": "false", + "fields": [ + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "case_1", + "type": "int" + }, + { + "name": "case_2", + "type": "int" + } + ] + }, + "mcpe_entity_event": { + "id": "0xa4", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "event_id", + "type": "byte" + } + ] + }, + "mcpe_mob_effect": { + "id": "0xa5", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "event_id", + "type": "byte" + }, + { + "name": "effect_id", + "type": "byte" + }, + { + "name": "amplifier", + "type": "byte" + }, + { + "name": "particles", + "type": "byte" + }, + { + "name": "duration", + "type": "int" + } + ] + }, + "mcpe_update_attributes": { + "id": "0xa6", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "attributes", + "type": "playerattributes" + } + ] + }, + "mcpe_player_equipment": { + "id": "0xa7", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "item", + "type": "item" + }, + { + "name": "slot", + "type": "byte" + }, + { + "name": "selected_slot", + "type": "byte" + } + ] + }, + "mcpe_player_armor_equipment": { + "id": "0xa8", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "helmet", + "type": "item" + }, + { + "name": "chestplate", + "type": "item" + }, + { + "name": "leggings", + "type": "item" + }, + { + "name": "boots", + "type": "item" + } + ] + }, + "mcpe_interact": { + "id": "0xa9", + "online": "false", + "fields": [ + { + "name": "action_id", + "type": "byte" + }, + { + "name": "target_entity_id", + "type": "long" + } + ] + }, + "mcpe_use_item": { + "id": "0xaa", + "online": "false", + "fields": [ + { + "name": "blockcoordinates", + "type": "blockcoordinates" + }, + { + "name": "face", + "type": "byte" + }, + { + "name": "facecoordinates", + "type": "vector3" + }, + { + "name": "playerposition", + "type": "vector3" + }, + { + "name": "item", + "type": "item" + } + ] + }, + "mcpe_hurt_armor": { + "id": "0xac", + "online": "false", + "fields": [ + { + "name": "health", + "type": "byte" + } + ] + }, + "mcpe_set_entity_data": { + "id": "0xad", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "metadata", + "type": "metadatadictionary" + } + ] + }, + "mcpe_set_entity_motion": { + "id": "0xae", + "online": "false", + "fields": [ + { + "name": "entities", + "type": "entitymotions" + } + ] + }, + "mcpe_set_entity_link": { + "id": "0xaf", + "online": "false", + "fields": [ + { + "name": "rider_id", + "type": "long" + }, + { + "name": "ridden_id", + "type": "long" + }, + { + "name": "link_type", + "type": "byte" + } + ] + }, + "mcpe_set_health": { + "id": "0xb0", + "online": "false", + "fields": [ + { + "name": "health", + "type": "int" + } + ] + }, + "mcpe_set_spawn_position": { + "id": "0xb1", + "online": "false", + "fields": [ + { + "name": "x", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "y", + "type": "int" + } + ] + }, + "mcpe_animate": { + "id": "0xb2", + "online": "false", + "fields": [ + { + "name": "action_id", + "type": "byte" + }, + { + "name": "entity_id", + "type": "long" + } + ] + }, + "mcpe_respawn": { + "id": "0xb3", + "online": "false", + "fields": [ + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + } + ] + }, + "mcpe_container_open": { + "id": "0xb5", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "type", + "type": "byte" + }, + { + "name": "slot_count", + "type": "short" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + } + ] + }, + "mcpe_container_close": { + "id": "0xb6", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + } + ] + }, + "mcpe_container_set_slot": { + "id": "0xb7", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "slot", + "type": "short" + }, + { + "name": "unknown", + "type": "short" + }, + { + "name": "item", + "type": "item" + } + ] + }, + "mcpe_container_set_data": { + "id": "0xb8", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "property", + "type": "short" + }, + { + "name": "value", + "type": "short" + } + ] + }, + "mcpe_container_set_content": { + "id": "0xb9", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "slot_data", + "type": "itemstacks" + }, + { + "name": "hotbar_data", + "type": "metadataints" + } + ] + }, + "mcpe_crafting_data": { + "id": "0xba", + "online": "false", + "fields": [ + { + "name": "recipes", + "type": "recipes" + } + ] + }, + "mcpe_crafting_event": { + "id": "0xbb", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "recipe_type", + "type": "int" + }, + { + "name": "recipe_id", + "type": "uuid" + }, + { + "name": "input", + "type": "itemstacks" + }, + { + "name": "result", + "type": "itemstacks" + } + ] + }, + "mcpe_adventure_settings": { + "id": "0xbc", + "online": "false", + "fields": [ + { + "name": "flags", + "type": "int" + } + ] + }, + "mcpe_tile_entity_data": { + "id": "0xbd", + "online": "false", + "fields": [ + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "namedtag", + "type": "nbt" + } + ] + }, + "mcpe_full_chunk_data": { + "id": "0xbf", + "online": "false", + "fields": [ + { + "name": "chunk_x", + "type": "int" + }, + { + "name": "chunk_z", + "type": "int" + }, + { + "name": "order", + "type": "byte" + }, + { + "name": "chunk_data_length", + "type": "int" + }, + { + "name": "chunk_data", + "type": "byte[]" + } + ] + }, + "mcpe_set_difficulty": { + "id": "0xc0", + "online": "false", + "fields": [ + { + "name": "difficulty", + "type": "int" + } + ] + }, + "mcpe_player_list": { + "id": "0xc3", + "online": "false", + "fields": [ + { + "name": "records", + "type": "playerrecords" + } + ] + }, + "mcpe_transfer": { + "id": "0x1b", + "online": "false", + "fields": [ + { + "name": "endpoint", + "type": "ipendpoint" + } + ] + }, + "mcpe_spawn_experience_orb": { + "id": "0xc5", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "count", + "type": "int" + } + ] + } + }, + "toClient": { + "id_connected_ping": { + "id": "0x00", + "online": "false", + "fields": [ + { + "name": "sendpingtime", + "type": "long" + } + ] + }, + "id_unconnected_ping": { + "id": "0x01", + "online": "false", + "fields": [ + { + "name": "ping_id", + "type": "long" + }, + { + "name": "offline_message_data_id", + "type": "offline_message_data_id" + } + ] + }, + "id_connected_pong": { + "id": "0x03", + "online": "false", + "fields": [ + { + "name": "sendpingtime", + "type": "long" + }, + { + "name": "sendpongtime", + "type": "long" + } + ] + }, + "id_unconnected_pong": { + "id": "0x1c", + "fields": [ + { + "name": "ping_id", + "type": "long" + }, + { + "name": "server_id", + "type": "long" + }, + { + "name": "offline_message_data_id", + "type": "offline_message_data_id" + }, + { + "name": "server_name", + "type": "string" + } + ] + }, + "id_open_connection_request_1": { + "id": "0x05", + "fields": [ + { + "name": "offline_message_data_id", + "type": "offline_message_data_id" + }, + { + "name": "raknet_protocol_version", + "type": "byte" + } + ] + }, + "id_open_connection_request_2": { + "id": "0x07", + "fields": [ + { + "name": "offline_message_data_id", + "type": "offline_message_data_id" + }, + { + "name": "clientendpoint", + "type": "ipendpoint" + }, + { + "name": "mtu_size", + "type": "short" + }, + { + "name": "client_guid", + "type": "long" + } + ] + }, + "id_new_incoming_connection": { + "id": "0x13", + "online": "false", + "fields": [ + { + "name": "cookie", + "type": "int" + }, + { + "name": "do_security", + "type": "byte" + }, + { + "name": "port", + "type": "short" + }, + { + "name": "session", + "type": "long" + }, + { + "name": "session2", + "type": "long" + } + ] + }, + "id_no_free_incoming_connections": { + "id": "0x14", + "online": "false", + "fields": [] + }, + "id_disconnection_notification": { + "id": "0x15", + "online": "false", + "fields": [] + }, + "id_connection_banned": { + "id": "0x17", + "online": "false", + "fields": [] + }, + "id_ip_recently_connected": { + "id": "0x1A", + "online": "false", + "fields": [] + }, + "mcpe_login": { + "id": "0x8f", + "online": "false", + "fields": [ + { + "name": "username", + "type": "string" + }, + { + "name": "protocol", + "type": "int" + }, + { + "name": "protocol2", + "type": "int" + }, + { + "name": "client_id", + "type": "long" + }, + { + "name": "client_uuid", + "type": "uuid" + }, + { + "name": "server_address", + "type": "string" + }, + { + "name": "client_secret", + "type": "string" + }, + { + "name": "skin", + "type": "skin" + } + ] + }, + "mcpe_add_player": { + "id": "0x96", + "online": "false", + "fields": [ + { + "name": "uuid", + "type": "uuid" + }, + { + "name": "username", + "type": "string" + }, + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "speed_x", + "type": "float" + }, + { + "name": "speed_y", + "type": "float" + }, + { + "name": "speed_z", + "type": "float" + }, + { + "name": "yaw", + "type": "float" + }, + { + "name": "head_yaw", + "type": "float" + }, + { + "name": "pitch", + "type": "float" + }, + { + "name": "item", + "type": "item" + }, + { + "name": "metadata", + "type": "metadatadictionary" + } + ] + }, + "mcpe_add_item_entity": { + "id": "0x9a", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "item", + "type": "item" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "speed_x", + "type": "float" + }, + { + "name": "speed_y", + "type": "float" + }, + { + "name": "speed_z", + "type": "float" + } + ] + }, + "mcpe_take_item_entity": { + "id": "0x9b", + "online": "false", + "fields": [ + { + "name": "target", + "type": "long" + }, + { + "name": "entity_id", + "type": "long" + } + ] + }, + "mcpe_move_entity": { + "id": "0x9c", + "online": "false", + "fields": [ + { + "name": "entities", + "type": "entitylocations" + } + ] + }, + "mcpe_move_player": { + "id": "0x9d", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "yaw", + "type": "float" + }, + { + "name": "head_yaw", + "type": "float" + }, + { + "name": "pitch", + "type": "float" + }, + { + "name": "mode", + "type": "byte" + }, + { + "name": "on_ground", + "type": "byte" + } + ] + }, + "mcpe_remove_block": { + "id": "0x9e", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "y", + "type": "byte" + } + ] + }, + "mcpe_update_block": { + "id": "0x9f", + "online": "false", + "fields": [ + { + "name": "blocks", + "type": "blockrecords" + } + ] + }, + "mcpe_add_painting": { + "id": "0xa0", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "direction", + "type": "int" + }, + { + "name": "title", + "type": "string" + } + ] + }, + "mcpe_level_event": { + "id": "0xa2", + "online": "false", + "fields": [ + { + "name": "event_id", + "type": "short" + }, + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + }, + { + "name": "data", + "type": "int" + } + ] + }, + "mcpe_tile_event": { + "id": "0xa3", + "online": "false", + "fields": [ + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "case_1", + "type": "int" + }, + { + "name": "case_2", + "type": "int" + } + ] + }, + "mcpe_entity_event": { + "id": "0xa4", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "event_id", + "type": "byte" + } + ] + }, + "mcpe_mob_effect": { + "id": "0xa5", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "event_id", + "type": "byte" + }, + { + "name": "effect_id", + "type": "byte" + }, + { + "name": "amplifier", + "type": "byte" + }, + { + "name": "particles", + "type": "byte" + }, + { + "name": "duration", + "type": "int" + } + ] + }, + "mcpe_update_attributes": { + "id": "0xa6", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "attributes", + "type": "playerattributes" + } + ] + }, + "mcpe_player_equipment": { + "id": "0xa7", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "item", + "type": "item" + }, + { + "name": "slot", + "type": "byte" + }, + { + "name": "selected_slot", + "type": "byte" + } + ] + }, + "mcpe_player_armor_equipment": { + "id": "0xa8", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "helmet", + "type": "item" + }, + { + "name": "chestplate", + "type": "item" + }, + { + "name": "leggings", + "type": "item" + }, + { + "name": "boots", + "type": "item" + } + ] + }, + "mcpe_interact": { + "id": "0xa9", + "online": "false", + "fields": [ + { + "name": "action_id", + "type": "byte" + }, + { + "name": "target_entity_id", + "type": "long" + } + ] + }, + "mcpe_use_item": { + "id": "0xaa", + "online": "false", + "fields": [ + { + "name": "blockcoordinates", + "type": "blockcoordinates" + }, + { + "name": "face", + "type": "byte" + }, + { + "name": "facecoordinates", + "type": "vector3" + }, + { + "name": "playerposition", + "type": "vector3" + }, + { + "name": "item", + "type": "item" + } + ] + }, + "mcpe_player_action": { + "id": "0xab", + "online": "false", + "fields": [ + { + "name": "entity_id", + "type": "long" + }, + { + "name": "action_id", + "type": "int" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + }, + { + "name": "face", + "type": "int" + } + ] + }, + "mcpe_hurt_armor": { + "id": "0xac", + "online": "false", + "fields": [ + { + "name": "health", + "type": "byte" + } + ] + }, + "mcpe_set_entity_motion": { + "id": "0xae", + "online": "false", + "fields": [ + { + "name": "entities", + "type": "entitymotions" + } + ] + }, + "mcpe_set_entity_link": { + "id": "0xaf", + "online": "false", + "fields": [ + { + "name": "rider_id", + "type": "long" + }, + { + "name": "ridden_id", + "type": "long" + }, + { + "name": "link_type", + "type": "byte" + } + ] + }, + "mcpe_animate": { + "id": "0xb2", + "online": "false", + "fields": [ + { + "name": "action_id", + "type": "byte" + }, + { + "name": "entity_id", + "type": "long" + } + ] + }, + "mcpe_respawn": { + "id": "0xb3", + "online": "false", + "fields": [ + { + "name": "x", + "type": "float" + }, + { + "name": "y", + "type": "float" + }, + { + "name": "z", + "type": "float" + } + ] + }, + "mcpe_drop_item": { + "id": "0xb4", + "online": "false", + "fields": [ + { + "name": "itemtype", + "type": "byte" + }, + { + "name": "item", + "type": "item" + } + ] + }, + "mcpe_container_open": { + "id": "0xb5", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "type", + "type": "byte" + }, + { + "name": "slot_count", + "type": "short" + }, + { + "name": "x", + "type": "int" + }, + { + "name": "y", + "type": "int" + }, + { + "name": "z", + "type": "int" + } + ] + }, + "mcpe_container_close": { + "id": "0xb6", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + } + ] + }, + "mcpe_container_set_slot": { + "id": "0xb7", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "slot", + "type": "short" + }, + { + "name": "unknown", + "type": "short" + }, + { + "name": "item", + "type": "item" + } + ] + }, + "mcpe_container_set_data": { + "id": "0xb8", + "online": "false", + "fields": [ + { + "name": "window_id", + "type": "byte" + }, + { + "name": "property", + "type": "short" + }, + { + "name": "value", + "type": "short" + } + ] + } + } +} \ No newline at end of file diff --git a/examples/client.js b/examples/client.js new file mode 100644 index 0000000..1a5b4dc --- /dev/null +++ b/examples/client.js @@ -0,0 +1 @@ +var mcpe = require('../'); \ No newline at end of file diff --git a/examples/server.js b/examples/server.js new file mode 100644 index 0000000..1a5b4dc --- /dev/null +++ b/examples/server.js @@ -0,0 +1 @@ +var mcpe = require('../'); \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..08a522a --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +module.exports = require('./dist/index.js'); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4f26562 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "pocket-minecraft-protocol", + "version": "0.1.0", + "description": "Parse and serialize Minecraft pocket edition packets.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "minecraft", + "pocket-edition", + "protocol" + ], + "author": "mhsjlw ", + "license": "MIT", + "dependencies": { + "babel-runtime": "^5.4.4", + "protodef": "0.2.2", + "xml2js": "0.4.16" + }, + "devDependencies": { + "gulp": "3.8.11", + "gulp-babel": "5.1.0", + "gulp-plumber": "1.0.1", + "gulp-sourcemaps": "1.3.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mhsjlw/pocket-minecraft-protocol.git" + }, + "bugs": { + "url": "https://github.com/mhsjlw/pocket-minecraft-protocol/issues" + }, + "homepage": "https://github.com/mhsjlw/pocket-minecraft-protocol#readme" +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..e69de29