Skip to content

Rewrite teleport reply position to fix riding teleport loop on 1.8 servers - #5041

Open
Packsolite wants to merge 3 commits into
ViaVersion:masterfrom
Packsolite:fix/1_8-riding-teleport-loop
Open

Packsolite wants to merge 3 commits into
ViaVersion:masterfrom
Packsolite:fix/1_8-riding-teleport-loop

Conversation

@Packsolite

@Packsolite Packsolite commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4748

Since 1.21.2, the client keeps its own position when it receives a teleport while riding and replies with that position instead of the teleport position. As from the protocol docs:

If the player is riding a vehicle, this packet has no effect, but both the Confirm Teleportation and Set Player Position and Rotation packets are still sent.

An 1.8 server, however, expects the reply at the teleport position and treats anything else as an "illegal" move and endlessly corrects the player. Each correction is another teleport, so client and server ping-pong until the client is kicked ("You are sending too many packets"). Clients before 1.21.1 applied the teleport even while riding, so this never happened before.

This PR implements a fix by remembering the position of every teleport sent to the client and rewriting the client's reply to it. This matches pre-1.21.2 behavior of the client.

Reproduced on Paper 1.8.8 with a 26.2 client (packet capture + server-side teleport-event log showing ~250 corrections/s until the kick, see #4748). With this change the loop no longer occurs and mount/dismount behaves normally.

Disclosure: Part of the research and implementation of this PR were AI assisted. I've reviewed and verified the results and any changes made.

…rvers

Since 1.21.2, clients keep their own position when receiving a teleport
while riding and reply with that instead of the teleport position. A 1.8
server expects the reply at the teleport position, treats anything else
as an illegal move, and endlessly corrects the player, eventually kicking
the client. Rewrite the reply position to the teleport position, which is
what pre-1.21.2 clients already reported.

Fixes ViaVersion#4748

@kennytv kennytv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The polling feels like it'll break on clients/servers with high latency, depending on where Via is installed? accept teleportation was added specifically made because of that

@Packsolite

Copy link
Copy Markdown
Contributor Author

The polling feels like it'll break on clients/servers with high latency, depending on where Via is installed? accept teleportation was added specifically made because of that

Can you elaborate please? In which scenario would it break?

@kennytv

kennytv commented Sep 20, 2026

Copy link
Copy Markdown
Member

The incoming player movement can be behind what the server is sending so you rewrite one movement to be "correct" and the next one is suddenly dozens of blocks away again

@Packsolite

Packsolite commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

The incoming player movement can be behind what the server is sending so you rewrite one movement to be "correct" and the next one is suddenly dozens of blocks away again

Well, that is exactly why I used a FIFO queue. If the server sends two teleports, the first position packet from the client will be rewritten to whichever teleport was sent first.
The only thing that might maybe happen is if the player is moving while already riding server-side, then receives the mount packet, and a few position packets are still in delivery, but that same desync can happen without this patch and will be corrected by the server with new teleport->position packets, which then will be rewritten. Even if they arrive a lot later, it might rewrite "the wrong" position packets, but the queue still de-dupes in the long run, because it doesn't really care which packet is correct and which isn't. For every "wrong" packet the server sends a new teleport, which will ultimately result in a correct rewrite even on very poor connections.

Do you still think that is an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[1.8 -> 1.21+] Packet spam when riding entities leads to clients being kicked

2 participants