Minecraft – How to use the testfor command

minecraft-commandsminecraft-java-edition

I've been trying to use this command since I found out about it, but for some odd reason, it hasn't been working at all. The command blocks look something like this: the command
But whenever I go to those certain coordinates, I am not teleported to those coordinates. Am I missing anything?
(Just to clarify: I'm not in a multiplayer game. I'm at singleplayer.)

Best Answer

Curly brackets are for NBT data (player/item NBT reference, world/entity NBT reference). For example, you could use:

/testfor @a {OnGround:0b}

To check for players that aren't touching the ground.


What you are wanting to do (check for players within a radius of some coordinates) should be done with target selector arguments instead. These use square brackets, and would look something like:

/testfor @a[x=-651,y=66,z=-633,r=1]

As this is part of the selector, you could also get rid of the testfor and simply use:

/tp @a[x=-651,y=66,z=-633,r=1] -660 66 -632

You may also want to look into the 1.9 command blocks. A repeating blocks would be easier and more efficient than your fill clock, and same with conditional blocks instead of comparators.