How can I make armor that if the wearer is attacked, the attacker also gets damaged?

I'm working on a map and I'm trying to make special armor and weapons, one of these pieces of armor I want to have the ability to damage a mob/player back if the player with the armor is damaged. If this is possible, could I possibly be given a /give command block example? Im using Minecraft Java on PC 1.13.2 if it helps.


Yes, this is possible. There is an enchantment called Thorns, that will cause damage to an enemy if they attack you. The amount of damage can be determined by the level. You can enchant armor/armour with thorns using an anvil or enchantment table.

The Minecraft wiki says:

Attackers are damaged when they deal damage to the wearer.

Gives a Level × 15% chance of inflicting 1 - 4 (or Level - 10 if Level > 10) damage on anyone who attacks the wearer, whether by melee attack, arrow, or other projectile. In addition to the normal durability reduction for being hit, reduces durability by 3 points when inflicting damage or 1 point otherwise.