-
-
Notifications
You must be signed in to change notification settings - Fork 839
Description
Expected Behavior
I expect the server to be able to send the client back to configuration and bring them back to play without issue.
Actual Behavior
The server recieves an invalid packet and disconnects the client.
Error message from an unmodified vanilla server
[13:50:31] [Server thread/INFO]: notmattw (9f36238e-bee0-3e4e-9404-44efe6986143) lost connection: Internal Exception: io.netty.handler.codec.DecoderException: Received unknown packet id 12
Also error message from a Minestom server
java.lang.IllegalStateException: Packet id 0x1d isn't registered!
at net.minestom.server.network.packet.PacketRegistry$PacketRegistryTemplate.packetInfo(PacketRegistry.java:482)
at net.minestom.server.network.packet.PacketReading.readPayload(PacketReading.java:210)
at net.minestom.server.network.packet.PacketReading.readFramedPacket(PacketReading.java:187)
Steps to Reproduce
Start velocity pointing at a vanilla server with debug commands enabled, eg
java -DMC_DEBUG_ENABLED -DMC_DEBUG_DEV_COMMANDS -jar server.jar nogui
- join the server through velocity
- Force yourself into the configuration state, eg
debugconfig config <your_username> - Force yourself back into the play state, eg
debugconfig unconfig <your_uuid> - Observe above error message in server logs and disconnect
- Become sad :-(
Note its easier to reproduce with some latency (eg 200ms), not sure if its required
Plugin List
No plugins on either velocity or server (vanilla server)
Velocity Version
running on commit 5320aae (from 26/1/26)
[13:58:54 INFO]: Velocity
[13:58:54 INFO]: Copyright 2018-2026 Velocity Contributors. Velocity is licensed under the terms of the GNU General Public License v3.
[13:58:54 INFO]: PaperMC - GitHub
Additional Information
I believe the issue is to do with the packet queue logic that occurs. When you enter config it starts queuing received play packets (most typically a tick end packet, 0xc). When the server sends a finish configuration packet, MinecraftConnection#setState is called which sends all those queued packets immediately. The result is the server receiving the play packets before the finish config ack from the client, and failing to parse them (it's still looking for play packets).
Im not sure if the fix is as simple as deleting the queuing mechanism or not, but it does not make sense to send play packets from before reconfiguring after the reconfiguration ends. They should be forwarded immediately or worst case dropped. Sending them after reconfig is likely to cause issues with any reasonable anticheat (eg imagine receiving an attack after reconfigured where you may be hundreds of blocks away from the person you 'attacked').