Target selector volume arguments "dx", "dy" and "dz" select larger area than provided
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 ccJerrycc can be found in this comment.
2017-12-21, 11:33 AM
2025-01-09, 08:38 PM
80
48
Minecraft 1.12.2 - 1.21.4
Minecraft 1.12.2, Minecraft 17w50a, Minecraft 18w16a, Minecraft 1.13.2, Minecraft 19w06a, Minecraft 1.14.1, 1.14.4, 19w35a, 19w41a, 19w42a, 19w44a, 19w46b, 1.15 Pre-Release 2, 1.15 Pre-release 3, 1.15 Pre-release 4, 1.15 Pre-release 5, 1.15 Pre-release 6, 1.15 Pre-release 7, 1.15, 1.15.1, 1.15.1 Pre-release 1, 1.15.2 Pre-Release 1, 1.15.2, 20w06a, 20w12a, 20w14a, 20w18a, 1.16.1, 1.16.2 Release Candidate 1, 1.16.3, 1.16.4, 20w49a, 21w03a, 21w05b, 1.17.1, 1.18.1, 1.18.2, 22w19a, 1.19.1 Pre-release 5, 1.19.3, 1.19.4, 23w12a, 23w18a, 1.20 Release Candidate 1, 1.20, 1.20.1, 1.20.2, 23w43b, 1.20.4, 24w14a, 1.20.5 Release Candidate 2, 1.20.5, 1.20.6, 1.21 Pre-Release 3, 1.21 Pre-Release 4, 1.21, 1.21.1, 1.21.3, 1.21.4
-