mojira.dev
MC-245904

Position selector arguments (x, y, z, dx, dy, dz) require all three axes to be specified only when called by the server

Description

When a command using the position selector arguments is called by a player, the arguments only need to include one axis for it to work. When called by the server, it needs all three.

Steps to Reproduce

Stand at 0, 0, 0 and execute the following as a player:

/say @a[x=-10, dx=20]

Note that your name appears in the output, since you are standing between x=-10 and x=+10.

Now, put that command in a .mcfunction and run the following as a player:

/function demo:example

 

Note that it still works, as expected.

Edit the datapack so that your mcfunction is called by #minecraft:tick, such that the executor is now the server instead of the player. Note that no player name appears, even though you are standing within the area specified.

In order for the command to select you now, you must specify all three axes in your command:

say @a[x=-10, dx=20, y=-10, dy=20, z=-10, dz=20]

This is in contrast to when the command originates from the player where it only requires 1 axis.

 

Comments 1

The described behavior works as intended. Unspecified x/y/z values default to the context position, and unspecified dx/dy/dz values default to 0.

When #tick runs, the context position is world spawn. Therefore, the selector starts searching at world spawn, except with X=-10, and tries to find players in a 20-wide tube in the positive X direction. This differs from the behavior you observe when running the command from chat because the context position is your position, so the selector starts searching at your position, except with X=-10.

SploxFox

(Unassigned)

Unconfirmed

(Unassigned)

1.18.1

Retrieved