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

fixing light over all the map

Discussion in 'Development' started by udwarf, Aug 7, 2017.

  1. udwarf

    udwarf Silverfish

    Messages:
    21
    Hello, pmmp developers,
    Sorry if this question was already answered here, couldn't find a solution over all the forum

    I'm trying to fix lighting on my map. There many blocks that are dark despite the fact that there is a torch next to them. I want to recalculate lighting once and save the fixed map, but I can not succeed.
    I'm simply iterating over all blocks in some wrongly dark area:
    PHP:
                $lv Server::getInstance()->getDefaultLevel();
                for (
    $px 80$px <= 110$px++) {
                    echo 
    "$px\n";
                    for (
    $py 0$py <= 120$py++) {
                        for (
    $pz 80$pz <= 110$pz++) {
                            
    $bId $lv->getBlockIdAt($px$py$pz);
                            
    //if ($bId != Block::AIR) {  //shoud  i recalculate light for air?
                                
    $lv->updateAllLight(new Vector3($px$py$pz));
                            
    //}

                        
    }

                    }

                }
    But nothing changes!
    I assumed that maybe client do not see changes because chuks are already sent to him, but after "save-all" command and relogin to the server - still no changes
    What did I missed?

    Thank you in advance
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Are you certain that you have lighting updates turned on in the pocketmine.yml?
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    That would not interfere with his code.
    Your code seems to be fine, check that it is really iterrating over the right coordinates.
     
    jasonwynn10 likes this.
  4. udwarf

    udwarf Silverfish

    Messages:
    21
    Well, I've fixed my map
    Not sure if it was optimal, but anyway...
    Light was recalculated correctly after this code implemented to each block:
    PHP:
                                    $ll $lv->getFullLight($pos);
                                    
    $lv->setBlockLightAt($px$py$pz$ll);
                                    
    $lv->updateAllLight($pos);
    the trick is to get/set light level. That worked for me
     
  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.