getLightLevel() problem

Discussion in 'Plugin Development' started by eisental, Feb 6, 2011.

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

    eisental

    I'm having trouble getting the light level of blocks.
    I've been trying to use something like this:
    Code:
            Block block = world.getBlockAt(location.getBlockX() location.getBlockY(), location.getBlockZ());
            int level = block.getLightLevel();
    
    The light level is always 0 no matter if its day or night or if I put any torches around it.
    Any help would be very appreciated...
     
  2. Offline

    Archelaus

    Get it from a block side.
     
  3. Offline

    eisental

    Sorry, I really don't understand what you mean :)
    I have a Location object with some x,y,z coords of a block.
     
  4. Offline

    Archelaus

    Look at a block in game, the light level isn't the same on all the sides, is it? You need to do ".getLightLevel()" on one of the sides of the block. As these have light level on them.
     
  5. Offline

    eisental

    I see, so basically the getLightLevel() will only work for Air blocks?

    EDIT: Ok, tested and it works. Thanks a lot for answering so quickly.
     
  6. Offline

    ursa_arcadius

    For my plugin I only take the light level on a block of air. If it is not a block of air I will look for one close by
     
  7. Offline

    robhol

    You don't need air, AFAIK; as long as the block is "pass-through" (maybe even see-through, although it hasn't been tested) it should work just fine.
     
Thread Status:
Not open for further replies.

Share This Page