mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -04:00
Update client/forgeHandshake.js to be installable as module
This commit is contained in:
parent
0ab5b6150d
commit
069a79ba3e
@ -1,5 +1,5 @@
|
||||
var mc = require('minecraft-protocol');
|
||||
var fml = require('../../dist/client/forgeHandshake'); // TODO: separate module
|
||||
var forgeHandshake = require('../../dist/client/forgeHandshake'); // TODO: what's with 'dist' here?
|
||||
|
||||
if(process.argv.length < 4 || process.argv.length > 6) {
|
||||
console.log("Usage : node echo.js <host> <port> [<name>] [<password>]");
|
||||
@ -25,18 +25,13 @@ mc.ping({host, port}, function(err, response) {
|
||||
console.log('Using forgeMods:',forgeMods);
|
||||
|
||||
var client = mc.createClient({
|
||||
tagHost: '\0FML\0', // signifies client supports FML/Forge
|
||||
// Client/server mods installed on the client
|
||||
// if not specified, pings server and uses its list
|
||||
/*
|
||||
forgeMods:
|
||||
*/
|
||||
tagHost: '\0FML\0', // passed to src/client/setProtocol.js, signifies client supports FML/Forge TODO: refactor into src/client/forgeHandshake.js, let it set it, but earliest enough(pause)
|
||||
host: host,
|
||||
port: port,
|
||||
username: username,
|
||||
password: password
|
||||
});
|
||||
client.forgeMods = forgeMods; // for fmlHandshakeStep TODO: refactor
|
||||
forgeHandshake(client, {forgeMods});
|
||||
|
||||
client.on('connect', function() {
|
||||
console.info('connected');
|
||||
@ -57,13 +52,6 @@ mc.ping({host, port}, function(err, response) {
|
||||
}
|
||||
});
|
||||
|
||||
client.on('custom_payload', function(packet) {
|
||||
// TODO: channel registration tracking in NMP, https://github.com/PrismarineJS/node-minecraft-protocol/pull/328
|
||||
if (packet.channel === 'FML|HS') {
|
||||
fml.fmlHandshakeStep(client, packet.data);
|
||||
}
|
||||
});
|
||||
|
||||
client.on('forgeMods', function(mods) {
|
||||
console.log('Received forgeMods event:',mods);
|
||||
});
|
||||
|
@ -172,7 +172,7 @@ var FMLHandshakeClientState = {
|
||||
COMPLETE: 5,
|
||||
};
|
||||
|
||||
function fmlHandshakeStep(client, data)
|
||||
function fmlHandshakeStep(client, data, options)
|
||||
{
|
||||
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
||||
debug('FML|HS',parsed);
|
||||
@ -205,7 +205,7 @@ function fmlHandshakeStep(client, data)
|
||||
debug('Sending client modlist');
|
||||
var modList = proto.createPacketBuffer('FML|HS', {
|
||||
discriminator: 'ModList',
|
||||
mods: client.forgeMods || []
|
||||
mods: options.forgeMods || []
|
||||
});
|
||||
client.write('custom_payload', {
|
||||
channel: 'FML|HS',
|
||||
@ -263,6 +263,11 @@ function fmlHandshakeStep(client, data)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fmlHandshakeStep
|
||||
module.exports = function(client, options) {
|
||||
client.on('custom_payload', function(packet) {
|
||||
// TODO: channel registration tracking in NMP, https://github.com/PrismarineJS/node-minecraft-protocol/pull/328
|
||||
if (packet.channel === 'FML|HS') {
|
||||
fmlHandshakeStep(client, packet.data, options);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user