Getting light level from skylight.

Discussion in 'Plugin Development' started by Josvth, Apr 20, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Josvth

    Okay I'm a little bit stuck on something that shouldn't be this hard.

    I want to get the light level from a block and use that to see if it's day or night. There is a method .getLightFromSky() but this doesn't return the light level based on day or night but it returns how far this block is in the shade. Meaning 15 is directly under the sky, 14 is one block in the shade etc. So day or night has no influence on this method.

    There are also .getLightLevel() and .getLightLevelFromBlocks() and I thought that subtracting these would give me the light from the sky. But this doesn't work either.

    Am I missing something completely here?
     
  2. Offline

    Njol

    Why don't you use the world's time to find out whether it's day or night?
     
    Josvth likes this.
  3. Offline

    Josvth

    Ahh, thanks! The solution lies in the combination of time and light level. When the time is between 0 en 12000 the surface light level will be 15 and for each block it will be the .getLightFromSky(). After 12000 it becomes darker and you can use .getLightLevel() - .getLightLevelFromBlocks() .
     
Thread Status:
Not open for further replies.

Share This Page