Minecraft – How to detect a player close to a specific block Minecraft 1.9

minecraft-commandsminecraft-java-edition

I am doing a troll to my friend, but I am not very good at commands. I am trying like to replace diamond ore/blocks in a radius of 5 around him with stone. I tried it with /execute and /testfor but it either didn't work or work but not very well (one had bugs and didn't change the block). I don't have my command because I deleted the world.

Best Answer

To do this, create two repeating command blocks containing the following commands:

Command one:

/execute YourFriendsName ~ ~ ~ /fill ~-5 ~-5 ~-5 ~5 ~5 ~5 stone 0 replace diamond_ore

Command two:

/execute YourFriendsName ~ ~ ~ /fill ~-5 ~-5 ~-5 ~5 ~5 ~5 stone 0 replace diamond_block