mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
some fixes for last protodef
This commit is contained in:
parent
a4db7a10a7
commit
3d3916bb93
3 changed files with 8 additions and 2 deletions
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue