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); } }
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; }