I want to build a set of command blocks that will automatically place a torch at the foot of a player (or entity) when the light level falls below a certain threshold. So basically I need to be able to determine the light level at a player using command blocks.
I've looked the some of the wiki pages on NBT data to see if the light level is stored with the block, so I could do something like /execute @p ~ ~ ~ testforblock ~ ~ ~ minecraft:air 0 {dataTagForLight:3b}
, but there doesn't seem to be any such data tag.
I've considered spawning a daylight detector, but I have a feeling it won't do what I want it to do while in caves, since as far as I can tell, in the primary mode, it's only affected by sunlight. Plus there's other issue with the plan, and it just feels like a kludge.
So, is there a way to determine the light level of a given block? If so, how?