mojira.dev
MCPE-235940

Negated has_property check excludes mobs without the property, but includes mobs with no properties

The bug

The has_property selector argument selects entities with a specified value for certain entity properties. For example has_property={minecraft:climate_variant="temperate"}selects all temperate farm animals.

When the value is inverted using !, it’s expected that the check is inverted. That is to say, in this example, it should select all entities except temperate farm animals. However, what it actually selects is all entities with the minecraft:climate_variant property set to a non-temperate value, as well as entities with no properties. It fails to select entities that have properties, but don’t have the minecraft:climate_variant property. This table demonstrates the issue:

Mob

Positive check (=)

Negated check (=!)

Temperate cow
(has property, has value)

Match ✅

No match ✅

Cold pig
(has property, wrong value)

No match ✅

Match ✅

Armadillo
(doesn’t have property)

No match ✅

No match ❌

Goat
(no properties at all)

No match ✅

Match ✅

How to reproduce

  1. Spawn an armadillo and a goat

  2. Run /testfor @e[has_property={minecraft:climate_variant=!"temperate"}]

Expected result

Both entities should be found, since neither of them have the minecraft:climate_variant property set to temperate.

Observed result

Only the goat is found, since it has no properties at all. The armadillo is not found.

Notes

If it’s intended that all entities without the specified property are excluded, even when the value is negated, then the goat should be excluded as well. There is no reason that one should be found but not the other.

Comments 0

No comments.

tryashtar

(Unassigned)

1560701

Confirmed

Windows

26.10.21 Preview, 26.0

Retrieved