mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-04 21:11:04 -05:00
Parse FML|HS discriminator byte using protodef
This commit is contained in:
parent
1d8332e2e8
commit
8018de5c29
1 changed files with 17 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
var mc = require('minecraft-protocol');
|
||||
var ProtoDef = require('protodef').ProtoDef;
|
||||
|
||||
if(process.argv.length < 4 || process.argv.length > 6) {
|
||||
console.log("Usage : node echo.js <host> <port> [<name>] [<password>]");
|
||||
|
@ -28,6 +29,19 @@ client.on('chat', function(packet) {
|
|||
client.write('chat', {message: msg});
|
||||
}
|
||||
});
|
||||
|
||||
var proto = new ProtoDef();
|
||||
// http://wiki.vg/User:Pokechu22/Forge#FML.7CHS_Packet_structure
|
||||
proto.addType('FML|HS', [
|
||||
'container',
|
||||
[
|
||||
{
|
||||
"name": "discriminator",
|
||||
"type": "byte"
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
||||
client.on('custom_payload', function(packet) {
|
||||
var channel = packet.channel;
|
||||
var data = packet.data;
|
||||
|
@ -37,5 +51,8 @@ client.on('custom_payload', function(packet) {
|
|||
console.log('Server-side registered channels:',channels);
|
||||
// TODO: do something?
|
||||
// expect: [ 'FML|HS', 'FML', 'FML|MP', 'FML', 'FORGE' ]
|
||||
} else if (channel === 'FML|HS') {
|
||||
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
||||
console.log('FML|HS',parsed);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue