From 3131172def48ed5732892b2868abd959652d9978 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 14:48:03 +0300 Subject: [PATCH 01/10] Update fml3.json Corrected mappings, as per https://github.com/MinecraftForge/MinecraftForge/blob/340d332e19a6d0200bbe1ad90683c2f3e35cb00c/src/main/java/net/minecraftforge/network/NetworkInitialization.java#L17 --- src/client/data/fml3.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/data/fml3.json b/src/client/data/fml3.json index 6848cbd..6796f84 100644 --- a/src/client/data/fml3.json +++ b/src/client/data/fml3.json @@ -127,10 +127,10 @@ { "type": "varint", "mappings": { - "0": "ModList", - "1": "ModListReply", - "2": "ServerRegistry", - "3": "ConfigurationData", + "1": "ModList", + "2": "ModListReply", + "3": "ServerRegistry", + "4": "ConfigurationData", "5": "ModData", "6": "ChannelMismatchData", "99": "Acknowledgement" @@ -308,4 +308,4 @@ ] ] } -} \ No newline at end of file +} From a41538787ca8d93e9e20fa9b873a58a4524a1b2f Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 15:15:25 +0300 Subject: [PATCH 02/10] Update fml3.json (ModList) In ModList, dataPackRegistries should go after registers, having the same type as the latter. See https://github.com/MinecraftForge/MinecraftForge/blob/340d332e19a6d0200bbe1ad90683c2f3e35cb00c/src/main/java/net/minecraftforge/network/HandshakeMessages.java#L58 --- src/client/data/fml3.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/client/data/fml3.json b/src/client/data/fml3.json index 6796f84..a046c27 100644 --- a/src/client/data/fml3.json +++ b/src/client/data/fml3.json @@ -197,6 +197,24 @@ ] } ] + }, + { + "name": "dataPackRegistries", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "name", + "type": "string" + } + ] + ] + } + ] } ] ], From d4c99f5eceec981436abd070ff841f235a54322f Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 16:56:08 +0300 Subject: [PATCH 03/10] Update fml3.json (ModData and ChannelMismatchData) Not sure if needed, but just in case described ModData and ChannelMismatchData as given here https://github.com/MinecraftForge/MinecraftForge/blob/340d332e19a6d0200bbe1ad90683c2f3e35cb00c/src/main/java/net/minecraftforge/network/HandshakeMessages.java#L139 https://github.com/MinecraftForge/MinecraftForge/blob/340d332e19a6d0200bbe1ad90683c2f3e35cb00c/src/main/java/net/minecraftforge/network/HandshakeMessages.java#L325 --- src/client/data/fml3.json | 70 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/client/data/fml3.json b/src/client/data/fml3.json index a046c27..56776e8 100644 --- a/src/client/data/fml3.json +++ b/src/client/data/fml3.json @@ -316,9 +316,73 @@ } ] ], - "Acknowledgement": "void", - "ModData" : "void", - "ChannelMismatchData" : "void" + "ModData": [ + "container", + [ + { + "name": "mods", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "key", + "type": "string" + }, + { + "name": "value", + "type": [ + "container", + [ + { + "name": "first", + "type": "string" + }, + { + "name": "second", + "type": "string" + } + ] + ] + } + ] + ] + } + ] + } + ] + ], + "ChannelMismatchData": [ + "container", + [ + { + "name": "mismatchedChannelData", + "type": [ + "array", + { + "countType": "varint", + "type": [ + "container", + [ + { + "name": "first", + "type": "string" + }, + { + "name": "second", + "type": "string" + } + ] + ] + } + ] + } + ] + ], + "Acknowledgement": "void" } } ] From 1b09e466296bb521913e969b0a0db0b8bbfda031 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:03:38 +0300 Subject: [PATCH 04/10] Update forgeHandshake3.js I tried to work with LetsChill's version of forgeHandshake3.js, however there were some problems, so for the time being I opted to use forgeHandshake2.js file as a template, with minor revisions to reflect the changes from FML3 --- src/client/forgeHandshake3.js | 231 ++++++++++++++++++++++++++++------ 1 file changed, 195 insertions(+), 36 deletions(-) diff --git a/src/client/forgeHandshake3.js b/src/client/forgeHandshake3.js index 5537491..0d9afcc 100644 --- a/src/client/forgeHandshake3.js +++ b/src/client/forgeHandshake3.js @@ -1,16 +1,16 @@ const ProtoDef = require("protodef").ProtoDef; -const Client = require("minecraft-protocol").Client +const Client = require("minecraft-protocol").Client; const debug = require("debug")("minecraft-protocol-forge") // Channels const FML_CHANNELS = { LOGINWRAPPER: "fml:loginwrapper", - HANDSHAKE: "fml:handshake" + HANDSHAKE: "fml:handshake", }; const PROTODEF_TYPES = { LOGINWRAPPER: "fml_loginwrapper", - HANDSHAKE: "fml_handshake" + HANDSHAKE: "fml_handshake", }; // Initialize Proto @@ -43,25 +43,48 @@ proto.addTypes({ ], }); - - -proto.addProtocol(require("./data/fml3.json"), ["fml3"]) +proto.addProtocol(require("./data/fml3.json"), ["fml3"]); /** * FML3 handshake to the server. * ! There is no wiki for it. * @param {import('minecraft-protocol').Client} client client that is connecting to the server. * @param {{ -* forgeMods: Array. | undefined, -* channels: Object. | undefined, -* registries: Object. | undefined -* }} options -*/ + * forgeMods: Array. | undefined, + * channels: Object. | undefined, + * registries: Object. | undefined + * }} options + */ +module.exports = function (client, options) { + + const modNames = options.forgeMods; + const channels = options.channels; + const registries = options.registries; -module.exports = function (client) { + // passed to src/client/setProtocol.js, signifies client supports FML2/Forge client.tagHost = "\0FML3\0"; + debug("initialized FML3 handler"); + if (!modNames) { + debug("trying to guess modNames by reflecting the servers'") + } else { + debug("modNames:", modNames) + } + if (!channels) { + debug("trying to guess channels by reflecting the servers'") + } else { + Object.entries(channels).forEach((name, marker) => { + debug("channel", name, marker) + }) + } + if (!registries) { + debug("trying to guess registries by reflecting the servers'") + } else { + Object.entries(registries).forEach((name, marker) => { + debug("registry", name, marker) + }) + } - client.registerChannel("fml:loginwrapper", proto.types.fml_loginwrapper, false) + client.registerChannel('fml:loginwrapper', proto.types.fml_loginwrapper, false) // remove default login_plugin_request listener which would answer with an empty packet // and make the server disconnect us @@ -70,34 +93,170 @@ module.exports = function (client) { client.on("login_plugin_request", (data) => { - // 0: ModData // Ignore - // 1: ModList // Return Acknowledgement. + if (data.channel === "fml:loginwrapper") { + // parse buffer + const { data: loginwrapper } = proto.parsePacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + data.data + ); - // 2 -> 20 Registry Data Return Acknowledgement. - // 21: Configuration Return Acknowledgement. + if (!loginwrapper.channel) { + console.error(loginwrapper); + } - if (data.channel === "fml:loginwrapper") { - switch (data.messageId) { + switch (loginwrapper.channel) { + case "fml:handshake": + const { data: handshake } = proto.parsePacketBuffer( + PROTODEF_TYPES.HANDSHAKE, + loginwrapper.data + ); - // ModData - case (0): - break; - case (1): // I am not sure why. + let loginwrapperpacket = Buffer.alloc(0); + switch (handshake.discriminator) { + // respond with ModListResponse + case "ModList": + const modlist = handshake.data; - case (21): - let AcknowledgementPacket = proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { discriminator: "Acknowledgement" }); - let loginWrapperPacket = proto.createPacketBuffer(PROTODEF_TYPES.LOGINWRAPPER, { channel: FML_CHANNELS.HANDSHAKE, data: AcknowledgementPacket, }); - client.write("login_plugin_response", { messageId: data.messageId, data: loginWrapperPacket }); - break + const modlistreply = { + modNames, + channels: [], + registries: [] + } - default: - if (data.messageId > 1 && data.messageId < 21) { - let AcknowledgementPacket = proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { discriminator: "Acknowledgement" }); - let loginWrapperPacket = proto.createPacketBuffer(PROTODEF_TYPES.LOGINWRAPPER, { channel: FML_CHANNELS.HANDSHAKE, data: AcknowledgementPacket, }); - client.write("login_plugin_response", { messageId: data.messageId, data: loginWrapperPacket }); - break + if (!options.modNames) { + modlistreply.modNames = modlist.modNames + } + + if (!options.channels) { + for (const { name, marker } of modlist.channels) { + if (marker != 'FML3') { + modlistreply.channels.push({ name, marker }) + } + } + } else { + for (const channel in channels) { + modlistreply.channels.push({ + name: channel, + marker: channels[channel] + }) + } + } + + if (!options.registries) { + for (const { name } of modlist.registries) { + modlistreply.registries.push({ name, marker: '1.0' }) + } + } else { + for (const registry in registries) { + modlistreply.registries.push({ + name: registry, + marker: registries[registry] + }) + } + } + + const modlistreplypacket = proto.createPacketBuffer( + PROTODEF_TYPES.HANDSHAKE, + { + discriminator: "ModListReply", + data: modlistreply, + } + ); + + loginwrapperpacket = proto.createPacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + { + channel: FML_CHANNELS.HANDSHAKE, + data: modlistreplypacket, + } + ); + break; + + // this shouldn't happen + case "ModListReply": + throw Error("received clientbound-only ModListReply from server"); + + // respond with Ack + case "ServerRegistry": + const serverregistry = handshake.data; + loginwrapperpacket = proto.createPacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + { + channel: FML_CHANNELS.HANDSHAKE, + data: proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { + discriminator: "Acknowledgement", + data: {} + }), + } + ); + break; + + // respond with Ack + case "ConfigurationData": + const configurationdata = handshake.data; + loginwrapperpacket = proto.createPacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + { + channel: FML_CHANNELS.HANDSHAKE, + data: proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { + discriminator: "Acknowledgement", + data: {} + }), + } + ); + break; + + // respond with Ack + case "ModData": + const moddata = handshake.data; + loginwrapperpacket = proto.createPacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + { + channel: FML_CHANNELS.HANDSHAKE, + data: proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { + discriminator: "Acknowledgement", + data: {} + }), + } + ); + break; + + // respond with Ack ? + case "ChannelMismatchData": + const channelmismatchdata = handshake.data; + loginwrapperpacket = proto.createPacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + { + channel: FML_CHANNELS.HANDSHAKE, + data: proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { + discriminator: "Acknowledgement", + data: {} + }), + } + ); + break; + + // this shouldn't happen + case "Acknowledgement": + throw Error("received clientbound-only Acknowledgement from server"); } + + client.write("login_plugin_response", { + messageId: data.messageId, + data: loginwrapperpacket, + }); + break; + + default: + console.log( + "other loginwrapperchannel", + loginwrapper.channel, + "received" + ); + break; } + } else { + console.log("other channel", data.channel, "received"); } - }) -} \ No newline at end of file + }); +}; From 540abb8a9347241e7fe2646a79d0b02c6fd002ca Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:05:03 +0300 Subject: [PATCH 05/10] Update autoVersionForge.js --- src/client/autoVersionForge.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/autoVersionForge.js b/src/client/autoVersionForge.js index a79884e..2839308 100644 --- a/src/client/autoVersionForge.js +++ b/src/client/autoVersionForge.js @@ -30,7 +30,7 @@ module.exports = function (client, options) { var forgeMods = response.forgeData.mods; console.log('Using forgeMods:', forgeMods); - // Install the FML|HS plugin with the given mods + // Install the FML2 plugin with the given mods forgeHandshake2(client, { forgeMods }); }); @@ -39,6 +39,11 @@ module.exports = function (client, options) { return // not ours } - forgeHandshake3(client) - }) + // Use the list of Forge mods from the server ping, so client will match server + var forgeMods = response.forgeData.mods; + console.log('Using forgeMods:', forgeMods); + + // Install the FML3 plugin with the given mods + forgeHandshake3(client, { forgeMods }); + }); } From 7549c454263b63a5210511e6c62eb5f56d0a8518 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:08:05 +0300 Subject: [PATCH 06/10] Update fml3.json (ModListReply) Not sure what ModCount and ChannelCount do in ModListReply, however I need to remove them to make forgeHandshake3.js work --- src/client/data/fml3.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/client/data/fml3.json b/src/client/data/fml3.json index 56776e8..c347020 100644 --- a/src/client/data/fml3.json +++ b/src/client/data/fml3.json @@ -221,11 +221,6 @@ "ModListReply": [ "container", [ - { - "name": "modCount", - "type": "varint" - - }, { "name": "modNames", "type": [ @@ -236,11 +231,6 @@ } ] }, - { - "name": "channelCount", - "type": "varint" - - }, { "name": "channels", "type": [ From cd89971a7d84f65e61180dd0365c6cafed29d8ff Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:20:35 +0300 Subject: [PATCH 07/10] 1.19.2 examples --- examples/mineflayer_forge/mineflayer_forge.js | 40 +++++++++ examples/mineflayer_forge/package.json | 9 ++ .../mineflayer_forge.js | 41 +++++++++ .../mineflayer_forge_simplelogin/package.json | 9 ++ .../simplelogin.js | 84 +++++++++++++++++++ 5 files changed, 183 insertions(+) create mode 100644 examples/mineflayer_forge/mineflayer_forge.js create mode 100644 examples/mineflayer_forge/package.json create mode 100644 examples/mineflayer_forge_simplelogin/mineflayer_forge.js create mode 100644 examples/mineflayer_forge_simplelogin/package.json create mode 100644 examples/mineflayer_forge_simplelogin/simplelogin.js diff --git a/examples/mineflayer_forge/mineflayer_forge.js b/examples/mineflayer_forge/mineflayer_forge.js new file mode 100644 index 0000000..ac91e8c --- /dev/null +++ b/examples/mineflayer_forge/mineflayer_forge.js @@ -0,0 +1,40 @@ +// Usage: node mineflayer_forge.js +// Change values of host, port, username before using. Tested with 1.19.2 Minecraft offline server. + +var mineflayer = require('mineflayer') +var pathfinder = require('mineflayer-pathfinder') +var autoVersionForge = require('../../src/client/autoVersionForge') + +var host = "server's IP"; +var port = "server's port"; +var username = "bot's username"; + +var bot = mineflayer.createBot({ + version: false, + host: host, + port: port, + username: username, +}); + +// leave options empty for guessing, otherwise specify the mods, +// channels and registries manually (channels and registries are only +// relevant for fml2 handshake) +const options = { + forgeMods: undefined, + channels: undefined, +} + +// add handler +autoVersionForge(bot._client, options); + +bot.loadPlugin(pathfinder.pathfinder) +console.info('Started mineflayer') + +// set up logging +bot.on('connect', function () { + console.info('connected'); +}); + +bot.on('spawn', function () { + console.info('I spawned') +}) diff --git a/examples/mineflayer_forge/package.json b/examples/mineflayer_forge/package.json new file mode 100644 index 0000000..01ec710 --- /dev/null +++ b/examples/mineflayer_forge/package.json @@ -0,0 +1,9 @@ +{ + "name": "minecraft-protocol-forge-mineflayer-example", + "version": "0.0.0", + "private": true, + "dependencies": { + "minecraft-protocol": "^0.20.3" + }, + "description": "An example of using a minecraft-protocol-forge with mineflayer" +} diff --git a/examples/mineflayer_forge_simplelogin/mineflayer_forge.js b/examples/mineflayer_forge_simplelogin/mineflayer_forge.js new file mode 100644 index 0000000..cfe055d --- /dev/null +++ b/examples/mineflayer_forge_simplelogin/mineflayer_forge.js @@ -0,0 +1,41 @@ +// Usage: node mineflayer_forge.js +// Change values of host, port, username, sl_pwd before using. Tested with 1.19.2 Minecraft offline server with Simple Login mod. + +var mineflayer = require('mineflayer'); +var pathfinder = require('mineflayer-pathfinder'); +var autoVersionForge = require('../../src/client/autoVersionForge'); +var simplelogin = require('./simplelogin'); + +var host = "server's IP"; +var port = "server's port"; +var username = "bot's username"; + +var bot = mineflayer.createBot({ + version: false, + host: host, + port: port, + username: username, +}); + +// leave options empty for guessing, otherwise specify the mods. Don't forget to write your Simple Login password (any password, if you connect for the first time) +const options = { + forgeMods: undefined, + channels: undefined, + sl_pwd: "Simple Login password for your bot" +}; + +// add handler +autoVersionForge(bot._client, options); +simplelogin(bot._client,options); + +bot.loadPlugin(pathfinder.pathfinder); +console.info('Started mineflayer'); + +// set up logging +bot.on('connect', function () { + console.info('connected'); +}); + +bot.on('spawn', function () { + console.info('I spawned') +}); diff --git a/examples/mineflayer_forge_simplelogin/package.json b/examples/mineflayer_forge_simplelogin/package.json new file mode 100644 index 0000000..323bb79 --- /dev/null +++ b/examples/mineflayer_forge_simplelogin/package.json @@ -0,0 +1,9 @@ +{ + "name": "mineflayer-forge-simplelogin-example", + "version": "0.0.0", + "private": true, + "dependencies": { + "minecraft-protocol": "^0.20.3" + }, + "description": "An example of using a minecraft-protocol-forge with mineflayer and Simple Login password feature (a Forge mod aimed to protect offline servers)" +} diff --git a/examples/mineflayer_forge_simplelogin/simplelogin.js b/examples/mineflayer_forge_simplelogin/simplelogin.js new file mode 100644 index 0000000..4541fe4 --- /dev/null +++ b/examples/mineflayer_forge_simplelogin/simplelogin.js @@ -0,0 +1,84 @@ +// https://github.com/SeraphJACK/SimpleLogin/blob/mc-1.19/src/main/java/top/seraphjack/simplelogin/network/MessageLogin.java + +const Client = require("minecraft-protocol").Client; +const { SHA256 } = require('crypto-js'); + +const toBytes = (text) => { + const result = []; + for (let i = 0; i < text.length; i += 1) { + const hi = text.charCodeAt(i); + if (hi < 0x0080) { + // code point range: U+0000 - U+007F + // bytes: 0xxxxxxx + result.push(hi); + continue; + } + if (hi < 0x0800) { + // code point range: U+0080 - U+07FF + // bytes: 110xxxxx 10xxxxxx + result.push(0xC0 | hi >> 6, + 0x80 | hi & 0x3F); + continue; + } + if (hi < 0xD800 || hi >= 0xE000 ) { + // code point range: U+0800 - U+FFFF + // bytes: 1110xxxx 10xxxxxx 10xxxxxx + result.push(0xE0 | hi >> 12, + 0x80 | hi >> 6 & 0x3F, + 0x80 | hi & 0x3F); + continue; + } + i += 1; + if (i < text.length) { + // surrogate pair + const lo = text.charCodeAt(i); + const code = 0x00010000 + (hi & 0x03FF) << 10 | lo & 0x03FF; + // code point range: U+10000 - U+10FFFF + // bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + result.push(0xF0 | code >> 18, + 0x80 | code >> 12 & 0x3F, + 0x80 | code >> 6 & 0x3F, + 0x80 | code & 0x3F); + } else { + break; + } + } + return result; +}; + +function byte2Hex(bytes) { + const hexChars = []; + for (let i = 0; i < bytes.length; ++i) { + let hex = (bytes[i] & 0xff).toString(16); + if (hex.length === 1) { + hex = '0' + hex; + } + hexChars.push(hex); + } + return hexChars.join(''); +} + +function hash256(pwd) { + const hash = SHA256(pwd).toString(); + const hash_bytes = toBytes(hash); + const hash_hex = byte2Hex(hash_bytes); + return hash_hex; +}; + +/** + * Simple Login message to the server. + */ +module.exports = function (client, options) { + client.on("custom_payload", function (packet) { + if (packet.channel === "simplelogin:main") { + const sl_pwd = options.sl_pwd; + const hashedPassword = hash256(sl_pwd).toString(); + const len = Buffer.alloc(4); + const buffer = Buffer.concat([len, Buffer.from(hashedPassword, 'utf-8')]); + client.write('custom_payload', { + channel: 'simplelogin:main', + data: buffer, + }); + }; + }); +}; \ No newline at end of file From 2eb916850b5f2240a02845db1a1f555347274289 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:14:56 +0200 Subject: [PATCH 08/10] Update fml3.json Fixing "other loginwrapperchannel quark:main received" error --- src/client/data/fml3.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/data/fml3.json b/src/client/data/fml3.json index c347020..c3f8faa 100644 --- a/src/client/data/fml3.json +++ b/src/client/data/fml3.json @@ -133,6 +133,7 @@ "4": "ConfigurationData", "5": "ModData", "6": "ChannelMismatchData", + "98": "Quark", "99": "Acknowledgement" } } @@ -372,6 +373,7 @@ } ] ], + "Quark": "void", "Acknowledgement": "void" } } From 3a6a74ef72d4292b9060a236a08da582fc410de5 Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:21:26 +0200 Subject: [PATCH 09/10] Update forgeHandshake3.js Fixing "other loginwrapperchannel quark:main received" error --- src/client/forgeHandshake3.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/client/forgeHandshake3.js b/src/client/forgeHandshake3.js index 0d9afcc..f6d90dd 100644 --- a/src/client/forgeHandshake3.js +++ b/src/client/forgeHandshake3.js @@ -247,6 +247,37 @@ module.exports = function (client, options) { }); break; + case "quark:main": + const { data: quark_handshake } = proto.parsePacketBuffer( + PROTODEF_TYPES.HANDSHAKE, + loginwrapper.data + ); + + let quark_loginwrapperpacket = Buffer.alloc(0); + + switch (quark_handshake.discriminator) { + // respond with Ack + case "Quark": + const quark = quark_handshake.data; + quark_loginwrapperpacket = proto.createPacketBuffer( + PROTODEF_TYPES.LOGINWRAPPER, + { + channel: FML_CHANNELS.HANDSHAKE, + data: proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { + discriminator: "Acknowledgement", + data: {} + }), + } + ); + break; + } + + client.write("login_plugin_response", { + messageId: data.messageId, + data: q_loginwrapperpacket, + }); + break; + default: console.log( "other loginwrapperchannel", From 210526a30943b478c63b0c8badc53c17df36d00e Mon Sep 17 00:00:00 2001 From: Mykola1453 <69845760+Mykola1453@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:23:07 +0200 Subject: [PATCH 10/10] Update forgeHandshake3.js Fixing "other loginwrapperchannel quark:main received" error --- src/client/forgeHandshake3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/forgeHandshake3.js b/src/client/forgeHandshake3.js index f6d90dd..84d3e33 100644 --- a/src/client/forgeHandshake3.js +++ b/src/client/forgeHandshake3.js @@ -274,7 +274,7 @@ module.exports = function (client, options) { client.write("login_plugin_response", { messageId: data.messageId, - data: q_loginwrapperpacket, + data: quark_loginwrapperpacket, }); break;