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

Mobs build up fall damage when dangling on a lead

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 22w42a
    • Snapshot 13w16a, Snapshot 13w17a, Snapshot 13w18a, Snapshot 13w18b, Snapshot 13w19a, Snapshot 13w21a, Snapshot 13w21b, Minecraft 1.6.1, Minecraft 1.6.2, Minecraft 1.7.4, Minecraft 14w05b, Minecraft 14w06b, Minecraft 14w07a, Minecraft 14w08a, Minecraft 1.7.5, Minecraft 1.8-pre1, Minecraft 1.8-pre3, Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.3, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 1.10.2, Minecraft 16w43a, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12 Pre-Release 6, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 18w20c, Minecraft 18w22a, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w09a, Minecraft 19w13b, 1.14.4, 19w36a, 1.15.2, 20w20a, 1.16 Pre-release 2, 1.16.1, 20w27a, 20w28a, 20w29a, 1.16.2 Pre-release 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3, 1.16.4, 20w46a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w07a, 21w11a, 21w17a, 1.17.1, 21w40a, 21w41a, 21w42a, 21w43a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 2, 1.18 Pre-release 4, 1.18 Pre-release 5, 1.18 Pre-release 6, 1.18 Pre-release 8, 1.18 Release Candidate 3, 1.18, 1.18.1 Release Candidate 1, 1.18.1 Release Candidate 2, 1.18.1, 22w03a, 22w05a, 22w06a, 22w07a, 1.18.2, 22w11a, 22w12a, 22w15a, 22w17a, 22w19a, 1.19 Pre-release 1, 1.19 Pre-release 3, 1.19.1 Pre-release 5, 1.19.1 Release Candidate 2, 1.19.2
    • Confirmed
    • Mob behaviour
    • Normal

      The Bug

      Suspending mobs from leashes in the air then moving the fence post with a piston causes the mob to die when they hit the ground regardless of the height they fall.

      I expected the mob to survive a fall of 1-3 blocks in height, but to die from long falls.

      Instead the mob dies even if it only falls one block to the ground.

      1. Put a fence post up in the air at least high enough that it holds the mob off the ground by one or more blocks.
      2. Put a piston up against the fence post.
      3. Attach a mob to the fence post with a leash.
      4. Activate the piston moving the post.
      5. The leash will break.
      6. The mob will die.
        1. Additionally a player riding a saddled mob will die too (from MC-100443)

      This works at any fall height of 1 or greater.

      Code analysis and fix

      Code analysis and fix by PR0CESS in this comment.

      The problem lies in the method checkFallDamage() in net.minecraft.world.entity.Entity.java:

      net.minecraft.world.entity.Entity.java (Mojang mappings, 1.18-pre5, variable renamings)
      protected void checkFallDamage(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) {
              if (onGround) {
                  ...
                  }
                  this.resetFallDistance();
              } else if (heightDifference < 0.0) {
                  this.fallDistance = (float)((double)this.fallDistance - heightDifference);
              }
          }
      

      Fixed code:

      protected void checkFallDamage(...) {
              if (onGround) {
                  ...
                  }
                  this.resetFallDistance();
              } else if (heightDifference < 0.0D) {
                  this.fallDistance = (float)((double)this.fallDistance - heightDifference);
              } else if (heightDifference > 0.0D) {
                  //Add back in the heightDifference if going upwards
                  this.fallDistance = Math.max((float)((double) this.fallDistance - heightDifference),0);
              }
          }
      

            gnembon [Mojang] Gnembon
            ampolive [Mod] ampolive
            Votes:
            85 Vote for this issue
            Watchers:
            25 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: