Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-39785

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.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
    • None
    • Confirmed
    • Windows
    • 166539

      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

            Nusiq Nusiq
            Votes:
            9 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              CHK: