I'm trying to make a vanilla spleef arena, with a redstone clock attached to a /setblock
command. No matter how I tried, I could not get the command to set the block under the player air. this was the closest I got: /setblock ~ ~-1 ~ air
is there some way I can attach the ~ ~-1 ~
to @p
? If not what is another way to do this?
-
Don't use a redstone clock! Redstone should never be used in command block contraptions, and especially not as your clock source. There are a few alternatives the run completely in command blocks, but that belongs in a different question.– MBraedleyCommented Oct 22, 2015 at 11:07
1 Answer
What you are looking for is the amazing execute
command:
Executes a command on behalf of one or more other entities, with originating permissions, optionally on condition that a single-block /testforblock-style check passes.
The syntax is:
execute <entity> <x> <y> <z> <command …>
<entity>
is a target selector, such as @a
, <x> <y> <z>
are coordinates from which to execute the following <command …>
from. In most cases, setting this to ~ ~ ~
(i.e. the exact location of the entity) is fine. To set the block under every player to air, you can use
execute @a ~ ~ ~ setblock ~ ~-1 ~ air
-
11.13 syntax:
/execute positioned as @a run setblock ~ ~-1 ~ air
– ppperyCommented Aug 26, 2018 at 3:01