mojira.dev
MC-34661

Thorns enchantment causes double armor decay

Put the summary of the bug you're having here

What i expected to happen is a diamond chest plate that was enchanted with thorns 2 and protection 4 to last longer than any other diamond armor i had, since the durability is so much higher

What actually happened was...:
had the inventory screen up and also had the durability monitor up for armor. Armor that has the enchantment thorns of any kind, IF it affects the enemy with damage it drops the durability of the armor twice per hit rather than once. So a chest piece of diamond decayed completely before any of the others remotely were close to breaking even though it's durability is the highest of them all.

Steps to Reproduce:
1. get diamond armor, enchant a chest plate with thorns and turn on durabiliy monitor for items
2. go into creative and get some golden apples, use them to have high health regen and turn to survival
3. Watch enemies beat the crap out of you and notice that the durability of the chest piece drops by a factor of two after every hit by going to the inventory screen and scrolling over the chest piece while being hit.


Code analysis by @unknown in this comment

Linked issues

Comments 5

Simply because the Thorns effect (enemies getting hit when they touch you) causes durability damage.

So a skeleton shoots you with an arrow. You take damage and it does as well and it makes sense to degrade twice because of one arrow? Just because thorns is there shouldn't change the degrading, If it should, then enchantments in GENERAL should degrade all armor at double speed because protection doesn't drop double just because it absorbs the brunt of attacks sometimes. Nor does fire protection or blast protection or projectile protection. Just because the enchantment is functioning isn't a reason to say that, otherwise it needs to act like that for all enchantments. Thus, why i pointed it out as a bug.

As far as I'm aware, it uses one point of durability to take the hit, and another point to cause the damage back to the thing that hit you. It's documented, but without looking at the code, it's hard to tell if it's deliberate.

Presumably it was considered to be a powerful enchantment, and thus carries an unusual cost for using it. I don't think it's worth it, so I avoid the enchantment.

In case this point isn't clear, when you are wearing a piece of armour with the Thorns enchantment and you are attacked:

If the Thorns spell does not activate, the armour takes 2 damage.
If the Thorns spell successfully activates, the armour takes 4 damage.
If your armour doesn't have Thorns, it takes 1 damage.

The code for the enchantment in MCP is vaguely,
if the spell is successful, damage the armour 3 points and cast Thorns on the aggressor,
else, damage the armour 1 point.

It could have easily been overlooked that standard damage has already been applied to the item at this point.

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.

What @unknown said is correct, the method net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int) reduces the durability of the item by 1 although the Thorns enchantment did not damage the attacking mob.

Charner Wesley Davis

slicedlime

Confirmed

Normal

Items

enchanted-items

Minecraft 1.6.2, Minecraft 1.6.4, 1.15.2, 20w12a

20w28a

Retrieved