mojira.dev
MC-240399

Dying entities can make splashing/falling sounds

The bug

Dying entities can still make splashing/falling sounds, as if they were still alive. This could be intended.

To reproduce

  1. Create a new creative world and fly a few blocks above water/land.

  2. Execute the following command:

    /summon turtle ~ ~ ~ {Health:0}

Observed result

The mob makes sounds after dying.

Expected result

The mob would not make sounds after dying.

Code analysis

Using Mojang mappings (22w11a).

LivingEntity#causeFallDamage(...) does not check if the entity is alive in order to play the fall sounds:

...
    @Override
    public boolean causeFallDamage(float $$0, float $$1, DamageSource $$2) {
        boolean $$3 = super.causeFallDamage($$0, $$1, $$2);
        int $$4 = this.calculateFallDamage($$0, $$1);
        if ($$4 > 0) {
            this.playSound(this.getFallDamageSound($$4), 1.0f, 1.0f);
            this.playBlockFallSound();
            this.hurt($$2, (float)$$4);
            return true;
        }
        return $$3;
    }
...

A potential fix would be to replace if ($$4 > 0) with if ($$4 > 0 && this.isAlive()).

Linked issues

Attachments

Comments 3

ampolive

Very likely related to MC-1246.

Avoma

Can confirm in 1.19.

TomatoClownfish

Can confirm in 23w03a.

ampolive

(Unassigned)

Confirmed

Sound

dying

1.17.1, 21w43a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 2, ..., 23w03a, 1.19.4, 23w14a, 1.20 Release Candidate 1, 1.20

Retrieved