mojira.dev
MC-311656

Predicate block state checks fail for min or max values outside the block's accepted range

Expected behaviour

“min” and “max” checks on block states should work regardless of whether “min” and “max” are achievable values for the respective block.

Observed behaviour

/setblock ~ ~ ~ carrots[age=1]
/execute if predicate {type:"minecraft:location_check",predicate:{block:{state:{age:{max:"8"}}}}}

The predicate check fails, even though 8 is a valid “age” for multiple other blocks, and 1 <= 8.

/setblock ~ ~ ~ sugar_cane[age=1] strict
/execute if predicate {type:"minecraft:location_check",predicate:{block:{state:{age:{max:"8"}}}}}

Now the predicate check succeeds.

/setblock ~ ~ ~ carrots[age=1]
/execute if predicate {type:"minecraft:location_check",predicate:{block:{state:{age:{min:"-1"}}}}}

The predicate check fails, even though 1 >= -1.

Especially the “max” situation makes it very hard to use the predicate in real situations, as we would need to hardcode which blocks have which max value, and run different predicates depending on that.

Comments 1

Confirmed.

Code analysis:
https://mcsrc.dev/2/26.3-pre-2/net/minecraft/advancements/predicates/StatePropertiesPredicate#L150

The game looks up the values of min and max in the property’s definition so it can compare them to the block’s own value. Since this check works for any property, not just numeric ones, it seems like this lookup is unavoidable, which makes a fix challenging.

SilicatYT

(Unassigned)

Confirmed

26.3 Pre-Release 1

Retrieved