Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix camera desync

Open GliczDev opened this issue 2 months ago • 8 comments

Setting player's camera before they had sent ServerboundPlayerLoadedPacket desyncs it. This should fix it

GliczDev avatar Oct 19 '25 17:10 GliczDev

Where are you getting the player camera to have this happen? This seems xy, I donno.

Owen1212055 avatar Oct 19 '25 17:10 Owen1212055

when I teleport player to a different world and set camera directly after that (so player has not yet fully loaded the world, entities do not exist for them, so there's no entity to set camera to - I checked client code for that)

GliczDev avatar Oct 19 '25 17:10 GliczDev

Couldnt you instead run that logic in the PlayerClientLoadedWorldEvent instead of setting the entity in that spot? Just seems like a niche sort of case, but could be argued as a valid desync.

Owen1212055 avatar Oct 20 '25 15:10 Owen1212055

Couldnt you instead run that logic in the PlayerClientLoadedWorldEvent instead of setting the entity in that spot?

no, the event is not called on dimension change (which, imo, is wrong, because the packet is being sent on dimension change too).

either way, it is a desync and should be fixed in Paper, not with a plugin.

GliczDev avatar Oct 20 '25 15:10 GliczDev

Okay, the event not firing on dimension change is a bug due to paper reusing the player entity on dimension switch.

Owen1212055 avatar Oct 20 '25 15:10 Owen1212055

The issue is the spectator logic is VERY client state dependent and is prone to stuff like this.

Owen1212055 avatar Oct 20 '25 15:10 Owen1212055

I believe that the proper fix is to instead use the player ready event, and on Player#reset change clientLoaded. As the event is currently not fired on dimension change, which is a bug. This is due to the player instance being reused.

Owen1212055 avatar Nov 21 '25 18:11 Owen1212055

I believe that the proper fix is to instead use the player ready event, and on Player#reset change clientLoaded. As the event is currently not fired on dimension change, which is a bug. This is due to the player instance being reused.

@Owen1212055 are you sure it should be Player#reset? It doesn't seem to be called when teleporting to a different world with the API

GliczDev avatar Nov 22 '25 09:11 GliczDev