mojira.dev
MC-241148

Named mobs hurt by water that die through a splash/lingering water bottle log death as "killed by magic"

The bug

Named mobs that are hurt by water that die through a splash water bottle log death as "killed by magic".

To reproduce

  1. Summon a named water-sensitive mob (blaze, enderman, strider, etc.):

    /summon minecraft:blaze ~ ~ ~ {NoAI:1b,Health:1.0f,CustomName:'{"text":"MC-241148"}'}
  2. Throw a splash water bottle at it.

  3. Look at the logs.

Observed result

Log says "MC-241148 was killed by <Player/Potion> using magic".

Expected result

Log uses an appropriate death message, or at least wouldn't mention "using magic", as there is no potion, just a water bottle.

Code analysis

In ThrownPotion#applyWater(), the DamageSource is "indirectMagic":

net.minecraft.world.entity.projectile.ThrownPotion.java (22w11a, Mojang mappings)

AABB $$0 = this.getBoundingBox().inflate(4.0, 2.0, 4.0);
        List<LivingEntity> $$1 = this.level.getEntitiesOfClass(LivingEntity.class, $$0, WATER_SENSITIVE);
        if (!$$1.isEmpty()) {
            for (LivingEntity $$2 : $$1) {
                double $$3 = this.distanceToSqr($$2);
                if (!($$3 < 16.0) || !$$2.isSensitiveToWater()) continue;
                $$2.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0f);
            }
        }
        ...

Linked issues

Comments 2

ampolive

(Unassigned)

Confirmed

Platform

Low

Debug

21w44a, 1.18 Pre-release 1, 1.18 Pre-release 2, 1.18 Pre-release 5, 1.18 Pre-release 6, ..., 23w04a, 1.20 Pre-release 4, 1.20.1, 1.20.4, 1.21

Retrieved