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?

  • I think that positioned as includes orientation, i.e. where the target is looking. – MBraedley May 22 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. – Fabian Röling May 23 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. – Fabian Röling May 23 at 7:56
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.

| improve this answer | |
  • Yeah, you would get teleported to 12, 23, 34 in the overworld. – MegaCrafter10 May 22 at 22:58
  • Oh, so the whole "divide/multiply" by 8 thing doesn't count for commands, only the workings of nether portals. That means all the math I thought needs to be done doesn't need to be done! Thanks for your help, this answer is accepted. – ExpertCoder14 May 23 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.