mojira.dev
MC-14167

Mobs build up fall damage when dangling on a lead

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 @unknown 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);
        }
    }

Linked issues

Comments 30

I've experimented this too.

I speculate that this happens because of suspended mobs accumulating fall distance (Like zombie pigman in lava lakes before)

Confirmed, but it does not only happen when you break leads, when you fly around with a tied mob, and you get the mob to the floor, it gets fall damage (and it mostly dies).

Confirmed with horses at least, kills them quickly, hope this gets fixed.

MisterSanderson

MC-14118 and MC-14167 are duplicates: boyh bug reports are about moving fences with pistons and then the lashed mob falling and dying.

20 more comments

Can confirm in 1.17.1.

Can confirm in 21w40a.

Confirmed for 1.18 pre-5

Working Fix

I added @unknown's fix to the bug description, using Mojang mappings. If I overlooked something, please let me know as I'm not a programmer.

In my opinion, this way of calculating fall damage is flawed and not realistic.

Instead, I propose calculating fall damage based on the velocity of the entity before hitting the ground. You can tune this calculation to replicate the current behaviour of 3 blocks = damage knowing Minecraft's gravitational constant.

This technique also allows Mojang to remove any specific slow-falling conditions as the impact velocity would not be high enough to inflict damage.

Argus Filch

ampolive

gnembon

Confirmed

Normal

Mob behaviour

fall-damage, leash

Snapshot 13w16a, Snapshot 13w17a, Snapshot 13w18a, Snapshot 13w18b, Snapshot 13w19a, ..., 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

22w42a

Retrieved