This probably sounds like a bad question and I should know this, but how do you test for a block relative from a player? I put down a command block with "testfor ~1 ~ ~ " but that did it from the command block. (I expected it to with that) "testfor @a ~1 ~ ~ " didnt work, and neither did "testfor ~1 ~ ~ @a". What is the right way to write this?

1 Answer 1


While you cannot use testfor to do this, you CAN use execute detect. This is most likely how it would look: /execute @a ~ ~ ~ detect ~1 ~ ~ grass 0 <command>

the execute command will detect a grass block to the left (in the X cord) of all players in the world. the command is how you would track that player if it detects the block successfully.

an example tracking command would be /execute @a ~ ~ ~ detect ~1 ~ ~ grass 0 scoreboard players set @p Sample_Obj 1

comment if you have any other questions.

Source: https://minecraft.wiki/w/Commands#execute

  • Could you make this answer a bit more general and explain a little more? As it stands, a random reader has no idea what it does, or how to change it to suit his needs.
    – MrLemon
    Aug 20, 2015 at 15:52
  • @MrLemon done, I really should have taken more time writing this instead of rushing it.
    – Judge2020
    Aug 20, 2015 at 15:56
  • @user3878893 This is kinda related to my "Is there a scoreboard criteria for breaking spawners?" question. Right now, I'm testing it, to make see if players can glitch it. Thanks for the help :D Aug 20, 2015 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .