Skip to content

Commit

Permalink
Better handling of other loginwrapperchannel (FML2, FML3) (#34)
Browse files Browse the repository at this point in the history
* Better handling of other loginwrapperchannel (FML2, FML3)

* Better handling of other loginwrapperchannel (FML2, FML3)

* Removed redundant code for Quark mod (FML3)

* Update forgeHandshake2.js

* Update forgeHandshake3.js

* More concise print
  • Loading branch information
Mykola1453 authored Mar 17, 2024
1 parent cbacbb5 commit 3a7f0ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 43 deletions.
2 changes: 0 additions & 2 deletions src/client/data/fml3.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
"4": "ConfigurationData",
"5": "ModData",
"6": "ChannelMismatchData",
"98": "Quark",
"99": "Acknowledgement"
}
}
Expand Down Expand Up @@ -373,7 +372,6 @@
}
]
],
"Quark": "void",
"Acknowledgement": "void"
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/client/forgeHandshake2.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,15 @@ module.exports = function (client, options) {
}

default:
console.log(
'other loginwrapperchannel',
loginwrapper.channel,
'received'
)
try {
console.log('other loginwrapperchannel', loginwrapper.channel, 'received, sending acknowledgement packet')
const AcknowledgementPacket = proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { discriminator: 'Acknowledgement' })
const loginWrapperPacket = proto.createPacketBuffer(PROTODEF_TYPES.LOGINWRAPPER, { channel: FML_CHANNELS.HANDSHAKE, data: AcknowledgementPacket })
client.write('login_plugin_response', { messageId: data.messageId, data: loginWrapperPacket })
break
} catch (error) {
console.error(error)
}
break
}
} else {
Expand Down
45 changes: 9 additions & 36 deletions src/client/forgeHandshake3.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,43 +246,16 @@ module.exports = function (client, options) {
break
}

case 'quark:main': {
const { data: quarkHandshake } = proto.parsePacketBuffer(
PROTODEF_TYPES.HANDSHAKE,
loginwrapper.data
)

let quarkLoginwrapperpacket = Buffer.alloc(0)
switch (quarkHandshake.discriminator) {
// respond with Ack
case 'Quark': {
quarkLoginwrapperpacket = 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: quarkLoginwrapperpacket
})
break
}

default:
console.log(
'other loginwrapperchannel',
loginwrapper.channel,
'received'
)
try {
console.log('other loginwrapperchannel', loginwrapper.channel, 'received, sending acknowledgement packet')
const AcknowledgementPacket = proto.createPacketBuffer(PROTODEF_TYPES.HANDSHAKE, { discriminator: 'Acknowledgement' })
const loginWrapperPacket = proto.createPacketBuffer(PROTODEF_TYPES.LOGINWRAPPER, { channel: FML_CHANNELS.HANDSHAKE, data: AcknowledgementPacket })
client.write('login_plugin_response', { messageId: data.messageId, data: loginWrapperPacket })
break
} catch (error) {
console.error(error)
}
break
}
} else {
Expand Down

0 comments on commit 3a7f0ea

Please sign in to comment.