mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-30 22:51:23 -04:00
fix packet test
This commit is contained in:
parent
d78d87b9fc
commit
88bb301693
@ -146,7 +146,7 @@ function getValue(_type, packet) {
|
|||||||
mc.supportedVersions.forEach(function(supportedVersion){
|
mc.supportedVersions.forEach(function(supportedVersion){
|
||||||
var mcData=require("minecraft-data")(supportedVersion);
|
var mcData=require("minecraft-data")(supportedVersion);
|
||||||
var version=mcData.version;
|
var version=mcData.version;
|
||||||
var packets = mcData.protocol.states;
|
var packets = mcData.protocol;
|
||||||
|
|
||||||
describe("packets "+version.minecraftVersion, function() {
|
describe("packets "+version.minecraftVersion, function() {
|
||||||
var client, server, serverClient;
|
var client, server, serverClient;
|
||||||
@ -158,9 +158,9 @@ mc.supportedVersions.forEach(function(supportedVersion){
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
client = new Client(false,version.minecraftVersion);
|
client = new Client(false,version.minecraftVersion);
|
||||||
client.setSocket(net.connect(25565, 'localhost'));
|
client.setSocket(net.connect(45000, 'localhost'));
|
||||||
});
|
});
|
||||||
server.listen(25565, 'localhost');
|
server.listen(45000, 'localhost');
|
||||||
});
|
});
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
client.on('end', function() {
|
client.on('end', function() {
|
||||||
@ -169,24 +169,17 @@ mc.supportedVersions.forEach(function(supportedVersion){
|
|||||||
});
|
});
|
||||||
client.end();
|
client.end();
|
||||||
});
|
});
|
||||||
var packetName, packetInfo, field;
|
var packetInfo, field;
|
||||||
for(var state in packets) {
|
Object.keys(packets).filter(function(state){return state!="types"}).forEach(function(state){
|
||||||
if(!packets.hasOwnProperty(state)) continue;
|
Object.keys(packets[state]).forEach(function(direction){
|
||||||
for(packetName in packets[state].toServer) {
|
Object.keys(packets[state][direction].types).filter(function(packetName){return packetName!="packet"}).forEach(function(packetName){
|
||||||
if(!packets[state].toServer.hasOwnProperty(packetName)) continue;
|
packetInfo = packets[state][direction].types[packetName][1];
|
||||||
packetInfo = packets[state]["toServer"][packetName].fields;
|
packetInfo=packetInfo ? packetInfo : null;
|
||||||
packetInfo=packetInfo ? packetInfo : null;
|
it(state + ","+(direction=="toServer" ? "Server" : "Client")+"Bound," + packetName,
|
||||||
it(state + ",ServerBound," + packetName,
|
callTestPacket(packetName.substr(7), packetInfo, state, direction=="toServer" ));
|
||||||
callTestPacket(packetName, packetInfo, state, true));
|
});
|
||||||
}
|
});
|
||||||
for(packetName in packets[state].toClient) {
|
});
|
||||||
if(!packets[state].toClient.hasOwnProperty(packetName)) continue;
|
|
||||||
packetInfo = packets[state]["toClient"][packetName].fields;
|
|
||||||
packetInfo=packetInfo ? packetInfo : null;
|
|
||||||
it(state + ",ClientBound," + packetName,
|
|
||||||
callTestPacket(packetName, packetInfo, state, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function callTestPacket(packetName, packetInfo, state, toServer) {
|
function callTestPacket(packetName, packetInfo, state, toServer) {
|
||||||
return function(done) {
|
return function(done) {
|
||||||
client.state = state;
|
client.state = state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user