[GH-ISSUE #2802] The death message shows the raw template with %1$s and %2$s instead of the names #700

Closed
opened 2026-11-02 15:41:14 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @levzzz5154 on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2802

What I did:

  • Died in a world and read the death message on the death screen.

What happened:

  • The death message shows the raw translation template with the placeholders in it, for example %1$s was shot by %2$s, instead of the names.

What I expected:

  • The death message should read like vanilla, with the player's name and what killed them: Player was shot by Zombie.

What I verified so far (the pinned 26.3 sources and the current main):

  • Vanilla resolves a translatable component in TranslatableContents.decomposeTemplate: every %N$s placeholder takes the component's Nth argument, and getArgument throws TranslatableFormatException when the component has no such argument. The caller then uses the whole template as it is. So a template that needs an argument the component does not carry shows as the raw template, with every placeholder in it, not only the missing one. Horizon's format_translation (crates/horizon-client-core/src/text.rs) does the same, and its test formats_like_translatable_contents pins that.
  • Vanilla builds the death message in CombatTracker.getDeathMessage -> DamageSource.getLocalizedDeathMessage: the victim's name is the first argument, the cause's name the second, and the kill credit uses the <id>.player variant. Horizon's CombatTracker.getDeathMessage (crates/horizon-client/src/game/combat.rs) follows that structure the same way.

So the placeholders mean the component that reaches the client has no argument for the placeholder the template needs. Where that argument is lost is what is still open: the local path (combat_death_message_for) passes the victim's name and the cause's name, and the no-cause case passes only the victim's name, which for a template like death.attack.arrow ("%1$s was shot by %2$s") is one argument short - vanilla shows the raw template in that case too.

A reproduction with the exact death and the client that shows it would help. Please add one (the report is from the Discord thread in the linked issue; the reporter plays in single player).

One smaller difference I noticed while reading it (not this report): vanilla uses the <id>.item variant of the message when the cause holds an item with a custom name (death.attack.arrow.item = "%1$s was shot by %2$s using %3$s"), and Horizon always uses the two-argument message.

Originally created by @levzzz5154 on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2802 **What I did:** - Died in a world and read the death message on the death screen. **What happened:** - The death message shows the raw translation template with the placeholders in it, for example `%1$s was shot by %2$s`, instead of the names. **What I expected:** - The death message should read like vanilla, with the player's name and what killed them: `Player was shot by Zombie`. **What I verified so far** (the pinned 26.3 sources and the current `main`): - Vanilla resolves a translatable component in `TranslatableContents.decomposeTemplate`: every `%N$s` placeholder takes the component's Nth argument, and `getArgument` **throws** `TranslatableFormatException` when the component has no such argument. The caller then uses the whole template as it is. So a template that needs an argument the component does not carry shows as the raw template, with **every** placeholder in it, not only the missing one. Horizon's `format_translation` (`crates/horizon-client-core/src/text.rs`) does the same, and its test `formats_like_translatable_contents` pins that. - Vanilla builds the death message in `CombatTracker.getDeathMessage` -> `DamageSource.getLocalizedDeathMessage`: the victim's name is the first argument, the cause's name the second, and the kill credit uses the `<id>.player` variant. Horizon's `CombatTracker.getDeathMessage` (`crates/horizon-client/src/game/combat.rs`) follows that structure the same way. **So the placeholders mean the component that reaches the client has no argument for the placeholder the template needs.** Where that argument is lost is what is still open: the local path (`combat_death_message_for`) passes the victim's name and the cause's name, and the no-cause case passes only the victim's name, which for a template like `death.attack.arrow` ("%1$s was shot by %2$s") is one argument short - vanilla shows the raw template in that case too. **A reproduction with the exact death and the client that shows it would help.** Please add one (the report is from the Discord thread in the linked issue; the reporter plays in single player). **One smaller difference I noticed while reading it** (not this report): vanilla uses the `<id>.item` variant of the message when the cause holds an item with a custom name (`death.attack.arrow.item` = "%1$s was shot by %2$s using %3$s"), and Horizon always uses the two-argument message.
Author
Owner

@ludovic111 commented on GitHub (Oct 27, 2026):

Claimed by John Pork on Discord, to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #2802).

<!-- gh-comment-id:6442770337 --> @ludovic111 commented on GitHub (Oct 27, 2026): Claimed by `John Pork` on Discord, to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #2802). <!-- kira:work -->
Author
Owner

@socksprox commented on GitHub (Oct 27, 2026):

🤖 Agent: Covered by open PR #2658 ("Draw the death screen cause with its styling").

<!-- gh-comment-id:6443371697 --> @socksprox commented on GitHub (Oct 27, 2026): 🤖 Agent: Covered by open PR #2658 ("Draw the death screen cause with its styling").
Author
Owner

@levzzz5154 commented on GitHub (Oct 27, 2026):

🤖 Agent: the difference I found while reading the death message is now fixed in #2821 (my pull request): vanilla's DamageSource.getLocalizedDeathMessage uses the <id>.item message with three arguments - the victim's name, the cause's name and the item's name - when the cause holds an item with a custom name, and Horizon always used the two-argument message, so the item was never named. The pull request keeps the custom name of a mob's main hand item and picks the message and its arguments from it.

The other half of this report is answered here as well, and it is not a bug in Horizon: the raw template is vanilla's own behaviour for a component whose template needs an argument the component does not carry. TranslatableContents.getArgument throws TranslatableFormatException for a missing argument, and the caller then uses the whole template as it is - every placeholder in it, not only the missing one. Horizon's format_translation does the same, and its test formats_like_translatable_contents pins it. So the placeholders mean the component that reached the client had no argument for the placeholder its template needs; the issue asks for the exact death and the client that shows it, and that part stays open.

Vanilla classes and methods: net.minecraft.world.damagesource.DamageSource#getLocalizedDeathMessage, net.minecraft.world.damagesource.CombatTracker#getDeathMessage, net.minecraft.world.item.ItemStack#hasCustomName, net.minecraft.network.chat.contents.TranslatableContents#decomposeTemplate and #getArgument.

<!-- gh-comment-id:6443458756 --> @levzzz5154 commented on GitHub (Oct 27, 2026): 🤖 Agent: the difference I found while reading the death message is now fixed in #2821 (my pull request): vanilla's `DamageSource.getLocalizedDeathMessage` uses the `<id>.item` message with three arguments - the victim's name, the cause's name and the item's name - when the cause holds an item with a custom name, and Horizon always used the two-argument message, so the item was never named. The pull request keeps the custom name of a mob's main hand item and picks the message and its arguments from it. The other half of this report is answered here as well, and it is not a bug in Horizon: the raw template is **vanilla's own** behaviour for a component whose template needs an argument the component does not carry. `TranslatableContents.getArgument` throws `TranslatableFormatException` for a missing argument, and the caller then uses the whole template as it is - every placeholder in it, not only the missing one. Horizon's `format_translation` does the same, and its test `formats_like_translatable_contents` pins it. So the placeholders mean the component that reached the client had no argument for the placeholder its template needs; the issue asks for the exact death and the client that shows it, and that part stays open. Vanilla classes and methods: `net.minecraft.world.damagesource.DamageSource#getLocalizedDeathMessage`, `net.minecraft.world.damagesource.CombatTracker#getDeathMessage`, `net.minecraft.world.item.ItemStack#hasCustomName`, `net.minecraft.network.chat.contents.TranslatableContents#decomposeTemplate` and `#getArgument`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#700
No description provided.