Skip to content

Sneak desync on vehicle dismount. 1.21.1 client -> 1.21.4 server (2) #1045

@Leymooo

Description

@Leymooo

'/viaversion dump' Output

https://dump.viaversion.com/90786427ea289d80bf955755d87e392371d2e7afe68635b874b48ef8d8be1031

Server/Client Error

Bug Description

#ead2c6f did not fix #1001 and desync still happen.

I did some debug and looks like client sends PLAYER_INPUT packet every tick when inside vehicle. And looks like due to some ping / delay the last player input is input with sneaking = true what overides sneaking = false sent from ClientboundPackets1_21_2.REMOVE_ENTITIES / SET_PASSANGERS.

[0] Server -> Client `Set passanger`
[1] Client -> Server `PLAYER_INPUT sneak = false`
[2] Client -> Server `PLAYER_INPUT sneak = true`    <- want to leave vehicle
     Via -> Server `PLAYER_COMMAND sneak = true`
[3] Server -> Client `SET_PASSENGERS/REMOVE_ENTITIES` <- Dismount player
     Via -> Server `PLAYER_COMMAND sneak = false`
[4] Client -> Server `PLAYER_INPUT sneak = true` <- Client still think it inside vehicle (and shift still pressed)
     Via -> Server `PLAYER_COMMAND sneak = true` <- Enables sneak server side  !! Desync happens here
[5] Client -> Server `PLAYER_INPUT sneak = true` <- Client still think it inside vehicle (and shift still pressed)
[6] Client Got Dismount packet and stops sending PLAYER_INPUT packets, the last one from client is with sneak = true

Looks like adding check for having ClientVehicleStorage fixes desync, but i am unsure how safe this fix and is there any downside effect for < 1.21.1 clients

             // Player input no longer sets the sneaking state on the server
             // Send the change separately if needed (= when in a vehicle and player commands aren't sent by the old client)
-            sendSneakingPlayerCommand(wrapper, sneaking);
+            if (wrapper.user().has(ClientVehicleStorage.class)) {
+                sendSneakingPlayerCommand(wrapper, sneaking);
+            }
         })
         protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_POS, wrapper -> {

Steps to Reproduce

  1. Log in with 1.21.1 client on 1.21.4 server
  2. Enter vehicle
  3. Press sneak to leave vehicle (press and release immediately).
  4. Sneak desync eventually should happen.

Expected Behavior

No desync

Additional Server Info

No response

Checklist

  • Via plugins are only running on EITHER the backend servers (e.g. Paper) OR the proxy (e.g. Velocity), not on both.
  • I have included a ViaVersion dump.
  • If applicable, I have included a paste (not a screenshot) of the error.
  • I have tried a build from https://ci.viaversion.com/ and the issue still persists.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions