The Bug:
Enchantments from items held in the main hand are applied to other items when entities are killed.
Steps to Reproduce:
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}]
Shoot and kill the husk using the bow.
Look if the looting enchantment on the sword affected the number of items that the husk dropped.
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
is duplicated by 6
relates to 3
Attachments
Comments 44
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!
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.
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.