Example #1
0
 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     $this->treeHeight = $random->nextBoundedInt(3) + 5;
     if ($this->superBirch) {
         $this->treeHeight += 5;
     }
     parent::placeObject($level, $x, $y, $z, $random);
 }
Example #2
0
 public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random)
 {
     $this->level = $level;
     $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
     for ($i = 0; $i < $amount; ++$i) {
         $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
         $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
         $y = $this->getHighestWorkableBlock($x, $z);
         if ($y === -1) {
             continue;
         }
         ObjectTree::growTree($this->level, $x, $y, $z, $random, $this->type);
     }
 }
Example #3
0
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         if ($this->getSide(0)->isTransparent() === true) {
             $this->getLevel()->useBreakOn($this);
             return Level::BLOCK_UPDATE_NORMAL;
         }
     } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
         //Growth
         if (mt_rand(1, 7) === 1) {
             if (($this->meta & 0x8) === 0x8) {
                 Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->meta & 0x7);
             } else {
                 $this->meta |= 0x8;
                 $this->getLevel()->setBlock($this, $this, true);
                 return Level::BLOCK_UPDATE_RANDOM;
             }
         } else {
             return Level::BLOCK_UPDATE_RANDOM;
         }
     }
     return false;
 }
Example #4
0
 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     $this->treeHeight = $random->nextBoundedInt(3) + 4;
     parent::placeObject($level, $x, $y, $z, $random);
 }