mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-04 21:11:04 -05:00
fml console.log -> debug
This commit is contained in:
parent
f6ad1d8061
commit
2802ac9d2b
3 changed files with 11 additions and 25 deletions
|
@ -55,4 +55,7 @@ mc.ping({host, port}, function(err, response) {
|
||||||
client.write('chat', {message: msg});
|
client.write('chat', {message: msg});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
client.on('forgeMods', function(mods) {
|
||||||
|
console.log('Received forgeMods event:',mods);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,6 +56,7 @@ function createClient(options) {
|
||||||
client.on("set_compression", onCompressionRequest);
|
client.on("set_compression", onCompressionRequest);
|
||||||
if(client.forge) {
|
if(client.forge) {
|
||||||
client.on('custom_payload', function(packet) {
|
client.on('custom_payload', function(packet) {
|
||||||
|
// TODO: channel registration tracking in NMP
|
||||||
if (packet.channel === 'FML|HS') {
|
if (packet.channel === 'FML|HS') {
|
||||||
fml.fmlHandshakeStep(client, packet.data);
|
fml.fmlHandshakeStep(client, packet.data);
|
||||||
}
|
}
|
||||||
|
|
32
src/fml.js
32
src/fml.js
|
@ -1,5 +1,6 @@
|
||||||
var ProtoDef = require('protodef').ProtoDef;
|
var ProtoDef = require('protodef').ProtoDef;
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var debug = require('./debug');
|
||||||
|
|
||||||
var proto = new ProtoDef();
|
var proto = new ProtoDef();
|
||||||
// copied from ../../dist/transforms/serializer.js TODO: refactor
|
// copied from ../../dist/transforms/serializer.js TODO: refactor
|
||||||
|
@ -174,7 +175,7 @@ var FMLHandshakeClientState = {
|
||||||
function fmlHandshakeStep(client, data)
|
function fmlHandshakeStep(client, data)
|
||||||
{
|
{
|
||||||
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
||||||
console.log('FML|HS',parsed);
|
debug('FML|HS',parsed);
|
||||||
|
|
||||||
var fmlHandshakeState = client.fmlHandshakeState || FMLHandshakeClientState.START;
|
var fmlHandshakeState = client.fmlHandshakeState || FMLHandshakeClientState.START;
|
||||||
|
|
||||||
|
@ -201,7 +202,7 @@ function fmlHandshakeStep(client, data)
|
||||||
data: clientHello
|
data: clientHello
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Sending client modlist');
|
debug('Sending client modlist');
|
||||||
var modList = proto.createPacketBuffer('FML|HS', {
|
var modList = proto.createPacketBuffer('FML|HS', {
|
||||||
discriminator: 'ModList',
|
discriminator: 'ModList',
|
||||||
mods: client.forgeMods || []
|
mods: client.forgeMods || []
|
||||||
|
@ -218,7 +219,7 @@ function fmlHandshakeStep(client, data)
|
||||||
case FMLHandshakeClientState.WAITINGSERVERDATA:
|
case FMLHandshakeClientState.WAITINGSERVERDATA:
|
||||||
{
|
{
|
||||||
assert.ok(parsed.data.discriminator === 'ModList', `expected ModList in WAITINGSERVERDATA state, got ${parsed.data.discriminator}`);
|
assert.ok(parsed.data.discriminator === 'ModList', `expected ModList in WAITINGSERVERDATA state, got ${parsed.data.discriminator}`);
|
||||||
console.log('Server ModList:',parsed.data.mods);
|
debug('Server ModList:',parsed.data.mods);
|
||||||
// TODO: client/server check if mods compatible
|
// TODO: client/server check if mods compatible
|
||||||
client.fmlHandshakeState = FMLHandshakeClientState.WAITINGSERVERCOMPLETE;
|
client.fmlHandshakeState = FMLHandshakeClientState.WAITINGSERVERCOMPLETE;
|
||||||
break;
|
break;
|
||||||
|
@ -227,10 +228,10 @@ function fmlHandshakeStep(client, data)
|
||||||
case FMLHandshakeClientState.WAITINGSERVERCOMPLETE:
|
case FMLHandshakeClientState.WAITINGSERVERCOMPLETE:
|
||||||
{
|
{
|
||||||
assert.ok(parsed.data.discriminator === 'RegistryData', `expected RegistryData in WAITINGSERVERCOMPLETE, got ${parsed.data.discriminator}`);
|
assert.ok(parsed.data.discriminator === 'RegistryData', `expected RegistryData in WAITINGSERVERCOMPLETE, got ${parsed.data.discriminator}`);
|
||||||
console.log('RegistryData',parsed.data);
|
debug('RegistryData',parsed.data);
|
||||||
// TODO: support <=1.7.10 single registry, https://github.com/ORelio/Minecraft-Console-Client/pull/100/files#diff-65b97c02a9736311374109e22d30ca9cR297
|
// TODO: support <=1.7.10 single registry, https://github.com/ORelio/Minecraft-Console-Client/pull/100/files#diff-65b97c02a9736311374109e22d30ca9cR297
|
||||||
if (parsed.data.hasMore === false) {
|
if (parsed.data.hasMore === false) {
|
||||||
console.log('LAST RegistryData');
|
debug('LAST RegistryData');
|
||||||
|
|
||||||
writeAck(client, FMLHandshakeClientState.WAITINGSERVERCOMPLETE);
|
writeAck(client, FMLHandshakeClientState.WAITINGSERVERCOMPLETE);
|
||||||
client.fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
client.fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||||
|
@ -252,7 +253,7 @@ function fmlHandshakeStep(client, data)
|
||||||
assert.ok(parsed.data.phase === 3, `expected HandshakeAck phase COMPLETE, got ${parsed.data.phase}`);
|
assert.ok(parsed.data.phase === 3, `expected HandshakeAck phase COMPLETE, got ${parsed.data.phase}`);
|
||||||
|
|
||||||
writeAck(client, FMLHandshakeClientState.COMPLETE);
|
writeAck(client, FMLHandshakeClientState.COMPLETE);
|
||||||
console.log('HandshakeAck Complete!');
|
debug('HandshakeAck Complete!');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,25 +262,6 @@ function fmlHandshakeStep(client, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//var forgeMods; // = [ {modid:'IronChest', version:'6.0.121.768'} ];
|
|
||||||
/*
|
|
||||||
function injectForge(client) {
|
|
||||||
client.on('custom_payload', function(packet) {
|
|
||||||
var channel = packet.channel;
|
|
||||||
var data = packet.data;
|
|
||||||
|
|
||||||
if (channel === 'REGISTER') {
|
|
||||||
var channels = data.toString().split('\0');
|
|
||||||
console.log('Server-side registered channels:',channels);
|
|
||||||
// TODO: do something?
|
|
||||||
// expect: [ 'FML|HS', 'FML', 'FML|MP', 'FML', 'FORGE' ]
|
|
||||||
} else if (channel === 'FML|HS') {
|
|
||||||
fmlHandshakeStep(client, data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
fmlHandshakeStep
|
fmlHandshakeStep
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue