mojira.dev
MC-124381

/execute positioned no longer offsets properly when recursing.

The error:

When using /execute positioned, which as you know, offsets the position of an entity, it no longer executes recursively, and no longer offsets properly.

To reproduce:

  1. Download the data pack below.

  2. Type in /function recursion:ray.

  3. See that no block is placed where you look.

Let's go through this error.

What this function attempts to do:

Is a block of air in front of you? (Local coordinates)

If there is air, then it offsets (Local coordinates), and runs the function again.

If there is not air, it sets a block at said position.

This should produce the results of placing an emerald block at the closest solid block you are looking at, as each time, it offsets, running the function again, searching in front of you again for said solid block. However, this offset is not applied in the recursion of the function, and it just does nothing, unless there is a solid block directly in front of you.

Linked issues

Attachments

Comments 10

Works fine for me when I remove the anchored eyes from the two commands.

Why should that change anything? That should only change the position from which the local coordinates run, not the recursion. Seems odd. I'll do some more investigating.

@tryashtar Read my comments, forgot to tag you. 😛

I'm still pretty sure this is a valid issue, please take a look at my comments. I'm not even entirely sure this is caused by /execute positioned.

Sorry, didn't see your comments until now! I'll reopen but I won't pretend to understand how anchored should behave in this or frankly any scenario.

I'm pretty sure this is either a duplicate of or directly related to MC-124140. Could someone please update this correctly?

For one thing, using "anchored eyes" in the function is pointless as it only needs to be set once. It will make the end result slightly different if anchored is used outside of the function instead (the end execution location will be 1.62 blocks lower). If you remove "anchored eyes" from the function and use this command: /execute positioned ~ ~1.62 ~ run function recursion:ray, you should get the expected results.

You would still get unexpected results if you used: /execute anchored eyes run function recursion:ray, since "positioned" sets the new foot location, and "anchored eyes" applies to every command run afterward that uses local coordinates. For example, if you run this command:

/execute anchored eyes positioned ^ ^ ^1 run setblock ~ ~ ~ stone

It will position the new foot level 1 block in the direction the player is facing from the executor's eye level. Running this command:

/execute anchored eyes positioned ^ ^ ^1 positioned ^ ^ ^1 run setblock ~ ~ ~ stone

The second positioned command, since it is using local coordinates (affected by anchored), will execute 1.62 blocks (eye level relative to foot level) above the new foot location, and 1 block in the direction the player is facing. In short, this command will set a stone block 3.24 blocks up from the players foot level and two blocks in the direction they are facing. I believe this is the intended behavior when using anchored and positioned in conjunction with one another. Running all of the positioned commands first then running an anchored command at the end will give the expected results, as long as anything after the anchored command uses local coordinates and does not set a new foot location.

These are the updated commands I used in the function:

execute unless block ^ ^ ^0.1 air run setblock ^ ^ ^0.1 emerald_block
execute if block ^ ^ ^0.1 air positioned ^ ^ ^0.1 run function fun_namespace:bomber_man/ray

and the command to call the function:

/execute positioned ~ ~1.62 ~ run function recursion:ray

No matter what, "anchored eyes" should be avoided within the function. I believe this command:

/execute anchored eyes positioned ^ ^ ^ anchored feet run function recursion:ray

should be functionally equivalent to the command I posted in my other comment. Anchoring back to the feet after the positioned command, which sets the new foot level, will override the "anchored eyes", meaning that any command that follows will no longer execute 1.62 blocks above the current foot level when using local coordinates.

CreeperMagnet_

(Unassigned)

Unconfirmed

Minecraft 18w03b, Minecraft 18w05a, Minecraft 18w07b

Retrieved