- 52,698 views, 10 today
37
Basically what you want to start out with is the basic execute command, /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:diamond_block 0 /effect @a minecraft:strength 30 5 is an example of using detect so basically as long as the command block is running on a clock as soon as you stand on a diamond block you get strength 5 for 30 seconds. or if you want to change -1 to +1 it will test for a diamond block right above you and same for every other coordinate. /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:iron_block 0 /effect @a minecraft:regeneration 15 2 What this does it detects that if you stand on an ironblock it will give regeneration 2 for 15 seconds.
That is basically just the intro of it you could do so much more. It doesn't have to be a potion effect for example you could run an execute command inside the execute command, for example: /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:emerald_block 0 /execute @e[type=Creeper] ~ ~ ~ /summon PrimedTnt ~ ~ ~ {Fuse:0} if a player happened to stand on top of an emerald block this time it would summon PrimedTnt at all creepers location and kill them, or do the exact samething except do it /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:emerald_block 0 /execute @e[type=Zombie] ~ ~ ~ /effect @e[type=Creeper] poison 60 1 instead of summoning primed tnt to creepers it will poison all zombies for a minute.
Another use you could use for this would be land mines. You have to change /execute @a ~ ~ ~ detect ~ ~-1 ~ /execute @e[type=Spider] ~ ~ ~ detect ~ ~-1 ~ minecraft:brick_block /execute @e[type=Spider] ~ ~ ~ /summon PrimedTnt ~ ~ ~ {Fuse:0} So this time if a player steps on a brick block nothing happens at all but if a spider steps on a brick block the spider will blow up. Or you could use the ! mark which means "not" /execute @e[type=Spider] ~ ~ ~ detect ~ ~-1 ~ minecraft:brick_block /execute @e[type=!Player] ~ ~ ~ /summon PrimedTnt ~ ~ ~ {Fuse:0}. This means anything that's not a player will get blown up if they happen to step on the brick block. Including items you drop onto the brick (Press Q).
There are literally so many fun things you could do with this command but a really useful concept is
/execute @e[type=Player] ~ ~ ~ detect ~ ~-1 ~ minecraft:grass /setblock X Y Z minecraft:redstone_block 0 replace This will mean when a grass block is 1 block below them(standing on it) So this can replace the testfor command and the comparators it will save you space and put coordinates of the redstone block to activate command blocks somewhere more distant (Still needs to be in same chunk).
This command basically replaces pressure plates without the pressure plate, but instead of doing ~ ~-1 ~ you can do
~1 ~ ~ or ~ ~ ~1 to detect if the block is on them side of them or ~ ~-2 ~ and see if the block is 2 blocks below them. or if you wanted to get fancy /execute @e[type=Player] ~ ~ ~ detect ~ ~-1 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ That will play a noteblock sound if you stand on a diamond. Now to make a diamond detector just make more commandblocks /execute @e[type=Player] ~ ~ ~ detect ~ ~-2 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ /execute @e[type=Player] ~ ~ ~ detect ~ ~-3 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ /execute @e[type=Player] ~ ~ ~ detect ~ ~-4 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ ETC. Eventually you'd get all the way to a really high number so if you were on the surface you were standing right above a diamond you'd hear the sound and and dig straight down to find a vein of diamonds.
I hope this blog helped you because most of the redstoners I know not many people were familiar with this part of the execute command.
Thanks for reading!
That is basically just the intro of it you could do so much more. It doesn't have to be a potion effect for example you could run an execute command inside the execute command, for example: /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:emerald_block 0 /execute @e[type=Creeper] ~ ~ ~ /summon PrimedTnt ~ ~ ~ {Fuse:0} if a player happened to stand on top of an emerald block this time it would summon PrimedTnt at all creepers location and kill them, or do the exact samething except do it /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:emerald_block 0 /execute @e[type=Zombie] ~ ~ ~ /effect @e[type=Creeper] poison 60 1 instead of summoning primed tnt to creepers it will poison all zombies for a minute.
Another use you could use for this would be land mines. You have to change /execute @a ~ ~ ~ detect ~ ~-1 ~ /execute @e[type=Spider] ~ ~ ~ detect ~ ~-1 ~ minecraft:brick_block /execute @e[type=Spider] ~ ~ ~ /summon PrimedTnt ~ ~ ~ {Fuse:0} So this time if a player steps on a brick block nothing happens at all but if a spider steps on a brick block the spider will blow up. Or you could use the ! mark which means "not" /execute @e[type=Spider] ~ ~ ~ detect ~ ~-1 ~ minecraft:brick_block /execute @e[type=!Player] ~ ~ ~ /summon PrimedTnt ~ ~ ~ {Fuse:0}. This means anything that's not a player will get blown up if they happen to step on the brick block. Including items you drop onto the brick (Press Q).
There are literally so many fun things you could do with this command but a really useful concept is
/execute @e[type=Player] ~ ~ ~ detect ~ ~-1 ~ minecraft:grass /setblock X Y Z minecraft:redstone_block 0 replace This will mean when a grass block is 1 block below them(standing on it) So this can replace the testfor command and the comparators it will save you space and put coordinates of the redstone block to activate command blocks somewhere more distant (Still needs to be in same chunk).
This command basically replaces pressure plates without the pressure plate, but instead of doing ~ ~-1 ~ you can do
~1 ~ ~ or ~ ~ ~1 to detect if the block is on them side of them or ~ ~-2 ~ and see if the block is 2 blocks below them. or if you wanted to get fancy /execute @e[type=Player] ~ ~ ~ detect ~ ~-1 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ That will play a noteblock sound if you stand on a diamond. Now to make a diamond detector just make more commandblocks /execute @e[type=Player] ~ ~ ~ detect ~ ~-2 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ /execute @e[type=Player] ~ ~ ~ detect ~ ~-3 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ /execute @e[type=Player] ~ ~ ~ detect ~ ~-4 ~ minecraft:diamond_ore /execute @p ~ ~ ~ playsound note.pling @p ~ ~ ~ ETC. Eventually you'd get all the way to a really high number so if you were on the surface you were standing right above a diamond you'd hear the sound and and dig straight down to find a vein of diamonds.
I hope this blog helped you because most of the redstoners I know not many people were familiar with this part of the execute command.
Thanks for reading!
Tags |
1 Update Logs
Update #1 : by Veritas025 06/23/2016 4:44:56 pmJun 23rd, 2016
Added 2 more paragraphs and fixed some details
tools/tracking
3516966
6
how-to-use-the-detect-in-execute-command-activate-command-blocks-by-standing-on-a-block
Create an account or sign in to comment.
And this same command" /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:iron_block 0 /effect @a minecraft:regeneration 15 2" for version 1.14.1 and put it in a command block and it works? I have tried to make the command block detect a player / entity on top of a block and execute another command (for 1.14.1) but it only works if I execute it but not if it is in the command block. Would someone know how to do it? Thanks in advance.
What Im trying to do:
I want the command block to detect when a player walks into a certain X Y Z coordinate. (Such as a 20x20x20 area), Im trying to make it so when any of the 2 players walks in front of a castle, it makes the bad guy of the map speak through command blocks. (Which I already know how to do) but I can't seem how to make command blocks detect it, and send a signal to redstone to play the "dialog". Any help with this would be very grateful. I can't find anything to help with this online, so I came here because you seem to know what your doing with the detect tool. Thanks.