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

Read Desc.

Comments in 'Plugin Development' started by TheBison_, Apr 11, 2016.

  1. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Does someone know why this function spawns Chests only at y = 128?

    PHP:
    public function generateChest(Level $level)
        {
            
    $x mt_rand(-200200);
            
    $z mt_rand(-200200);
           
            
    $catch = [19];
           
            for(
    $y=1$y<=128$y++)
            {
                if(
    in_array($level->getBlockIdAt($x$y$z), $catchtrue))
                {           
                    
    $block = new \pocketmine\block\Chest();
                    
    $level->setBlock(new Vector3($x$y-1$z), $blocktruetrue);
                    
    $nbt = new Compound("", [
                            new 
    Enum("Items", []),
                            new 
    String("id"Tile::CHEST),
                            new 
    Int("x"$x),
                            new 
    Int("y"$y),
                            new 
    Int("z"$z)
                                ]);
                    
    $nbt->Items->setTagType(NBT::TAG_Compound);
                    
    $tile Tile::createTile("Chest"$level->getChunk($block->getX() >> 4$block->getZ() >> 4), $nbt);
                    
    $tile->getInventory()->clearAll();
                    for(
    $i=0;$i<=26;$i++)
                    {
                        
    $rand mt_rand(15);
                        if(
    $rand === 1)
                        {
                            
    $items = array
                            (
                                
    Item::get(29801),
                                
    Item::get(29901),
                                
    Item::get(30001),
                                
    Item::get(30101),
                                
    Item::get(26801),
                                
    Item::get(27101),

                                
    Item::get(29701),

                                
    Item::get(39301),
                                
    Item::get(39303),

                                
    Item::get(26501),
                                
    Item::get(26503),
                                
    Item::get(26508),

                                
    Item::get(26601),
                                
    Item::get(26603),

                                
    Item::get(26401),
                                
    Item::get(26402),

                                
    Item::get(27201),

                                
    Item::get(32001),
                                
    Item::get(32003),

                                
    Item::get(36401),
                                
    Item::get(36403),

                                
    Item::get(36601),
                                
    Item::get(36603),

                                
    Item::get(Item::COMPASS01),
                                
    Item::get(Item::COMPASS01)
                            );
                                
    $itemRnd mt_rand(0count($items)-1);
                                
    $item $items[$itemRnd];

                                
    $tile->getInventory()->setItem($i$item);
                            } else {
                                
    $tile->getInventory()->setItem($iItem::get(001));
                            }
                        }
                    }
                }    
               
                
    $this->getServer()->broadcastMessage($x " " $y " " $z);
        }
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    Maybe condition is false? Anyway try to debug your code it should help you
  3. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_

Share This Page

Advertisement