Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-152728

The player continues sprinting when performing actions that slow them down

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w44a
    • 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, 19w35a, 19w38b, 19w39a, 19w40a, 19w41a, 1.15 Pre-release 1, 1.15 Pre-release 7, 1.15, 1.15.1, 1.15.1 Pre-release 1, 1.15.2 Pre-release 2, 1.15.2, 20w06a, 20w07a, 20w09a, 20w10a, 20w11a, 20w13b, 20w17a, 20w19a, 1.16 Pre-release 5, 1.16 Pre-release 7, 1.16 Pre-release 8, 1.16, 1.16.1, 20w27a, 1.16.2 Pre-release 1, 1.16.2 Release Candidate 1, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 1, 1.16.4 Pre-release 2, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w07a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w15a, 21w16a, 21w17a, 21w18a, 21w19a, 21w20a, 1.17 Pre-release 1, 1.17 Pre-release 3, 1.17 Pre-release 4, 1.17 Pre-release 5, 1.17 Release Candidate 1, 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 2, 1.17.1 Pre-release 3, 1.17.1 Release Candidate 1, 1.17.1, 21w37a, 21w38a, 21w39a, 21w41a, 21w42a, 21w43a, 1.18 Pre-release 1, 1.18, 1.18.1, 22w03a, 22w05a, 22w06a, 22w07a, 1.18.2 Release Candidate 1, 1.18.2, 22w12a, 22w17a, 22w19a, 1.19, 1.19.1, 1.19.2, 22w43a, 1.19.3, 23w07a, 1.19.4, 1.20 Pre-release 1, 1.20, 1.20.1, 1.20.4, 23w51b, 1.20.5 Release Candidate 3, 1.20.5, 1.20.6, 24w19b, 1.21 Release Candidate 1, 1.21, 1.21.3
    • Confirmed
    • Player
    • Important
    • Platform

      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 Avoma 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.

        1. MC-152728.mp4
          5.50 MB
          [Mod] Avoma
        2. MC-152728.png
          1.57 MB
          [Mod] Avoma

            rebeccakullenius [Mojang] Rebecca
            Avoma [Mod] Avoma
            Votes:
            105 Vote for this issue
            Watchers:
            45 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: