-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 15w39b, Minecraft 15w43c, Minecraft 15w44a, Minecraft 15w46a, Minecraft 16w02a, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.10.2, Minecraft 16w35a, Minecraft 16w41a, Minecraft 1.11.2, Minecraft 17w17a, Minecraft 17w17b, Minecraft 17w18a, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, 1.14.4, 1.15.1, 1.16 Pre-release 5, 1.16.1, 20w28a, 20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Pre-release 3, 1.16.2 Release Candidate 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 1, 1.16.4 Pre-release 2, 1.16.4 Release Candidate 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w07a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 1.17, 1.17.1, 21w37a, 21w39a, 1.18.1, 22w06a, 1.18.2, 22w14a, 1.19 Release Candidate 2, 1.19, 1.19.2, 1.19.3, 1.19.4, 1.20.1, 1.20.2 Pre-release 2, 1.20.2, 23w41a, 23w43a, 1.20.3, 1.20.4 Release Candidate 1, 1.20.4, 23w51b, 24w07a, 24w13a, 1.20.5
-
Confirmed
-
Text
-
Low
-
Platform
The death message of a dead player can show the name of an item which is unrelated to their death. For instance; this can occur when one player shoots another with a bow/crossbow, but then replaces the bow/crossbow in their main-hand with a different (renamed) item before the second player dies. The same can also be observed when the player has a bow in their off-hand, but a renamed item in their main hand. The general issue here being that the game does not properly detect the source of a death when choosing what item name to display, but instead uses the name of the item in the main hand (of the 'killer' player) upon death.
Steps to Reproduce:
- Get a renamed item:
/give @s dirt[minecraft:custom_name='{"text":"Custom Name","color":"red"}']
- Kill the player:
(Must be holding the renamed item when you do)/damage @p 20 minecraft:arrow by @p
Observed & Expected Behavior:
- The game will output the death message "[Player] was shot by [Player] using [Renamed Dirt Block]", despite dying to arrow damage.
- The death message would properly display the name of the item used to shoot the player. If a name is not applicable, it would give a vague message such as "[Player] shot [Player]"
Code Analysis:
This issue stems specifically from the return value of the getLocalizedDeathMessage() method in the DamageSource class.
As stated in the post, the game checks the name of the item the player is currently holding rather than the item used.
public Component getLocalizedDeathMessage(LivingEntity livingEntity) { String s = "death.attack." + this.type().msgId(); if (this.causingEntity == null && this.directEntity == null) { LivingEntity livingentity1 = livingEntity.getKillCredit(); String s1 = s + ".player"; return livingentity1 != null ? Component.translatable(s1, livingEntity.getDisplayName(), livingentity1.getDisplayName()) : Component.translatable(s, livingEntity.getDisplayName()); } else { Component component = this.causingEntity == null ? this.directEntity.getDisplayName() : this.causingEntity.getDisplayName(); Entity entity = this.causingEntity; ItemStack itemstack1; if (entity instanceof LivingEntity) { LivingEntity livingentity = (LivingEntity)entity; itemstack1 = livingentity.getMainHandItem(); } else { itemstack1 = ItemStack.EMPTY; } ItemStack itemstack = itemstack1; --- > ISSUE START return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? Component.translatable(s + ".item", livingEntity.getDisplayName(), component, itemstack.getDisplayName()) : Component.translatable(s, livingEntity.getDisplayName(), component); --- > ISSUE END } }
decompiled code via MCP Reborn
Old Description
This is the original description, when the issue was triaged:
When you kill another player with bow (In second hand) and you have a renamed item (A dirt block with name "Hello worrld" for example) the death message is:
player was shot by <Me> using [Item in main hand (EX: Hello World")
- is duplicated by
-
MC-91406 Incorrect death message with offhand bow and named item
- Resolved
-
MC-95728 Death Message shows weapon of default hand but not actual death-causing weapon of offhand
- Resolved
-
MC-98022 When killed with weapon in offhand, death message says you were killed by weapon in main hand
- Resolved
-
MC-100057 Off hand bow shots don't show bow name
- Resolved
-
MC-100484 Death Messages All messed Up!
- Resolved
-
MC-106809 Death Messages are Incorrect
- Resolved
-
MC-159033 Killing a player with a bow/crossbow in the offhand will announce that the player was killed with the item in the main hand
- Resolved
-
MC-164645 Death Note Shows Main Hand Item When Killed By Offhand Weapon
- Resolved
-
MC-222677 Dying to arrow damage while holding a renamed item causes the "shot by" death message to show incorrectly
- Resolved
-
MC-228391 I exploded myself with a axe
- Resolved
-
MC-229371 When killed in a TNT chain reaction caused by other player, the message displayed makes reference to whatever the "culprit" has in his/her hand
- Resolved
-
MC-245435 Death message shows player's held item instead of the bow if entity is killed with a TNT ignited by a fire arrow
- Resolved
-
MC-252444 Named Crossbow not shown in death message with another item in main hand
- Resolved
-
MC-255955 Killing someone with weapon in offhand returns chat message as if killed by item in mainhand
- Resolved
-
MC-259051 Explode death detects the exploder's tool only upon victim's death
- Resolved
-
MC-262086 Incorrect item in the death message
- Resolved
-
MC-264835 Wrong item in death message
- Resolved
-
MC-268032 Death messages from players killed by an area effect cloud created by another player do not display the correct information
- Resolved