From 0b2550e20642a3ebca55e455c8b72312216c61b5 Mon Sep 17 00:00:00 2001 From: deathcap Date: Sat, 23 Jan 2016 18:17:18 -0800 Subject: [PATCH] Add forgeMods option, set to array of Forge modifications installed on client --- examples/client_forge/client_forge.js | 13 +++++++------ src/createClient.js | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/client_forge/client_forge.js b/examples/client_forge/client_forge.js index e4d9e0b..3dbc0bc 100644 --- a/examples/client_forge/client_forge.js +++ b/examples/client_forge/client_forge.js @@ -8,6 +8,12 @@ if(process.argv.length < 4 || process.argv.length > 6) { var client = mc.createClient({ forge: true, + // Client/server mods installed on the client + // TODO: send from ServerListPing packet + forgeMods: + [ + {modid:'IronChest', version:'6.0.121.768'} + ], host: process.argv[2], port: parseInt(process.argv[3]), username: process.argv[4] ? process.argv[4] : "echo", @@ -58,7 +64,6 @@ proto.addType('fml|hsMapper', ] ); -// TODO: refactor to use one big switch like https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/transforms/serializer.js#L21 proto.addType('FML|HS', [ "container", @@ -232,11 +237,7 @@ client.on('custom_payload', function(packet) { console.log('Sending client modlist'); var modList = proto.createPacketBuffer('FML|HS', { discriminator: 'ModList', - //mods: [] - // TODO: send from ServerListPing packet, allow customizing not hardcoding - mods: [ - {modid:'IronChest', version:'6.0.121.768'} - ] + mods: client.forgeMods || [] }); client.write('custom_payload', { channel: 'FML|HS', diff --git a/src/createClient.js b/src/createClient.js index 6fb1ba9..74ea962 100644 --- a/src/createClient.js +++ b/src/createClient.js @@ -45,6 +45,8 @@ function createClient(options) { var client = new Client(false,version.majorVersion); + client.forge = options.forge; + client.forgeMods = options.forgeMods; client.on('connect', onConnect); if(keepAlive) client.on('keep_alive', onKeepAlive); client.once('encryption_begin', onEncryptionKeyRequest);