Mojira Archive
MCPE-39785

Function position refers to executor instead of command origin when not using /execute

The bug

The following commands are supposed to be indistinguishable:

/function cmd
/execute @s ~ ~ ~ function cmd

However, this is not the case for some functions.
Consider the following function:

tp @s ~ ~5 ~
setblock ~ ~ ~ stone

The expected behavior this function is that you are teleported 5 blocks up, then stone is placed on the ground where you used to be. If this seems confusing, please understand that relative coordinates are relative to the position the command was run from, not the position of @s. This is well-established and works correctly in many other situations.

The function works differently depending on if you put /execute @s ~ ~ ~ in front of it, breaking the first assumption. With the /execute, it works correctly, but without it, it fails, teleporting the player ten blocks in the air.

How to reproduce

1. Download and open the attached world
2. /execute @s ~ ~ ~ function teleport_block
The block was placed on the ground
3. /function teleport_test
The block was placed in mid-air

Unresolved

Nusiq

2018-12-14, 11:12 PM

2024-08-28, 01:56 AM

9

5

Confirmed

166539

vanilla-parity

1.13.0.1 Beta - 1.17.321.13.0.1 Beta, 1.19.10.20 Preview, 1.17.40.23 Beta, 1.17.40.21 Beta, 1.17.30.22 Beta, 1.17.11 Hotfix, 1.17.0.50 Beta, 1.16.220, 1.16.200.57 Beta, 1.8.0, 1.10.0, 1.11.0, 1.13.0, 1.16.100, 1.16.101 Hotfix, 1.17.30, 1.17.32

-