Skip to content

PlayerList#respawn reuses ServerPlayer without resetting sprinting state or SPEED_MODIFIER_SPRINTING #14413

Closed

Description

@itskua

Expected behavior

When a player respawns or changes dimensions through PlayerList#respawn, player.isSprinting() should be false and Attributes.MOVEMENT_SPEED should not retain LivingEntity.SPEED_MODIFIER_SPRINTING, matching vanilla behavior where PlayerList#respawn constructs a new ServerPlayer instance.

Observed/Actual behavior

Because Paper reuses the existing ServerPlayer instance in PlayerList#respawn (ServerPlayer player = serverPlayer; // Paper - TODO - recreate instance), it manually resets sneaking via player.setShiftKeyDown(false), but never calls player.setSprinting(false) in PlayerList#respawn or ServerPlayer#reset.

In addition, ServerGamePacketListenerImpl#handlePlayerCommand ignores STOP_SPRINTING packets while !this.hasClientLoaded(). If a player dies or enters a portal while sprinting, player.isSprinting() remains true and SPEED_MODIFIER_SPRINTING (+30% movement speed) stays attached to Attributes.MOVEMENT_SPEED in sendAllPlayerInfo after respawn or dimension change.

Steps/models to reproduce

  1. Join a Paper server and start sprinting.
  2. While sprinting, die and respawn (or enter a Nether/End portal).
  3. Inspect player.isSprinting() and player.getAttribute(Attribute.MOVEMENT_SPEED).getModifiers() in PlayerRespawnEvent / PlayerPostRespawnEvent (or in the ClientboundUpdateAttributesPacket sent by PlayerList#sendAllPlayerInfo).
  4. Observe that isSprinting() is still true and minecraft:sprinting (0.3 ADD_MULTIPLIED_TOTAL) is still present on the respawned player until a new STOP_SPRINTING packet is received after ServerboundPlayerLoadedPacket.

Plugin and Datapack List

None

Paper version

This server is running Paper version 1.21.11-R0.1-SNAPSHOT (MC: 1.21.11 / 26.3)

Other

In paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch, right next to:

player.setShiftKeyDown(false);

calling:

player.setSprinting(false);

clears both the shared sprinting flag (setSharedFlag(3, false)) and SPEED_MODIFIER_SPRINTING on the reused ServerPlayer.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions