1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Light level of random locations

Discussion in 'Development' started by Sandertv, Dec 11, 2016.

  1. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Hello!
    I'm working on a monster generator and I have to get the light level of a random location, and if it meets light level 7 or lower (and other requirements) it should spawn a monster. I'm struggling however with getting the light level of the positions.
    I have tried several ways to get the light level, but it didn't work the way I wanted. I var_dumped several ways:
    PHP:
    var_dump($level->getBlockLightAt($x$y$z)); //returns int 0, or higher if light source is near.
    var_dump($level->getBlockSkyLightAt($x$y$z)); //returns int 0 or higher if light source is near as well! 
    I'm not sure what I'm doing wrong, or if this is a PocketMine issue, but it would be greatly appreciated if someone could look at it. If you want the full code, here it is: https://github.com/RevivalPMMP/Pure...icode/pureentities/task/AutoSpawnTask.php#L66
    I need to get the light level the block has with the actual sky light added to it.

    Thanks in advance!
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Sandertv likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.