I could be totally wrong, but as far as I know, there is no way to actually prevent the anvils from breaking/degrading without a mod. You can however replace any anvils that are damaged with a simple command.
1. You can have use a series of command blocks to check for an unbroken anvil in a specific location, and if false (meaning it's not there) use another command block to replace it.
For example, say I have an anvil at x=10 y=50 z=22. You need two command blocks(as of the new snapshot)
In the first command block you would use a /testforblock command
/testforblock 10 50 22 minecraft:anvil 0
Next, add a comparator next to the command block leading into a second command block with the command
/setblock 10 50 22 minecraft:anvil
this will replace the block where the undamaged anvil was with a brand spanking new anvil. Be forewarned though, this will replace ANY block you put in it's place (including air) so if you want to replace it, you'll have to disable the command blocks, so this is really mostly only practical on an adventure map or such
Edit:Sorry, I forgot to mention that the first command block (the one running the /testforblock command) needs to be set to repeat. Or, if you don't like running snapshots, run a simple redstone clock to power the command.
Is there a way with command blocks to stop all anvils from degrading with use?
I could be totally wrong, but as far as I know, there is no way to actually prevent the anvils from breaking/degrading without a mod. You can however replace any anvils that are damaged with a simple command.
1. You can have use a series of command blocks to check for an unbroken anvil in a specific location, and if false (meaning it's not there) use another command block to replace it.
For example, say I have an anvil at x=10 y=50 z=22. You need two command blocks(as of the new snapshot)
In the first command block you would use a /testforblock command
Next, add a comparator next to the command block leading into a second command block with the command
this will replace the block where the undamaged anvil was with a brand spanking new anvil. Be forewarned though, this will replace ANY block you put in it's place (including air) so if you want to replace it, you'll have to disable the command blocks, so this is really mostly only practical on an adventure map or such
Edit:Sorry, I forgot to mention that the first command block (the one running the /testforblock command) needs to be set to repeat. Or, if you don't like running snapshots, run a simple redstone clock to power the command.
Alternatively, use /fill's replacement syntax to only replace damaged anvils:
Damage values vary depending on directional facing. List can be found in the wiki: http://minecraft.gamepedia.com/Anvil#Data_values
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/