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

How do I set blocks in void levels?

Discussion in 'Development' started by InxGaming, Jul 30, 2017.

  1. InxGaming

    InxGaming Spider

    Messages:
    14
    So I generated a void type of a world which means there are absolutely no other blocks in it but only air in the first place. I tried generating a structure at some coordinates using $level->setBlock($pos, $block) where $level is an instance of Level, $pos is an instance of Vector3 and $block is an instance of Block. This code does not give any errors but it is just not generating the block in the world. Help please
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Are you sure you have put a block from 1 to 255?

    If yes, give us your code. This may help us to find out what is going wrong...
     
    Last edited by a moderator: Aug 2, 2017
  3. InxGaming

    InxGaming Spider

    Messages:
    14
    This is my code :
    PHP:
            for ($x $coords['x'] - $size$x <= $coords['x'] + $size$x++)
            {
                for (
    $z $coords['z'] - $size$z <= $coords['z'] + $size$z++)
                {
                    
    $level->setBlock(new Vector3($x$coords['y'], $z), Block::get(2));
                    for(
    $y $coords['y'] - 1$y >= $coords['y'] - $size$y--)
                    {
                        
    $level->setBlock(new Vector3($x$y$z), Block::get(3));
                    }
                }
            }
    There
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    what about
    PHP:
    $x=2
    $y
    =43
    $z
    =134
    $level
    ->setBlock(new Vector3($x$y$z), Block::get(3));
     
    Last edited: Aug 5, 2017
  5. InxGaming

    InxGaming Spider

    Messages:
    14
    That is not the issue I have. $coords['x'], $coords['y'] and $coords['z'] are all instance of int. The player is even being teleported later on to these coordinates without a problem. I assure you, the problem is not in the coordinates.
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    The code you showed has no obvious problems. The problem must be in your setup, such as wrong configuration, etc. Dump some debug info to make sure you set the block at your intended coordinates.
     
  7. InxGaming

    InxGaming Spider

    Messages:
    14
    mes.png
    It says the block is being generated at the specified random coordinates, however when I go to these coordinates, there is nothing there except air
     
  8. InxGaming

    InxGaming Spider

    Messages:
    14
    Okay this makes absolutely no sense. I did debug, everything is ok. $level->setBlock() just doesn't set the block. I didn't have such issues on a normal world

    Edit: (can someone move this outside of facepalm? I accidently placed it here lol)
     
    Last edited: Jul 31, 2017
    jasonwynn10 likes this.
  9. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    After Placing the blocks try go to another world and back :D Maybe it will be there then
     
  10. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Send the output of var_dump(get_class($level));
     
    jasonwynn10 and Awzaw like this.
  11. InxGaming

    InxGaming Spider

    Messages:
    14
    string(22) "pocketmine\level\Level"
     
  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.