mojira.dev
MC-129178

Teleport ignoring execute

In the latest snapshot, /teleport is set to work based on the executors location. This works fine, except /execute should be able to work on /tp or /teleport, however, based on the description, and it does not. The best way I can think of describing this is with an example.

In 1.12, if I use the command (in a command block): /execute @p~ ~ ~ teleport @e[type=armor_stand,c=1] ~ ~ ~2
The armor stand is constantly teleported positive 2 blocks on the Z axis beside me, as to be expected.

In 18w16a, if I use the command (also in a command block): /execute as @p run teleport @e[type=armor_stand,limit=1,sort=nearest] ~ ~ ~2
The armor stand is teleported positive 2 blocks on the Z axis beside the command block running the command.

It appears that /execute is unable to change the relative executor, and such causes the command block's coordinates to be the one used, despite the /execute command setting the relative coordinates to mine. I have tried many other of the /execute settings, but was unable to get any of them to work. This also does not work outside of command blocks, if a player were to run an execute on a different entity and teleport something based on it's location, the teleported object will still be teleported to the player, using its relative coordinates.

EDIT: Fix would be /execute as @p at @s run teleport @e[type=armor_stand,limit=1,sort=nearest] ~ ~ ~2, using both at and as, mentioned by Jack Lanois. Still may or may not be a bug.

Comments 4

This seems like an issue that should be very common, and reported already, but I have searched many times and found nothing.

I could be wrong, but I do not believe this is a bug. In the latest snapshot, executing as an entity and executing at an entity are broken up. When you type in the command /execute as @p run teleport @e[type=armor_stand,limit=1,sort=nearest] ~ ~ ~2, it executes the command as run by the the player, but the location of it is still relative to the command block(or where the command was executed). In other words, it executes the command as the player, but the relative coordinates are not at the player. In 1.12, executing as the entity and at the entity were the same thing, which is why the first command works in 1.12. In the snapshot and forward, you would have to add an "at @s" after the "as @e" to change the relative coordinates of the command. Like this for example: /execute as @p at @s run teleport @e[type=armor_stand,limit=1,sort=nearest] ~ ~ ~2

That could be true, I have picked up the new commands only recently (used the old format for years however) and I have not thought of everything, such as that. Will have to try it out and see how it goes. Thank you however! Even if not a bug I still needed a fix for this. EDIT: Can confirm that in fact did make it work properly. I tried everything but using both as and at, guess I overlooked that. Still open for debate if this is a bug or not, but at the very least there is a way around it if there is. Many thanks!

Not a bug; use at for location-based features.

Dinnerbone has a list of changes here: https://www.reddit.com/user/Dinnerbone/comments/6l6e3d/a_completely_incomplete_super_early_preview_of/

It's a bit outdated but does explain how as and at work.

delsin rowe

(Unassigned)

Unconfirmed

Minecraft 18w16a

Retrieved