I'm trying to recreate a form of the game Runner in a spleef format. Basically, I want a redstone signal to be sent out when the player stands on a Snow block in order to delete the block (replace it with air using setblock) a second or two after. How would I accomplish this?


The /execute command will allow you to detect blocks relative to a player. The syntax is:

/execute <entity> <x> <y> <z> <command>

So, you can run the following in the command block:

execute @p ~ ~ ~ testforblock ~ ~-1 ~ snow

The above will give a redstone signal when it successfully finds a snow block below the player, which is what your question asks.

However, using testfor commands and comparators for something like this is generally a bad idea; how will you know what block to delete 2 seconds later when the player has moved away from it, for example? Plus it'll be completely incompatible with multiplayer.

You may want to, instead, use the /execute command's detect syntax, which allows you to detect a block from an entity, then run a command from the same entity if that block was found. You could use this to delete the block that was found, or summon a marker stand to delete it after a delay:

execute @a ~ ~ ~ detect ~ ~-1 ~ snow 0 summon ArmorStand ~ ~-1 ~ {Marker:1b,Invisible:1b,NoGravity:1b,Invulnerable:1b,CustomName:"BlockRemover"}
  • Thanks. Unfortunately, I just realized a flaw in my program – Milesman34 Nov 8 '15 at 18:26

/execute features a detect parameter:

/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:snow 0 /setblock ~ ~-1 ~ minecraft:air 0 Parameter explanation:

@a : select all players

~ ~ ~ : execute at their position

detect : only execute if the following block is found

~ ~-1 ~ : check the block below the player

minecraft:snow 0 : check for snow with metadata = 0

/setblock ~ ~-1 ~ minecraft:air 0 : command to be executed by the player(sets the block below him to air)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.