Mojira Archive
MC-230719

Logged villager deaths don't use "death.fell.*" death messages, while named mob deaths do

When a villager falls from a high place, the death message logged is "Villager hit the ground too hard", maybe followed by "whilst trying to escape <player/mob>" if someone knocks him from a high place. This is the case even for climbable blocks. Named mob deaths which are now logged in 1.17.1 Pre-release 2 use "fell from a high place", "fell off a ladder" and so on.

How to reproduce:

  1. In the launcher, go to the settings and enable "Open output log when Minecraft: Java Edition starts".
  2. Launch any version above release 1.15.
  3. Enter a singleplayer world.
  4. Punch a villager off a platform 25 blocks high up in the air.
  5. Look at the log.

Expected result:

The villager's death message would contain the cause of its fall damage ("fell from a high place" or "fell off a ladder" or others like these).

Observed result:

The villager's death message was either "hit the ground too hard" or "hit the ground too hard whilst trying to escape <player/mob>".

Cause:

When a villager dies, Villager#die is run for that villager. That method is shown below.

public void die(DamageSource damageSource) {
   LOGGER.info("Villager {} died, message: '{}'", this, damageSource.getLocalizedDeathMessage(this).getString());
   Entity entity = damageSource.getEntity();
   if (entity != null) {
      this.tellWitnessesThatIWasMurdered(entity);
   }
   this.releaseAllPois();
   super.die(damageSource);
}

At the start of the method, a message with two arguments (pairs of curly braces) is printed to the console. The first argument is replaced by Villager#toString, while the second argument is replaced by damageSource.getLocalizedDeathMessage(this).getString(). This doesn't allow for the villager's CombatTracker to check for climbable blocks, and thus death messages for climbable blocks cannot appear. Named entities use this.getCombatTracker().getDeathMessage().getString() for the second argument instead, and this is what should be used for villagers as well.