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?

1 Answer 1


This method is also a fairly bad kludge and a bit impractical, but it should be able to detect block light as well as sunlight.

There are a few of processes that only occur at certain light levels, sunlight or not:

Event            || Light Level
Snow/ice melt    || >=12
Mushrooms uproot || >=13
Flowers uproot   || <=7
Plants grow      || <=9

With a very high /gamerule randomTickSpeed, these processes can happen almost immediately. Obvious disadvantage here is that the gamerule will also effect the processes throughout the entire world.

Different mobs also have different spawning light levels:

Mob              || Light Level
Bats             || <=3
Most hostiles    || <=7
Blaze/silverfish || <=11
Most passives    || >=9

You can also create custom mob spawners will spawn a mob every tick by changing its MinSpawnDelay and MaxSpawnDelay.

Using either of these methods (or both), what you'd need to do is something like:

  1. Clone blocks around the block/player to a specific area
  2. Set the block/spawner in the middle of the newly cloned area
  3. Wait a few ticks
  4. Test if a mob has spawned, or a process occurred

You could also have the mob spawner (minecart) or test block at the actual player's location, rather than cloning it first, which would reduce lag a lot but cause the player to see flickering mobs/blocks.

  • Yeah, the idea is to run this on a repeating command block, and if I think using a daylight sensor is a bit of a kludge, what does that make this?
    – MBraedley
    Commented Sep 27, 2015 at 17:26
  • Also, this really only tests an area, not a particular block.
    – MBraedley
    Commented Sep 27, 2015 at 17:31
  • @MBraedley It does test a particular block; the one that you're setting to wheat/ice/whatever. The rest of the area is only cloned as to get the same light level at that block. It is a bad kludge, as I say in the answer, but works for blocklight which a daylight sensor does not. AFAIK it's the only real way of doing it.
    – SirBenet
    Commented Sep 27, 2015 at 19:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .