Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FML3 improvements #28

Merged
merged 10 commits into from
Dec 31, 2023
Merged

Conversation

Mykola1453
Copy link
Contributor

@Mykola1453 Mykola1453 commented Aug 6, 2023

There are still come kinks, but here's my pull request for FML3.

Firstly, I compared fml3.json file with Forge source code, fixing mappings numbers in fml_handshake and adding description for ModData and ChannelMismatchData (not sure if needed, added just in case), and removing modCount and channelCount in ModListReply (not sure what it does, but having it breaks my version of forgeHandshake3.js) .

Secondly, forgeHandshake3.js file.

As I understand, @letschill's approach was to use messageId instead of discriminator to determine when to send an Acknowledgement Packet. However, the issue here is that sometimes it needs to send Acknowledgement to more messages than specified in the code. LetsChill's code worked perfectly with Forge and no mods, but when I started adding mods (for example, Biomes O' Plenty and other mods from Forstride), bot couldn't connect, the connection timed out. Only when I replaced if (data.messageId > 1 && data.messageId < 21) with if (data.messageId > 1 && data.messageId < 23) (so to send the packet to any message with ID from 2 to 22), it worked. I'm not sure why or how it works, seems arbitrary to me. After adding some other mods, I couldn't connect without upping that number again, so the number seems arbitrary too.

In short, I couldn't figure how to work with LetsChill's code and resorted to the use of forgeHandshake2.js as I understood it better. I used that file as a template, adding necessary changes to make it work with FML3. I'm not sure how critical, but it adds an error in server's console: [ne.mi.ne.HandshakeHandler/FMLHANDSHAKE]: Recieved unexpected index 0 in client reply. This doesn't seem to influence the bot, but the error is absent when using LetsChill's code (with changes above needed to connect), so there are benefits in using LetsChill's version of the file (if messageId can be figured out).

Another thing I couldn't figure is that both mine and LetsChill's code lead to this error, when trying to connect to the local game with some mods (like Mekanism ones) installed: Error: Deserialization error for play.toClient : Read error for undefined : unexpected tag end .... The error is absent when using the same mods, but on server instead of opening singleplayer to LAN. I'm sure there are other kinks, but those are ones I noticed.

Finally, I added examples of using mineflayer with FML3, one with the logic needed to connect to the server with SimpleLogin mod, one without it.

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
Not sure what ModCount and ChannelCount do in ModListReply, however I need to remove them to make forgeHandshake3.js work
@rom1504
Copy link
Member

rom1504 commented Aug 25, 2023

any thoughts @letschill ?

@PolyAnthi
Copy link

Do we have any updates on this? @rom1504 @letschill @Mykola1453

@PolyAnthi
Copy link

@rom1504 can we merge this?

@Maud-Pie
Copy link

Maud-Pie commented Dec 26, 2023

@Mykola1453
Using your branch with autoVersionForge gives this result to me:

Using forgeMods: []
other loginwrapperchannel quark:main received
{"translate":"multiplayer.disconnect.slow_login"} false

Fixing "other loginwrapperchannel quark:main received" error
Fixing "other loginwrapperchannel quark:main received" error
Fixing "other loginwrapperchannel quark:main received" error
@Mykola1453
Copy link
Contributor Author

Mykola1453 commented Dec 27, 2023

@Maud-Pie, thanks for noticing. My recent commits should have fixed this.

As it reads from your log, this is due to Quark mod. Since October (version 410+), the mod now sends a custom packet upon login and waits for a response from the client. If no response is given, mineflayer bot won't connect and gives a timed out error.

Using the mod's source code as reference, I fixed this error quickly. I just wrote so that the bot, upon receiving the Quark packet, sends acknowledgment.

I wasn't sure I had to modify forgeHandshake3.js and fml3.json files for this, given that it's mod behavior and not Forge's. However, this mod is quite popular, whereas the change is not that big and doesn't seem to break anything if there's no Quark mod. So while there may be a more elegant way to fix this, this works too.

@Mykola1453
Copy link
Contributor Author

Mykola1453 commented Dec 27, 2023

On an unrelated note, I also encountered an error with mineflayer itself, when I connected to a server with some mods. Specifically, with ...\mineflayer\lib\plugins\entities.js file and TeamAbnormals mods. Fix is a simple if statement around entity.type = entityData.type || 'object' line. I created mineflayer PR that does that PrismarineJS/mineflayer#3254

@rom1504
Copy link
Member

rom1504 commented Dec 31, 2023

merging

would be really great to have some CI here, otherwise it will keep breaking

@rom1504 rom1504 merged commit 53509d4 into PrismarineJS:master Dec 31, 2023
2 checks passed
@rom1504
Copy link
Member

rom1504 commented Dec 31, 2023

/makerelease

1 similar comment
@rom1504
Copy link
Member

rom1504 commented Dec 31, 2023

/makerelease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

4 participants