mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 22:23:21 -04:00
some fixes for last protodef
This commit is contained in:
parent
a4db7a10a7
commit
3d3916bb93
@ -49,7 +49,7 @@
|
|||||||
"lodash.merge": "^4.3.0",
|
"lodash.merge": "^4.3.0",
|
||||||
"minecraft-data": "^2.11.0",
|
"minecraft-data": "^2.11.0",
|
||||||
"prismarine-nbt": "^1.0.0",
|
"prismarine-nbt": "^1.0.0",
|
||||||
"protodef": "^1.2.3",
|
"protodef": "^1.3.0",
|
||||||
"readable-stream": "^2.0.5",
|
"readable-stream": "^2.0.5",
|
||||||
"ursa-purejs": "^0.0.3",
|
"ursa-purejs": "^0.0.3",
|
||||||
"uuid-1345": "^0.99.6",
|
"uuid-1345": "^0.99.6",
|
||||||
|
@ -7,7 +7,7 @@ module.exports = function(client, options) {
|
|||||||
var proto = new ProtoDef();
|
var proto = new ProtoDef();
|
||||||
proto.addTypes(mcdata.protocol.types);
|
proto.addTypes(mcdata.protocol.types);
|
||||||
proto.addTypes(minecraft);
|
proto.addTypes(minecraft);
|
||||||
proto.addTypes({'registerarr': [readDumbArr, writeDumbArr, sizeOfDumbArr]});
|
proto.addType('registerarr',[readDumbArr, writeDumbArr, sizeOfDumbArr]);
|
||||||
|
|
||||||
client.registerChannel = registerChannel;
|
client.registerChannel = registerChannel;
|
||||||
client.unregisterChannel = unregisterChannel;
|
client.unregisterChannel = unregisterChannel;
|
||||||
|
@ -18,12 +18,18 @@ function recursiveAddTypes(protocol,protocolData,path)
|
|||||||
recursiveAddTypes(protocol,get(protocolData,path.shift()),path);
|
recursiveAddTypes(protocol,get(protocolData,path.shift()),path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const protocols={};
|
||||||
|
|
||||||
function createProtocol(state,direction,version,customPackets)
|
function createProtocol(state,direction,version,customPackets)
|
||||||
{
|
{
|
||||||
|
const key=state+";"+direction+";"+version;
|
||||||
|
if(protocols[key])
|
||||||
|
return protocols[key];
|
||||||
const proto = new ProtoDef();
|
const proto = new ProtoDef();
|
||||||
proto.addTypes(minecraft);
|
proto.addTypes(minecraft);
|
||||||
const mcData=require("minecraft-data")(version);
|
const mcData=require("minecraft-data")(version);
|
||||||
recursiveAddTypes(proto,merge(mcData.protocol,get(customPackets,[mcData.version.majorVersion])),[state,direction]);
|
recursiveAddTypes(proto,merge(mcData.protocol,get(customPackets,[mcData.version.majorVersion])),[state,direction]);
|
||||||
|
protocols[key]=proto;
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user