Thorns damage is applied when player shoots himself
The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]} - Shoot yourself
→ Your chestplate will break and you will die because of the thorns damage
Possible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
This could probably be tested in the methods net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity) (better?) or net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int).
Created Issue:
Thorns damage is applied when player shoots himself
The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]}- Shoot yourself
→ Your chestplate will break and you will die because of the thorns damagePossible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int)/** * Whenever an entity that has this enchantment on one of its associated items is damaged this method will be * called. */ public void onUserHurt(EntityLivingBase user, Entity attacker, int level) { // Added this if statement if (user.equals(attacker)) { return; } else { Random random = user.getRNG(); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.THORNS, user); if (shouldHit(level, random)) { if (attacker != null) { attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)getDamage(level, random)); } if (itemstack != null) { itemstack.damageItem(3, user); } } else if (itemstack != null) { itemstack.damageItem(1, user); } } }
The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]}- Shoot yourself
→ Your chestplate will break and you will die because of the thorns damagePossible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
This could probably be tested in the method net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity) already.
net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int)/** * Whenever an entity that has this enchantment on one of its associated items is damaged this method will be * called. */ public void onUserHurt(EntityLivingBase user, Entity attacker, int level) { // Added this if statement if (user.equals(attacker)) { return; } else { Random random = user.getRNG(); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.THORNS, user); if (shouldHit(level, random)) { if (attacker != null) { attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)getDamage(level, random)); } if (itemstack != null) { itemstack.damageItem(3, user); } } else if (itemstack != null) { itemstack.damageItem(1, user); } } }
The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]}- Shoot yourself
→ Your chestplate will break and you will die because of the thorns damagePossible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
This could probably be tested in the method net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity)
already.net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int)/** * Whenever an entity that has this enchantment on one of its associated items is damaged this method will be * called. */ public void onUserHurt(EntityLivingBase user, Entity attacker, int level) { // Added this if statement if (user.equals(attacker)) { return; } else { Random random = user.getRNG(); ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.THORNS, user); if (shouldHit(level, random)) { if (attacker != null) { attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)getDamage(level, random)); } if (itemstack != null) { itemstack.damageItem(3, user); } } else if (itemstack != null) { itemstack.damageItem(1, user); } } }The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]}- Shoot yourself
→ Your chestplate will break and you will die because of the thorns damagePossible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
This could probably be tested in the methods net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity) or net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int) (better?).
The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]}- Shoot yourself
→ Your chestplate will break and you will die because of the thorns damagePossible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
This could probably be tested in the methods net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity) or net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int)
(better?).The bug
When a player shoots himself with a bow he will be damaged by his own thorns enchantment.
How to reproduce
- Use the following command and equip the chestplate
/give @p minecraft:diamond_chestplate 1 0 {ench:[{id:7s,lvl:32767s}]}- Shoot yourself
→ Your chestplate will break and you will die because of the thorns damagePossible solution
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
This could probably be tested in the methods net.minecraft.enchantment.EnchantmentHelper.applyThornEnchantments(EntityLivingBase, Entity) (better?) or net.minecraft.enchantment.EnchantmentThorns.onUserHurt(EntityLivingBase, Entity, int).