Minecraft – How to automatically remove anvils in Minecraft

minecraft-java-edition

I'm creating a Minecraft PVP map where players can purchase enchanted weapons for XP. However, I'm supplying certain items in my shop that I do not want players to repair with anvils (e.g. A "Sniper Bow" which insta-kills players with a remaining durability of 10 shots). How can I make a mechanism in vanilla Minecraft to automatically remove anvils once placed?

Best Answer

If the total cost to repair an item is greater than 39, it cannot be repaired in survival mode. You can use the RepairCost nbt tag to make it too expensive to repair an item in an anvil. For example, this command will spawn a Power 10 bow that cannot be repaired with an anvil:

/give @p minecraft:bow 1 374 {ench:[{id:48,lvl:10}],RepairCost:40}