The bug
It appears the following selector arguments do not behave consistently:
distance
: Finds entities whose position (center of the hitbox) is within the areadx
,dy
,dz
: Finds entities whose hitbox intersects with the area
This might be intended, but can also have unexpected side-effects and be unintuitive.
How to reproduce
Place a block at (0,0) in the floor so you know where it is
Show hitboxes (
F3
+B
)Move around (0,0) and run the following command
/say @s[x=0.5,z=0.5,distance=..0.5]
It finds you as soon as the center of your hitbox is inside a circular area with center at (0.5,0.5) with radius 0.5
Move around (0,0) and run the following command
/say @s[x=0.0,z=0.0,dx=0,dz=0]
It finds you as soon as your hitbox intersects with the block area of (0,0)
I was thinking about position/hitbox arguments and it appears that all should be position, as they can be more precise. In the other hand, mobs have different hitboxes, so it would be harder to see what touches specified coords. Other solution would be adding a new argument to command selectors "select=position/hitbox" with default position to keep old contraptions easy to fix.
Example of usage:
/tp @e[x=2..3,y=4..5,z=6..,select=position] @e[x=0,y=9,z=..2,select=hitbox]