mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-30 06:30:39 -04:00
use protodef addProtocol
This commit is contained in:
parent
2610273529
commit
87768f5d76
@ -43,7 +43,7 @@
|
|||||||
"lodash.merge": "^4.3.0",
|
"lodash.merge": "^4.3.0",
|
||||||
"minecraft-data": "^2.14.0",
|
"minecraft-data": "^2.14.0",
|
||||||
"prismarine-nbt": "^1.0.0",
|
"prismarine-nbt": "^1.0.0",
|
||||||
"protodef": "^1.3.0",
|
"protodef": "^1.5.1",
|
||||||
"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",
|
||||||
|
@ -9,15 +9,6 @@ const states = require("../states");
|
|||||||
const merge=require("lodash.merge");
|
const merge=require("lodash.merge");
|
||||||
const get=require("lodash.get");
|
const get=require("lodash.get");
|
||||||
|
|
||||||
function recursiveAddTypes(protocol,protocolData,path)
|
|
||||||
{
|
|
||||||
if(protocolData===undefined)
|
|
||||||
return;
|
|
||||||
if(protocolData.types)
|
|
||||||
protocol.addTypes(protocolData.types);
|
|
||||||
recursiveAddTypes(protocol,get(protocolData,path.shift()),path);
|
|
||||||
}
|
|
||||||
|
|
||||||
const protocols={};
|
const protocols={};
|
||||||
|
|
||||||
function createProtocol(state,direction,version,customPackets)
|
function createProtocol(state,direction,version,customPackets)
|
||||||
@ -25,10 +16,10 @@ function createProtocol(state,direction,version,customPackets)
|
|||||||
const key=state+";"+direction+";"+version;
|
const key=state+";"+direction+";"+version;
|
||||||
if(protocols[key])
|
if(protocols[key])
|
||||||
return protocols[key];
|
return protocols[key];
|
||||||
const proto = new ProtoDef();
|
const proto = new ProtoDef(false);
|
||||||
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]);
|
proto.addProtocol(merge(mcData.protocol,get(customPackets,[mcData.version.majorVersion])),[state,direction]);
|
||||||
protocols[key]=proto;
|
protocols[key]=proto;
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user