use new raknet which support customPackets, begin fixing the protocol.json

This commit is contained in:
Romain Beaumont 2016-04-04 23:29:24 +02:00
commit e00ccf1542
5 changed files with 40 additions and 17 deletions

View file

@ -3,7 +3,7 @@
"string": [
"pstring",
{
"countType":"short"
"countType":"i16"
}
],
"shapeless_recipe": [
@ -91,11 +91,11 @@
[
{
"name": "meta",
"type": "short"
"type": "i16"
},
{
"name": "id",
"type": "short"
"type": "i16"
},
{
"name": "result",
@ -108,11 +108,11 @@
[
{
"name": "id",
"type": "short"
"type": "i16"
},
{
"name": "meta",
"type": "short"
"type": "i16"
},
{
"name": "result",
@ -602,7 +602,36 @@
]
}
],
"packet": [
"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",
[
{

View file

@ -7,19 +7,11 @@ if(process.argv.length !=4) {
var server = pmp.createServer({
host: process.argv[2],
port: parseInt(process.argv[3])
port: parseInt(process.argv[3]),
name: 'MCPE;numerous-alpaca test server!;45 45;0.0.1;0;20'
});
server.on('connection', function(client) {
client.on('unconnected_ping', function(packet) {
client.write('unconnected_pong', {
pingID: packet.pingID,
serverID: 0,
magic: 0,
serverName: 'MCPE;numerous-alpaca test server!;45 45;0.0.1;0;20'
});
});
client.on('error', function(err) {
console.log(err.stack);
});

View file

@ -19,7 +19,7 @@
"dependencies": {
"prismarine-nbt": "^0.2.2",
"protodef": "^1.2.0",
"raknet": "^1.3.1"
"raknet": "^1.5.2"
},
"devDependencies": {},
"repository": {

View file

@ -9,6 +9,7 @@ function createClient(options) {
assert.ok(options.username, "username is required");
options.customPackets=require("../data/protocol");
var client=raknet.createClient(options);
client.username = options.username;

View file

@ -9,6 +9,7 @@ function createServer(options) {
19132;
var host = options.host || '0.0.0.0';
options.customPackets=require("../data/protocol");
var server = raknet.createServer(options);
server.name = options.name || "Minecraft Server";