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

Solved How to set a block / remove a block

Discussion in 'Development' started by Miste, Jul 21, 2017.

  1. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    Hello,
    I am trying to set a new block where there is actually one.
    This my code but he doesn't work and I really don't know why.
    I tried with and without
    PHP:
    $level->doChunkGarbageCollection();
    but it doesn't work.
    I checked I have all the use I need and the $level isn't null and $x $y $z var aren't null too.
    PHP:
    $level $this->pg->getServer()->getLevelByName($world);
    $level->setBlock(new Vector3($x$y$z), Block::get(0), truetrue);
    $level->doChunkGarbageCollection();
    Thanks for the help !
     
    Last edited: Jul 21, 2017
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You don't need to call doChunkGarbageCollection(), you can directly...
    PHP:
    $level->setBlock(new Vector3($x$y$z), Block::get(Block::AIR));
     
    Last edited: Aug 12, 2017
    Levi and BranDev like this.
  3. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    Well, you don't read my post I tried with and without doChunkGarbageCollection() and first without.

     
  4. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    Fixed, I was trying to set a block who is already Air ^^
     
  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.