mojira.dev
MCPE-124890

Function positional offset applies repeatedly/too late

The bug

When a function is run with modified coordinates via /execute, it's supposed to run at those coordinates (makes sense). However, instead it repeatedly re-evaluates those coordinates for each command relative to the executing entity, which does not make sense and is very confusing.

How to reproduce

Create a function with the following contents

tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~
tp @s ~ ~ ~

Run the function with the following command:

/execute @p ~ ~1 ~ function whatever

Expected result
You get teleported one block up.

Actual result
You get teleported ten blocks up.

Notes

This is closely related to MCPE-39785. It might be fixed if bedrock edition finally gets the update aquatic version of /execute.

Currently, the function is treated as if every command had /execute @s ~ ~1 ~ in front of it. Bedrock seems to have a weird notion of function context, containing a sender (@s) and sender-relative re-evaluated coordinates. That is wrong, the correct context is a sender and an absolute context position, from which all commands in the function are sourced. Teleporting the sender should not affect the context position at all, and you can use /execute to explicitly re-sync them.

In other words, the position argument of /execute should be a position, relative to the sender, to run all commands from. Currently it's a position to run all commands from, relative to the sender. That distinction is very important and the cause of this bug.

Attachments

Comments 2

This is not fully fixed. To see this, modify the function so that the first line is
/tp @s ~ ~100 ~

Now do /function whatever
Expected result: You don't move at all, since you are teleported back to your original location immediately after the 100-block jump.
Actual result: You are teleported 100 blocks in the air.

Now do /execute @s ~ ~ ~ function whatever
Expected result: This should be identical to the previous call, since neither the sender nor context position are modified.
Actual result: You get the expected result from the previous attempt.

This implies that /execute supplies additional context that is present, but not applied correctly when running a command straight.

The remaining part of this is just MCPE-39785

tryashtar

(Unassigned)

537173

Confirmed

Windows

1.19.10.20 Preview, 1.17.40.23 Beta, 1.17.40.21 Beta, 1.17.0.50 Beta, 1.16.220, 1.17.30, 1.17.32

1.17.0.58 Beta

Retrieved