mojira.dev
MC-152728

The player continues sprinting when performing actions that slow them down

The Bug:

The player continues sprinting when performing actions that slow them down.

There are certain actions that slow down the player's movement speed. When one of these actions is commenced while the player is sprinting, the player doesn't stop sprinting, and as a result of this, these actions don't slow the player down as much as if they weren't sprinting. The player is unable to start sprinting while one of these actions is active, and as such, this is not intentional.

Actions that slow down the player include:

  • Sneaking

  • Crawling

  • Eating or drinking

  • Using a spyglass

  • Blocking with a shield

  • Charging a bow or crossbow

  • Preparing to throw a trident

  • Using a goat horn

  • Flying with elytra

Steps to Reproduce:

  1. Obtain a shield, begin blocking with it and walk forwards a couple of blocks.

  2. Take note of how fast you're traveling.

  3. Begin sprinting and then start blocking with the shield.

  4. Take note of how fast you're traveling now compared to the speed at which you were traveling before.

  5. Take note as to whether or not the player continues sprinting when performing actions that slow them down

Observed Behavior:

The player continues to sprint. Although the player is slowed down, they are not slowed down to the speed they would be traveling if they were not sprinting.

Expected Behavior:

The player would stop sprinting and when using items, they would slow down to the same speed regardless of whether or not they were sprinting.

Code Analysis:

Code analysis by @unknown can be found below.

The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

net.minecraft.client.player.LocalPlayer.java

public class LocalPlayer extends AbstractClientPlayer {
   ...
   public void aiStep() {
      ...
      if (this.isUsingItem() && !this.isPassenger()) {
         this.input.leftImpulse *= 0.2F;
         this.input.forwardImpulse *= 0.2F;
         this.sprintTriggerTime = 0;
      }
      ...

If we look at the above class, we can see that when a player starts using an item, their movement speed is decreased by a fixed amount. This is evident through the following lines of code:

this.input.leftImpulse *= 0.2F;
this.input.forwardImpulse *= 0.2F;

However, this piece of code doesn't check if the player was sprinting when beginning to use an item, thus resulting in players continuing to sprint (and not being completely slowed down) when using items.

Linked issues

MC-153075 Sneaking when sprinting does not lower the FOV again Resolved MC-153150 Sprinting then sneaking is faster than walking then sneaking Resolved MC-153256 "sneak sprinting" Resolved MC-153765 Sprinting particles while shifting Resolved MC-153846 Running, then sneaking still creates particles Resolved

Attachments

Comments 55

Able to reproduce. OS is Windows 10 Home.
Video

Affects 1.14.2-pre4

Can confirm in 1.14.2-pre4 using Linux

Still in 1.14.2 (Release). Also, please add "FOV" be added to the title/description to make it easier to find this bug report.

The fov has nothing to do with the sprinting, it's just its symptom. The title is perfectly fine as "you sprint, you start sneaking, but don't actually stop sprinting"

45 more comments

For those interested here's a feedback post if you wish to discuss this. As the bug tracker is not the right place.

(If you can't log in look at pinned comment in WEB-6665 )

Bug fix has been reverted. See 25w04a's announcement article.

Bug hasn't reverted consistently. Flying with elytra not work as intended. It works like in versions with fixed bug
Wrote bug report about this problem https://bugs.mojang.com/browse/MC-279725

@Riflusso That is actually tracked under MC-279688

this bug isn't in 1.21.4 but it is in 25w04a

Juliner

Avoma

(Unassigned)

Confirmed

Platform

Normal

Player

mojang_internal_1

Minecraft 1.14.2 Pre-Release 3, Minecraft 1.14.2, Minecraft 1.14.3 Pre-Release 1, Minecraft 1.14.3 Pre-Release 2, 1.14.4, ..., 1.21.3, 25w04a, 25w08a, 1.21.5, 1.21.7

24w44a

Retrieved