The bug
The volume defined by target selector arguments dx
, dy
and dz
is always larger than specified by 1 in all dimensions.
For example, @e[dx=0,dy=0,dz=0]
would select entities in a 1x1x1 cube with the negative corner at the execution location, and @e[dx=1,dy=1,dz=1]
would select entities in a 2x2x2 cube.
Negative values are allowed and work correctly in the negative directions; however the selection area is still extended 1 in all positive directions.
For example, If you have an armor stand besides you at each side, aligned to the x axis, @e[dx=-1]
would select you and both armor stands, rather than just the one on the negative side.
Steps to reproduce
Setup some armor stands
Run the following commands:
/execute align xyz run summon armor_stand ~0.5 ~ ~0.5 {CustomName:'{"text":"Center"}'} /execute at @e[type=armor_stand,name=Center] run summon armor_stand ~1 ~ ~1 {CustomName:'{"text":"Positive"}'} /execute at @e[type=armor_stand,name=Center] run summon armor_stand ~-1 ~ ~-1 {CustomName:'{"text":"Negative"}'}
Run the following command:
/execute at @e[type=armor_stand,name=Center] run say @e[dx=0,dy=0,dz=0,type=armor_stand]
→ ❌ It finds "Positive" even though an area with the size of 0x0x0 is provided.
Use the following command:
/execute at @e[type=armor_stand,name=Center] run say @e[dx=-1,dy=-1,dz=-1,type=armor_stand]
→ ❌ It finds all armor stand even though it should not find "Positive" as a negative area is provided.
Code analysis
A code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 4
relates to 1
Attachments
Comments 43


Basically the game defaults to checking a 1 meter cubed volume, starting form the north-west-bottom and ending in the south-east-top, with the executing position in one of the eight corners. With positive x and z coordinates, the executing point is the same as the start point of the volume. With negative x and z coordinates, the executing point will be in the south-east corner, and the start point of the volume will be in the north-west corner. On top of this behavior, x, y, z, dx, dy, and dz all check for entity hitboxes, not coordinates, which is very misleading and causes unexpected behavior.

Confirmed for 18w16a.

Confirmed for 1.13.2
Hope this gets fixed soon.

confirmed in 1.14. It's affecting a lot of my creations since it's impossible to select an area smaller than 1x1x1 with this bug. I really hope this gets fixed soon :/
It would be a huge help for me

Confirmed in 1.21 Release Candidate 1
@unknown: Please stop confirming this for every new build, major releases are more than enough! Any further comments will be removed.

Got it. I will only comment for major releases. In this case, I can confirm this bug in Release 1.21

Confirmed in 1.21.4

Agreed, this should be fixed. Maybe for 1.21.5
Disregard my last comment, had a wrong test setup.