Getting lightlevel of player

Discussion in 'Plugin Development' started by r3Fuze, Aug 11, 2011.

Thread Status:
Not open for further replies.
  1. I need to find the lightlevel of a player for my plugin, i tried getting the lightlevel of the block below the player, it only returns 0 or 15 though..
    I would love if someone could help me!
     
  2. Offline

    Crash

    byte level = player.getLocation().getBlock().getLightLevel();

    The block under the player is the ground which will be a light level of 0
     
  3. Offline

    bergerkiller

    Yup you need to check the light level of the block above (air). (just checked it in the craftbook IC coding.)

    Code:
    Location loc = player.getLocation().add(0, 1, 0);
    int level = loc.getBlock().getLightLevel();
    (written from scratch)
     
  4. Wow, didn't think of that. And it worked, thanks!

    Thats pretty much what i did but it didn't work.
    But since @bergerkiller 's code worked, theres no need to think more about it :)
     
  5. Offline

    bergerkiller

    Waaiiit do check if it works, I didn't guarantee it to work. (although it may have seemed like it)
    Only compared it to some working piece of code, which did that. :p
     
Thread Status:
Not open for further replies.

Share This Page