Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved SetBlockIdAt

Comments in 'Plugin Development' started by Cristalix, Apr 20, 2016.

  1. Cristalix
    Offline

    Cristalix New Member

    Joined:
    Sep 10, 2015
    Posts:
    38
    Minecraft User:
    Gistrec
    [​IMG]
    Server write message, but don't set block :c
    Whyyyyy :'c


    PHP:
    if($block->getId() == 121){
                 if ((
    $x == $this->pos["red"]["x"]) and ($y == $this->pos["red"]["y"]) and ($z == $this->pos["red"]["z"])){
                     if (
    $this->team[$player] == "red"){
                         
    $event->setCancelled(true);
                     } else {
                         
    $this->getServer()->getDefaultLevel()->setBlockIdAt($x$y$z$id);
                         
    $this->lifeR--;
                         if (
    $this->lifeR <= 0){
                             
    $this->EndGame();
                         } 
                         
    $this->getServer()->broadcastMessage("§cУ красного нексуса осталось ".$this->lifeR." жизней!");
                     }
                    
                 } elseif ((
    $x == $this->pos["green"]["x"]) and ($y == $this->pos["green"]["y"]) and ($z == $this->pos["green"]["z"])){
                     if (
    $this->team[$player] == "green"){
                         
    $event->setCancelled(true);
                     } else {
                         
    $this->getServer()->getDefaultLevel()->setBlockIdAt($x$y$z$id);
                         
    $this->lifeG--;
                         if (
    $this->lifeG <= 0){
                             
    $this->EndGame();
                        } 
                         
    $this->getServer()->broadcastMessage("§aУ зеленого нексуса осталось ".$this->lifeG." жизней!");
                     }
                 }
             }
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Any error? Is $id defined?
  3. Cristalix
    Offline

    Cristalix New Member

    Joined:
    Sep 10, 2015
    Posts:
    38
    Minecraft User:
    Gistrec
    $id = 121;
    No error :c
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Why don't you use
    PHP:
    \pocketmine\level\Level\setBlock(Vector3 $posBlock $block);
  5. Cristalix
    Offline

    Cristalix New Member

    Joined:
    Sep 10, 2015
    Posts:
    38
    Minecraft User:
    Gistrec
    I will use setCancelled(true);
    Couse it simply!
    Thanks all
  6. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    if you need to use setBlockIdAt you should unload and then load the chunk
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You never told us what you're doing and in what scope you are.
    Cristalix and CraftYourBukkit like this.

Share This Page

Advertisement