The explosion caused by the "explode" entity effect doesn't appear to correctly attribute the explosion to the player.
This means that mobs killed by the explosion don't drop xp or loot that is specific to player kills (i.e. spider eyes).
Steps to Reproduce:
Add the attached data pack (
) to your world to add the
bugtest:explosive
enchantment to bows. The definition for this enchantment is provided in
.
Enchant a bow with the custom enchantment (using an enchanted book from the creative inventory)
Fire the bow at a mob
Have the explosion damage a hostile mob, iron golems, or the player
Observed Results:
Damage, and credit for any kills, from the explosion is attributed to the affected mob, so no XP is dropped. Passive Iron golems damaged by the explosion will attack the victim of the original attack, and not the player.
Expected Results:
The attribute_to_user field says that the explosion should be attributed to the user, in this case the player. Enemies damaged by the explosion should become hostile to the player, and XP should be dropped on kill.
Attachments
Comments 10
Please update your steps to reproduce to include all the necessary commands I need to reproduce your issue.
Apologies for the confusion, I omitted some information about the enchantment I thought was unnecessary.
The issue comes from a custom data-driven enchantment. The .json file I attached when I made the post is the custom enchantment from the data pack I created that was used to discover the issue.
To reproduce the issue, you'll need to add the file to an "enchantment" folder in a data pack. The enchantment will show up in the creative inventory as "Explosive" and can be applied to a bow normally using an anvil.
If you'd like me to include the full data pack I can. it's a pack I'm using to test the data-driven enchantments.
I can confirm this, however for me the enchantment works a bit weirdly in general. It seems like any items nearby get always destroyed by the explosion for some reason, and additionally the particles don't seem to be displaying correctly; those might be separate bugs though.
Changing the damage type of the explosion to something else (I tried minecraft:player_explosion
and minecraft:indirect_magic
) does not impact this at all, the bug still happens.
I've also attached a simple data pack containing the provided custom enchantment only.
I've removed your additional note, since it describes the expected death messages (the kill is attributed to the iron golem, so it is intended that the iron golem will be included in the death message when the damage type is player_explosion
) and not an actual part of the bug.
you'll have to excuse me if I've missed something, as I am not a professional coder, but I wrote the note under the impression that the change in death message might indicate a possible issue, as I figured that the death message would be the same. Unless explosion damage always writes as "blew up" without attributing a cause, and player explosion takes an extra step to specify the attacking entity.
You hit the nail in the head. Your last sentence is absolutely correct; the death message for explosion
is always "[player] blew up", while the death message for player_explosion
is always "[player] was blown up by [player/mob]".
I just added two pictures which show what the killfeed says when a player is killed by an explosion with damage type set to "player_explosion" when the "attribute to user" field is set to true or false. It appears to be the same in both: %1$s was blown up by %2$s
This was done on 1.21.3 by equipping a villager with armor enchanted with the "unstable" curse, and hitting the villager, triggering an explosion that kills the player.
Edit: I did not properly save the file during the test, resulting in an error. When properly saved, the explosion was correctly attributed to the Test villager. This may a result of the fact that the "enchanted" and "affected" entities are the same for this new enchantment. Maybe "attribute to user" is incorrectly pulling data from the "affected" field rather than the "enchanted" field?
Thank you for your report!
However, this issue has been temporarily closed as Awaiting Response.
Just a reminder, to make your bug report as effective as possible, please try and include the following steps to reproduce the problem:
If your ticket does not look like the example given here, then it's likely to be closed as Incomplete.
This ticket will automatically reopen when you reply.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki