I want a redstone block to be placed when the player is in a certain location. The redstone block will power multiple command blocks which will display a conversation the player is supposed to "overhear."

I've tried the following command to no avail:

/execute @a x y z /fill x y z x y z redstone_block

1 Answer 1

/execute @a x y z /fill x y z x y z redstone_block

Here was your old trials. I'm assuming you were testing for players on coordinates (1, 2, 3) by doing:

/execute @a 1 2 3

But no. What exactly are the coordinates after @a doing? Let's take a look.

From the Minecraft Wiki:


execute <origin: target> <position: x y z> <command: command>

And what does the coordinates do?

Specifies the position from which to run the command. Coordinates specified with tilde and caret notation are relative to the target, not to the position of the command's execution.

Your command is telling Minecraft to do this:

Tell all players to execute the following command at x, y, z: fill x1 y1 z1 x2 y2 z2 redstone_block.

Obviously not what you want.

To filter players based on position, properties, distance, etc., you have to modify @a to include arguments, which will filter your selection to the correct players.

Arguments go in the (optional) square brackets after @a. For example: @a[ARGS]

We'll use the x, y, and z arguments to select a position, and the r argument to dictate how close the player must be.

/testfor @a[x=1,y=2,z=3,r=5]

For example, this command will succeed if a player is detected within 5 blocks of (1, 2, 3).

All you need to do is place a chain command block after that set to conditional mode, with the command you want to run, like your /fill or a /setblock.

  • So, does the /testfor @a[x=1,y=2,z=3,r=5] go in a command block? And this is for bedrock? Aug 13, 2020 at 22:47
  • /testfor goes in a repeating UNCONDITIONAL command block, correct? Aug 13, 2020 at 22:49
  • IT WORKED! Thank you SO MUCH! You are a real computer genius, that is for sure. Aug 13, 2020 at 22:56

You must log in to answer this question.

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