Light levels 0-4 are treated as one light level, so it is impossible to differentiate between those five values. For example, when trying to detect a light level specifically of 4, any actual light level of 0, 1, 2, 3, or 4 will return as true.
Worse when trying to detect only a value of 0, which will return false even if the light is actually 0! It is thus impossible to detect absolute darkness of 0, which is what I was trying to do when I discovered this bug.
Only values above 5 can be successfully specifically tested for.
Predicate gatkong:dark
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"location": {
"light": {
"light": 0
}
}
}
}
execute at @s if predicate gatkong:dark run say dark
edit to add: It appears this is only true on the surface (exposed to sky). Underground (no visible sky) one can accurately detect darkness of 0 etc.
edit #2: It appears night darkness exposed to sky displays in f3 as (12 sky, 0 block) but predicate tests as 4.
Comments 3
I suppose the bug is then that the f3 screen shows light level of (15 sky, 0 block) at night, but the light level is predicate testing as 4. Either the predicate is reading the sky/block light wrong, or the f3 screen is displaying it wrong, depending on which is actually working as intended. I will amend the bug report title.
As you noted, sky light is factored in