mojira.dev
MC-3304

Enchantments from items held in the main hand are applied to other items when entities are killed

The Bug:

Enchantments from items held in the main hand are applied to other items when entities are killed.

Steps to Reproduce:

  1. Summon a husk, hold a bow in your offhand, and a sword enchanted with a high level of looting in your main hand, by using the commands provided below.

    /summon minecraft:husk ~ ~ ~ {NoAI:1b}
    /item replace entity @s weapon.offhand with minecraft:bow
    /item replace entity @s weapon.mainhand with minecraft:diamond_sword[enchantments={"minecraft:looting":100}]
  2. Shoot and kill the husk using the bow.

  3. Look if the looting enchantment on the sword affected the number of items that the husk dropped.

  4. Take note as to whether or not enchantments from items held in the main hand are applied to other items when entities are killed.

Observed Behavior:

Enchantments are applied to other items when entities are killed.

Expected Behavior:

Enchantments would not be applied to other items when entities are killed.

Potential Fix:

A potential fix by @unknown can be found in this comment.

Linked issues

Attachments

Comments 44

It also works if a mob is killed by a normal arrow (no flame effect) and you switch to a looting sword fast enough, and even works on deflected ghast fireballs (you can even deflect the fireball directly with the sword). It happens because the game checks the item you are holding at the time the mob dies, rather thank the item you killed the mob with.

Xristos Mpesiris

Correct, Chalmes, this is where I saw the bug from!

I didn't see anyone reporting it, so I reported it!

I was pretty sure that 1.4.6 Pre-Release would come either way!

The sooner these bugs are fixed the sooner I will get to play with my mods!

It doesn't matter if we have to get to Minecraft 1.4.10+ for that, as long as we get there faster!

Well, it is very useful, even though it is a bug.

This is a bug that people can take advantage of, so it should be set to private.

34 more comments

Mojang has never stated this is intended, and a priority has been assigned. The only reason the bedrock issue got fixed was because it was an unintentional change that broke parity, thus the change was reverted until they decide whether to actually INTENTIONALLY fix this, or keep this.
Just because people abuse a bug does not make it a feature.

 A possible solution is to cache the ItemStack that causes the action in the DamageSource instance that will be used to cause the damage and check for enchantments against this item instead of the player's currently held item. The DamageSource will also need to be cached for projectiles and written to NBT in case the world is closed before the damage is applied.

On second thought, the DamageSource likely doesn't need to be written to NBT for projectiles, saving the ItemStack to the projectile should suffice. The ItemStack can be passed to the DamageSource when needed.

Is there an actual reason to fix this? After this many years, it's a feature just like quasi connectivity is with redstone.

It's only a feature when Mojang says it's a feature, and that it has beentriaged actually speaks against that.
Old issue != by design.

In 23w33a

Xristos Mpesiris

Avoma

(Unassigned)

Confirmed

Platform

Low

Combat, Enchantments, Loot tables

Minecraft 1.4.4, Minecraft 1.4.7, Minecraft 1.5, Minecraft 1.6.1, Minecraft 1.6.2, ..., 1.21.2 Pre-Release 3, 1.21.3, 1.21.4, 25w08a, 1.21.5

Snapshot 13w26a

Retrieved