If a mob wielding a renamed weapon kills you, it's renamed weapon doesn't show in the death message.
What I expected to happen was...:
If any mob wielding a melee weapon (i.e. not a bow) that is renamed is spawned, and if you let the mob kill you, it should say: <player name> was slain by <name of mob> using <name of weapon>
What actually happened was...:
The death message was <player name> was slain by <name of mob>
Steps to Reproduce:
1. Enter this command into a command block and activate it:
/summon Zombie ~ ~1 ~ {CustomName:"Zombie test dummy",HandItems:[{id:"minecraft:diamond_sword",Count:1b,tag:{display:{Name:"This Sword",Lore:["This is a test!"]}}},{}]}/summon Zombie ~ ~1 ~ {CustomName:"Zombie test dummy",HandItems:[{id:"minecraft:diamond_sword",Count:1b,tag:{display:{Name:"This Sword",Lore:["This is a test!"]}}},{}]}2. Switch to survival or adventure and let the Zombie kill you.
3. The death message says: <player name> was slain by Zombie test dummy, as seen in Screenshot 1. But it should actually say <player name> was slain by Zombie test dummy using [This Sword]
An additional detail here is that if a Skeleton kills you with a renamed bow the death message works just fine, as seen in Screenshot 2. Test it with this command:
/summon Skeleton ~ ~1 ~ {CustomName:"Renamed Skeleton",HandItems:[{id:"minecraft:bow",Count:1b,tag:{display:{Name:"Renamed Bow",Lore:["This is also a test!"]}}},{}]}/summon Skeleton ~ ~1 ~ {CustomName:"Renamed Skeleton",HandItems:[{id:"minecraft:bow",Count:1b,tag:{display:{Name:"Renamed Bow",Lore:["This is also a test!"]}}},{}]}Code analysis by @unknown can be found in this comment.
Attachments
Comments 5
Please link to this comment in the description
The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.
The reason is that the death message is created in this way:
/**
* Gets the death message that is displayed when the player dies
*/
public IChatComponent getDeathMessage(EntityLivingBase p_151519_1_)
{
ItemStack var2 = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItem() : null;
String var3 = "death.attack." + this.damageType;
String var4 = var3 + ".item";
return var2 != null && var2.hasDisplayName() && StatCollector.canTranslate(var4) ? new ChatComponentTranslation(var4, new Object[] {p_151519_1_.getDisplayName(), this.damageSourceEntity.getDisplayName(), var2.getChatComponent()}): new ChatComponentTranslation(var3, new Object[] {p_151519_1_.getDisplayName(), this.damageSourceEntity.getDisplayName()});
}/**
* Gets the death message that is displayed when the player dies
*/
public IChatComponent getDeathMessage(EntityLivingBase p_151519_1_)
{
ItemStack var2 = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItem() : null;
String var3 = "death.attack." + this.damageType;
String var4 = var3 + ".item";
return var2 != null && var2.hasDisplayName() && StatCollector.canTranslate(var4) ? new ChatComponentTranslation(var4, new Object[] {p_151519_1_.getDisplayName(), this.damageSourceEntity.getDisplayName(), var2.getChatComponent()}): new ChatComponentTranslation(var3, new Object[] {p_151519_1_.getDisplayName(), this.damageSourceEntity.getDisplayName()});
}Because there is only death.attack.player.item but not death.attack.mob.item it uses the default death message when a mob kills a player using a melee weapon.
And please update the provided commands because the tags changed in the latest snapshots
/summon Zombie ~ ~1 ~ {CustomName:"Zombie test dummy",HandItems:[{id:"minecraft:diamond_sword",Count:1b,tag:{display:{Name:"This Sword",Lore:["This is a test!"]}}},{}]}/summon Zombie ~ ~1 ~ {CustomName:"Zombie test dummy",HandItems:[{id:"minecraft:diamond_sword",Count:1b,tag:{display:{Name:"This Sword",Lore:["This is a test!"]}}},{}]}/summon Skeleton ~ ~1 ~ {CustomName:"Renamed Skeleton",HandItems:[{id:"minecraft:bow",Count:1b,tag:{display:{Name:"Renamed Bow",Lore:["This is also a test!"]}}},{}]}/summon Skeleton ~ ~1 ~ {CustomName:"Renamed Skeleton",HandItems:[{id:"minecraft:bow",Count:1b,tag:{display:{Name:"Renamed Bow",Lore:["This is also a test!"]}}},{}]}Fixed in 18w01a, which added death.attack.mob.item. Note that 18w01a also changed mob names and item display names (but not lore) to use JSON text, but will only refuse to spawn the mob if the mob name is invalid JSON. If the item name is invalid JSON (MC-123807), you will get "[Diamond Sword]" in chat, which presumably is what happened to @unknown.
/summon zombie ~ ~1 ~ {CustomName:"{\"text\":\"Zombie test dummy\"}",HandItems:[{id:"minecraft:diamond_sword",Count:1b,tag:{display:{Name:"{\"text\":\"This Sword\"}",Lore:["This is a test!"]}}},{}]}/summon zombie ~ ~1 ~ {CustomName:"{\"text\":\"Zombie test dummy\"}",HandItems:[{id:"minecraft:diamond_sword",Count:1b,tag:{display:{Name:"{\"text\":\"This Sword\"}",Lore:["This is a test!"]}}},{}]}/summon skeleton ~ ~1 ~ {CustomName:"{\"text\":\"Renamed Skeleton\"}",HandItems:[{id:"minecraft:bow",Count:1b,tag:{display:{Name:"{\"text\":\"Renamed Bow\"}",Lore:["This is also a test!"]}}},{}]}/summon skeleton ~ ~1 ~ {CustomName:"{\"text\":\"Renamed Skeleton\"}",HandItems:[{id:"minecraft:bow",Count:1b,tag:{display:{Name:"{\"text\":\"Renamed Bow\"}",Lore:["This is also a test!"]}}},{}]}
Confirmed for
16w06a