mojira.dev
MC-88533

Entities without hitboxes cannot properly be tested for with target argument "distance=0" or "dy=0"

These experiments involve marker armorstands – it also affects area effect clouds with zero radius. Most likely the bug occurs due to these armorstands lacking a hitbox.

Setup experiment
In this scenerio the armorstands involved in the testing were obtained as follows:

/summon armor_stand ~ ~ ~ {CustomName:"\"A\"",Marker:X}
/execute at @e[name=A] run summon armor_stand ~ ~ ~ {CustomName:"\"B\"",Marker:X}

Note that the X is either a 0 or 1 depending on the following cases.

Results experiment
We distinguish the following 3 cases

  • Case 1: ArmorStand A is not a marker, ArmorStand B is not a marker.

    execute at @e[name=A] run kill @e[name=B,distance=0]

    Kills B, works as expected

    execute at @e[name=B] run kill @e[name=A,distance=0]

    Kills A, works as expected

  • Case 2: ArmorStand A is a marker, ArmorStand B is not a marker.

    execute at @e[name=A] run kill @e[name=B,distance=0]

    Kills B, works as expected

    execute at @e[name=B] run kill @e[name=A,distance=0]

    Does not kill A, does not work as expected

  • Case 3: ArmorStand A is a marker, ArmorStand B is a marker.

    execute at @e[name=A] run kill @e[name=B,distance=0]

    Does not kill B, does not work as expected

    execute at @e[name=B] run kill @e[name=A,distance=0]

    Does not kill A, does not work as expected

Further research
I've had a talk about these seemingly bugs with SkylinerW who in the MC community is a well respected modder/'expert' on Minecraft. This talk can be found back in this reddit topic:
https://www.reddit.com/r/Minecraft/comments/3cgck7/the_nbt_tag_marker1b_made_a_position_glitch_of/

Here are some extracts from our conversation that might help you guys further, credit to SkylinerW:

"That one definitely seems to be a bug. It's not just armor stands, but any entity that is in the ground; I can't get the command to work even if there's a villager with its feet stuck in a block directly underneath the armor stand without increasing the radius to 2 (r=1 still presents the problem, so it's not restricted to r=0). It's specific to the Y coordinate, so it seems like their interpreted location is being skewed for being within a block. I imagine the eye height for marker stands being at the exact Y value causes it to be seen as being within a block.


Code analysis by @unknown can be found in this comment.


Also this can be more easily tested with this being run in chat while you don't move:

summon armor_stand ~ ~ ~ {NoGravity:1b,Marker:1b,CustomName:"\"c\""}
say @e[distance=0]

this'll only show your name and not the armor stand's, unless you change it to Marker:0b

Linked issues

Comments 48

Please do not mark unreleased versions as affected.
You don't have access to them yet.

--- This action was performed automagically. If you believe this was done erroneously, please :light_bulb_on: raise an issue.

Please fix this ;_; i can't do it otherwise...

You can temperarely make it r=1, and when it's fixed you can change it to r=0

I hate this bug too, it makes some systems suck, but that's why there is a bug tracker, and this will get fixed at one point

Thats the problem. I can't ^^
Cause there are other Armorstands around it that should not be affected.
And something like /execute (...) ~ ~1 ~ (...) @e[r=1] doesn't work either.
With an offset of 0.999 none of the Armorstands react, and with 0.998 all of them do...

You could add c=1

38 more comments

(Workaround)

This does not occur in predicate's distance detection. Use that instead.

Still affects 1.17.1

still a problem in 1.18.1

This could be solved by expanding the bounding box by an additional 1 in the negative direction as well.

(for the code analysis comment)

This is actually a horrible way to fix it, as it makes making small selection cubes even harder, amplifying MC-123441 to be twice as severe.

The actual problem is that these entities are only a point in existence, as the point is not accepted in the selection box, because it's on the very edge. (The selector check is "in between min and max, excluding min and max values", rather than "in between min and max, including min and max values".)
You can literally offset the selection box by 0.00001 on x y and z, and then find it with dx/dy/dz just fine.
Example:

/summon marker
/execute as @e[type=marker] at @s run say @s[dy=0] <- no result
/execute as @e[type=marker] at @s positioned ~-0.00001 ~-0.00001 ~-0.00001 run say @s[dy=0] <- result

For distance= there doesn't seem to be a command-workaround, but you can use predicates are previously pointed out (because they properly check for including, not excluding).

Can confirm in 1.21.1 with marker entities

GamerGuppy

AlexMCool

(Unassigned)

Confirmed

Platform

Low

Commands

Marker, argument, armor_stand, radius, selector

Minecraft 1.8.8, Minecraft 15w36d, Minecraft 15w37a, Minecraft 15w42a, Minecraft 15w51b, ..., 1.16.3, 1.17.1, 1.18.1, 1.19, 1.21.3

Minecraft 16w38a

Retrieved