azalea-rs / azalea

A collection of Rust crates for making Minecraft bots, clients, and tools.
https://azalea.matdoes.dev
MIT License
361 stars 48 forks source link

ServerboundHelloPacket leftover data issue #117

Closed 1zun4 closed 9 months ago

1zun4 commented 9 months ago

So if you try to parse a ServerboundHelloPacket, it will fail due to Leftover data after reading packet ServerboundHelloPacket: [186]

image

By disabling the debug assertions

[profile.dev]
debug-assertions = false

we can get a reading of the packet: 1zun4 (0185ac9d-5ec3-204e-9493-3b3b0b8f6c51) is attempting to join **.**.**.**:25565.

Looking at the UUID, we notice that the UUID was not read correctly. image

I will investigate this further and submit a pull request with a fix.

1zun4 commented 9 months ago

The reason for this issue is that they introduced writeOptional, which first writes a boolean and then proceeds to either write the UUID or not.

image image

This causes the UUID to be wrong and the length of the packet being off by 1.

1zun4 commented 9 months ago

It seems I am stupid enough to use the wrong branch, as this was already fixed by https://github.com/azalea-rs/azalea/blob/1.20.1/azalea-protocol/src/packets/login/serverbound_hello_packet.rs

1zun4 commented 9 months ago

Was this changed back in 1.20.2? When I understood correctly, the main branch is targeting protocol 764, which is 1.20.2.

1zun4 commented 9 months ago

Yes, indeed. It was changed back. I will therefore close this issue as I am embarrasing myself.

For my use-case I will have to pass the fitting struct depending on specific protocol number.