Cancelling PlayerTeleportEvent when farmland block converts to dirt makes the player instantly die
Expected behavior
When farmland block converts to a dirt block and a player is standing on it, cancelling PlayerTeleportEvent shouldn't cause the player to instantly die, but instead either not fire the PlayerTeleportEvent at all when pushing the player up or add another teleport cause (as right now the teleport cause is unknown) and make it so it cannot be cancelled (or just make it so the player doesn't die if cancelled).
Observed/Actual behavior
When farmland block converts to a dirt block and a player is standing on it and the PlayerTeleportEvent gets cancelled the player instantly dies (teleports in void?).
Steps/models to reproduce
- Make a dummy plugin which cancels PlayerTeleportEvent
- Give yourself a farmland block
- Jump on it
Plugin and Datapack List
Dummy plugin for cancelling the PlayerTeleportEvent
Paper version
This server is running Paper version 1.21.4-232-ver/1.21.4@12d8fe0 (2025-06-09T10:15:42Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.21-DEV-81bc9ba (MC: 1.21)
Other
This did not happen on version 1.21.1, but only when we switched to 1.21.4.
Can't confirm that the player immediately dies, but the behavior is definitely not correct either
https://github.com/user-attachments/assets/d7b1f173-bff9-450e-8ad6-fe1f1bc88b47
This server is running Paper version 1.21.4-232-ver/1.21.4@12d8fe0 (2025-06-09T10:15:42Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
The position I am teleported to is not consistent in x and z axis but pretty much always around 100 blocks above the previous y position
Also happens on 1.21.6, it seems like x and z get exponentially bigger. After a few attempts, the server crashed.
Interesting, the reason I said players were immediately dying is because it was teleporting them into void, instead of the air like it teleported you, but definitely this behavior isn't correct either way.
Can confirm, issue is in https://github.com/PaperMC/Paper/blob/4781d28b4b23839c125075c6f0d323e9585338e6/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch#L1029-L1035 the game passes all relative flags when teleporting up from farmland, so the PositionMoveRotation's position is actually a delta. When cancelling the event, the previous position is used as the new position, and with the relative position flags it means the position as a vector is added, so the result is the player is teleported away (twice the current distance to 0,0,0)
It appears I am also encountering this bug, but with snow layers, when cancelling the teleport event triggered by them naturally stacking to 2 or more (with the game rule snowAccumulationHeight >1).
The same code can replicate the issue using snow layers:
Standing in a biome that snows and waiting for long enough (or increasing random tick speed) will cause you to teleport to twice your current position.