mojira.dev
MC-155509

Dying puffed pufferfish can still sting players

The bug

Puffed pufferfish can hurt the player even if it's dead.

How to reproduce

Summon a dying puffed pufferfish:

/summon minecraft:pufferfish ~ ~ ~ {Health:0f,PuffState:1}

→ ❌ Pufferfish can hurt the player while dying

Code analysis

Code analysis can be found in this comment.

Linked issues

Attachments

Comments 8

Confirmed in 1.16.1 and 20w28a.

Can confirm in 21w06a.

Can confirm in 1.17.1.

Can confirm in 1.18.1.

Code analysis (Mojang mappings, 21w11a): Pufferfish#playerTouch(Player) does not check if the pufferfish is alive before hurting the player. A potential fix would just require this check:

...
    @Override
    public void playerTouch(Player $$0) {
        if (this.isAlive()) {
            int $$1 = this.getPuffState();
            if ($$0 instanceof ServerPlayer && $$1 > 0 && $$0.hurt(DamageSource.mobAttack(this), (float)(1 + $$1))) {
                if (!this.isSilent()) {
                    ((ServerPlayer)$$0).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0f));
                }
                $$0.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * $$1, 0), this);
            }
        }
    }
...

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

noTEing1563

(Unassigned)

Confirmed

Mob behaviour

dying, pufferfish

Minecraft 1.14.3, 1.16.1, 20w28a, 1.16.2 Pre-release 1, 1.16.2 Release Candidate 1, ..., 1.19, 1.19.2, 1.19.3, 1.20.1, 23w35a

Retrieved