mojira.dev
MC-123441

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

  1. 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"}'}
  2. 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.

  3. 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

Attachments

Comments 43

migrated

Disregard my last comment, had a wrong test setup.

migrated

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.

AjaxGb

Confirmed for 18w16a.

Kitilexx

Confirmed for 1.13.2

Hope this gets fixed soon.

migrated

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

33 more comments
phaic

Confirmed in 1.21 Release Candidate 1

[Mod] turbo

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

phaic

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

phaic

Confirmed in 1.21.4

phaic

Agreed, this should be fixed. Maybe for 1.21.5

[Mod] turbo

(Unassigned)

Confirmed

Platform

Normal

Commands

selector

Minecraft 1.12.2, Minecraft 17w50a, Minecraft 18w16a, Minecraft 1.13.2, Minecraft 19w06a, ..., 1.21 Pre-Release 4, 1.21, 1.21.1, 1.21.3, 1.21.4

Retrieved