mojira.dev
MC-124140

Anchoring does not reset after use, and is implicitly applied in nonsensical cases by default

What I expected:
I expected that after I anchored the origin of the local coordinate system to my eyes, and set a position using local coordinates, that the anchoring would be reset (as it no longer makes sense, though the option always exists to re-anchor).

What actually happened:
After anchoring the origin of the local coordinate system to my eyes, and setting the position using local coordinates, the anchoring still applied, and I had to use anchored feet to fix it.

More details:
See the image attachment. A workaround for this issue is adding anchored feet directly after anything that makes use of a non-default anchor point, but this is much less obvious given that the main use of anchored will be with entities, and changing the position would retain a seemingly-arbitrary offset.

Here are commands to reproduce the issue:

execute as @a at @s anchored eyes positioned ^ ^ ^3 run particle end_rod ~ ~ ~
execute as @a at @s anchored eyes positioned ^ ^ ^3 positioned ^ ^ ^ run particle flame ~ ~ ~
execute as @a at @s anchored eyes positioned ^ ^ ^3 positioned ~ ~ ~2 run particle flame ~ ~ ~
execute as @a at @s anchored eyes positioned ^ ^ ^3 facing ~ ~ ~2 positioned ^ ^ ^5 run particle flame ~ ~ ~

The first 3 commands function as markers to visualize the steps taken in the final command. The end rod particle represents the sensible step, 5 blocks in front of the players' eyes. But the flames represent a line segment created by anchored eyes being implicitly applied a second time, the bottom left of which is an endpoint.

Here are commands to show what I expected the above 4 commands to look like if this issue did not exist:

execute as @a at @s anchored eyes positioned ^ ^ ^3 run particle end_rod ~ ~ ~
execute as @a at @s anchored eyes positioned ^ ^ ^3 anchored feet positioned ^ ^ ^ run particle flame ~ ~ ~
execute as @a at @s anchored eyes positioned ^ ^ ^3 positioned ~ ~ ~2 run particle flame ~ ~ ~
execute as @a at @s anchored eyes positioned ^ ^ ^3 anchored feet facing ~ ~ ~2 positioned ^ ^ ^5 run particle flame ~ ~ ~

Linked issues

Attachments

Comments 19

This still affects 18w05a. And you'd probably want to update the description, and this is a result of anchored simply not working with positioned, similarly to MC-124381, which I found. I have no idea why this is occurring, I've been testing a bunch, to no avail.

This is all WAI.

OP's expectation is wrong, tildes never care about anchoring.

If you read the post, you'd see that I am using local coordinates. It's just facing some relative coordinates (which I only expect to be elevated after overwriting the position, not from the get-go).

Anchored makes the rest of a command use feet/eyes for local coordinates and facing commands. This means that anchoring at the players eyes, then positioning 1 block forward will set the new foot level 1 block forward from the players eye level. chaining another positioned command will still run from the eye level, which is now 1.62 blocks above the current foot level. The same occurs if using a facing command, it will execute 1.62 blocks above whatever the current foot level is and run as though the player is looking at the location 2 blocks south (from the command you gave) of the current foot location (since relative coordinates were used). If local coordinates were used in the facing command, it would run as though the player is looking either to the side, up, or forward from their eye level. Anchored changes whether local coordinates execute from the players feet or eyes, but relative coordinates always execute from wherever the current foot location is (changed by using "at" or "positioned").

I understand the functionality of facing. However, after I change my base position using positioned and local coordinates, I expected to be able to execute further subcommands from that position. Instead, the facing subcommand I executed appears to have treated the new position as if it was the eye level, and decided to go down to the foot level since that's where relative coordinates always run. However, this new position is meant to replace the foot level, and the anchoring should be reset correctly.

9 more comments

Affects 1.13-pre1, and I think this is more an issue that positioned with local coordinates doesn't reposition the eye level when working with local coordinates.

ie.

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

will execute off the eyes, but the reposition where the feet are, to one block from the eyes, and then since the feet are repositioned, it thinks the eyes are up there too, and then repositions it again to where the eyes are, making it so the stone ends up two blocks from where you're looking, and two player eye heights up.

This should really reposition where the eyes are if the command is already anchored to the eyes, so the stone would appear 2 blocks from the player's eyes.

Seems to affect 1.14.4.

Found this bug by running a datapack with two functions, "namespace:trigger" and "namespace:raycast", for a total of three commands.
Contents of "namespace:trigger": 
         execute as @s anchored eyes positioned ^ ^ ^1 run function namespace:raycast
Contents of "namespace:raycast":
         execute run particle flame ~ ~ ~ 0 0 0 0 1
         execute as @s positioned ^ ^ ^0.1 run function namespace:raycast

The intuitive and expected result after calling "namespace:trigger" with the function command in-game would be a line of flame particles drawn from the user's eyes onwards in the direction they are facing. The trigger function should set the initial base for the local coordinates to the user's eyes, then run the recursive raycast function which spawns a flame particle at the local coordinates, then shifts the local coordinates forward by 0.1 blocks and runs itself again.

What happens instead is a line of flame particles are drawn upwards in intervals of the player's height (from feet to eyes). Similar to what CreeperMagnet_ said, what is likely happening in this scenario is that every time the raycast function is called, the local coordinates are raised by the height of the user's eye level as though the anchored subcommand is being called upon again after repositioning. In the comments section of MC-124381, Aaron Rhodes suggested adding "anchored feet" to counteract the "anchored eyes" in the command. This fixes the problem, supporting that the cause of the issue lies somewhere with the execute command repeatedly "anchoring" the local coordinates to a height corresponding to the user's eye level every time the following commands are run. (I would also like to add that although inserting "anchored feet" may resolve the issue in some circumstances, it's a bit of an unintuitive solution.)

Alluet

slicedlime

Community Consensus

Normal

Commands

Minecraft 18w02a, Minecraft 18w03a, Minecraft 18w05a, Minecraft 18w07b, Minecraft 18w11a, ..., Minecraft 1.13.2-pre1, Minecraft 18w44a, Minecraft 1.14.2 Pre-Release 1, Minecraft 1.14.3 Pre-Release 2, 1.14.4

19w41a

Retrieved