The Bug:
Holding items enchanted with thorns in your hand works as if you were wearing them.
Steps to Reproduce:
Switch into survival mode and hold an item enchanted with thorns by using the command provided below.
/item replace entity @s weapon.mainhand with minecraft:golden_helmet{Enchantments:[{id:"minecraft:thorns",lvl:3}]}
Summon an entity that will attack you, for example, a husk.
Let it damage you a couple of times.
Take note as to whether or not holding items enchanted with thorns in your hand works as if you were wearing them.
Observed Behavior:
Holding items enchanted with thorns in your hand works as if you were wearing them.
Expected Behavior:
Holding items enchanted with thorns in your hand would not work as if you were wearing them.
Code Analysis:
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 2
relates to 2
Attachments
Comments 19
Confirmed for
16w15b
Thorns is defined as enchantment for armor, but not for held items. This report is very likely valid
Please link to this comment in the description
The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
The reason why this happens is because the methods net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity)
and net.minecraft.enchantment.EnchantmentHelper.applyArthropodEnchantments(EntityLivingBase, Entity)
call both the method net.minecraft.entity.Entity.func_184209_aF()
which gets for players all items in armor and hand slots. This behaviour might be intended partwise but the developers should definitely have a look at it again because calling this method is probably not what they want considering that after this for players the enchantment influence is calculated again only for the mainhand (which was included already before).
The problem that the item enchanted with the Thorns enchantment is not damaged is because the method net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int)
tries to get the item which has the Thorns enchantment from all slots which can have this enchantment. As hand items cannot have this enchantment the item is null
and no item is damaged.
Can confirm this behavior in 21w41a. Here are some extra details regarding this problem.
The Bug:
Holding items enchanted with thorns in your hand works as if you were wearing them.
Steps to Reproduce:
Switch into survival mode and hold an item enchanted with thorns.
/item replace entity @s weapon.mainhand with minecraft:golden_helmet{Enchantments:[{id:"thorns",lvl:3}]}
Summon an entity that will attack you, for example, a husk.
Let it damage you a couple of times.
Take note as to whether or not holding items enchanted with thorns in your hand works as if you were wearing them.
Observed Behavior:
Holding items enchanted with thorns in your hand works as if you were wearing them.
Expected Behavior:
Holding items enchanted with thorns in your hand would not work as if you were wearing them.
This works for all types of gear and items.
If you get a hopper and give it a low movement speed tag (or something like that, I forgot what it exactly was) you can use them as spyglasses π.
I think this is intended.