4

The /execute command is a versatile command used to execute commands on behalf of other entities, or to test for conditionals before executing a command. It offers multiple different parameters to set who, what, when, and where to execute the command.

There are two parameters that look very similar: at and positioned as.
The Minecraft Wiki has a clear description of what each one does: at is used to position at an entity, while positioned can be used to specify coordinates.

But however, there is another way to specify an entity: using positioned as ??. This also offers us to specify an entity instead of coordinates to execute the command at.

What is the difference between these two parameters, and in which situations should I prefer each of them?

3
  • I think that positioned as includes orientation, i.e. where the target is looking.
    – MBraedley
    May 22, 2020 at 21:55
  • No, you cannot set "when" to execute something. Only /schedule can do that directly and you can use ticking things or other things that have timings to make timers indirectly, based on conditions. May 23, 2020 at 7:53
  • Wow, I didn't even know that /execute positioned as exists. I've never used it before, in my 192 Minecraft commands answers that use/mention /execute or elsewhere. It's even confusingly named, because it's not like /execute as at all. May 23, 2020 at 7:56

1 Answer 1

4

This is an interesting question. at changes the position of execution using the position, rotation, and dimension of the target. positioned as only uses the position of the target.

You can test this yourself by running this command from a command block in the overworld (make sure the chunk is loaded):

/execute if entity @e[tag=test] positioned as @p run setblock ~ ~2 ~ glass

The entity with the tag is just a switch so you can activate the command from the end/nether. The command will place a glass block at your position but in the overworld (which proves that positioned as only uses the position). Now try using at and you will see that the glass block is placed not only at your position, but also in the same dimension you are in.

0

You must log in to answer this question.

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