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

SetBlock área

Discussion in 'Development' started by TGames, Feb 18, 2019.

  1. TGames

    TGames Silverfish

    Messages:
    18
    Hi, I wanted to know what's wrong. I want to clean a 7x7 area of blocks, but it's not clean. how I achieve it. this is my code!
    Code:
    public function setReset(string $arena, $update = false) {
                $config = new Config($this->plugin->getDataFolder() . "/config.yml", Config::YAML);
                $levelArena = $this->plugin->getServer()->getLevelByName($arena);
                $lg = $config->get($arena."lobby");
                if($levelArena instanceof Level) {
                    for($spawn=1; $spawn<=8; $spawn++) {
                        $spawners = $config->get($arena."Spawn".$spawn);
                        for($piso=1; $piso<=7; $piso++) {
                $levelArena->setBlock(new Vector3($spawners[0]-3,$spawners[1]+$spawn,$spawners[2]-4+$piso), Block::get(0),$update,$update);
                $levelArena->setBlock(new Vector3($spawners[0]-2,$spawners[1]+$spawn,$spawners[2]-4+$piso), Block::get(0),$update,$update);
                $levelArena->setBlock(new Vector3($spawners[0]-1,$spawners[1]+$spawn,$spawners[2]-4+$piso), Block::get(0),$update,$update);
                $levelArena->setBlock(new Vector3($spawners[0],$spawners[1]+$spawn,$spawners[2]-4+$piso), Block::get(0),$update,$update);
                $levelArena->setBlock(new Vector3($spawners[0]+1,$spawners[1]+$spawn,$spawners[2]-4+$piso), Block::get(0),$update,$update);
                $levelArena->setBlock(new Vector3($spawners[0]+2,$spawners[1]+$spawn,$spawners[2]-4+$piso), Block::get(0),$update,$update);
                $levelArena->setBlock(new Vector3($spawners[0]+3,$spawners[1],$spawners[2]-4+$piso), Block::get(0),$update,$update);
                }
          }
    }
     
  2. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you must set the 3rd parameter (update) to true
     
  3. TGames

    TGames Silverfish

    Messages:
    18
    It did not work: 'v
     
  4. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    do var_dump($spawners); and see if that's the area you're standing in
     
  5. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Is your level loaded?
    Did you use pocketmine/level/Level?
    By not clean, do you mean some blocks remain or all blocks are left untouched?
     
  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.