some fixes for last protodef

This commit is contained in:
Romain Beaumont 2017-02-26 19:46:17 +01:00
parent a4db7a10a7
commit 3d3916bb93
No known key found for this signature in database
GPG key ID: DB60E388B3BCF286
3 changed files with 8 additions and 2 deletions

View file

@ -49,7 +49,7 @@
"lodash.merge": "^4.3.0",
"minecraft-data": "^2.11.0",
"prismarine-nbt": "^1.0.0",
"protodef": "^1.2.3",
"protodef": "^1.3.0",
"readable-stream": "^2.0.5",
"ursa-purejs": "^0.0.3",
"uuid-1345": "^0.99.6",

View file

@ -7,7 +7,7 @@ module.exports = function(client, options) {
var proto = new ProtoDef();
proto.addTypes(mcdata.protocol.types);
proto.addTypes(minecraft);
proto.addTypes({'registerarr': [readDumbArr, writeDumbArr, sizeOfDumbArr]});
proto.addType('registerarr',[readDumbArr, writeDumbArr, sizeOfDumbArr]);
client.registerChannel = registerChannel;
client.unregisterChannel = unregisterChannel;

View file

@ -18,12 +18,18 @@ function recursiveAddTypes(protocol,protocolData,path)
recursiveAddTypes(protocol,get(protocolData,path.shift()),path);
}
const protocols={};
function createProtocol(state,direction,version,customPackets)
{
const key=state+";"+direction+";"+version;
if(protocols[key])
return protocols[key];
const proto = new ProtoDef();
proto.addTypes(minecraft);
const mcData=require("minecraft-data")(version);
recursiveAddTypes(proto,merge(mcData.protocol,get(customPackets,[mcData.version.majorVersion])),[state,direction]);
protocols[key]=proto;
return proto;
}