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

How to detect a player close to a specific block Minecraft 1.9 - From below of satisfied curling players spreading hands and joining palms together during game

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



Pictures about "How to detect a player close to a specific block Minecraft 1.9"

How to detect a player close to a specific block Minecraft 1.9 - Sportsmen in red and blue waistcoats chatting on floor of spacious curling arena
How to detect a player close to a specific block Minecraft 1.9 - Talking curler players chilling on floor
How to detect a player close to a specific block Minecraft 1.9 - Crop curlers connecting brooms on floor



How do you detect if a player is on a specific block in Minecraft?

The blank is for the particular block you are looking for. Let's say you're lost in the Nether and need to find your Nether Portal, you could type : /locateblock obsidian, and get the coordinates for the nearest obsidian, most likely being your, said, Portal.



Detect When A Player Is At A Block/Blocks Minecraft




More answers regarding how to detect a player close to a specific block Minecraft 1.9

Answer 2

You can place a command block behind it or below it (but make sure it isn't in sight).

In 1.9 and above, you can change it to a repeating command block (purple-colored) and make it always active, unless you want to manually enable it. In order to do that, keep it redstone-powered and place a lever.

In 1.8.9 or below, place a comparator clock like this:

comparator clock example

Credits to [Martin1704] on the Minecraft Forums for the image.2

Finally, type in this command:

/execute @a[r=5] ~ ~ ~ /setblock x y z minecraft:stone

Replace "x y z" with the coordinates.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: SHVETS production, SHVETS production, SHVETS production, SHVETS production