Exemple #1
0
 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     $this->treeHeight = $random->nextBoundedInt(4) + 6;
     $topSize = $this->treeHeight - (1 + $random->nextBoundedInt(2));
     $lRadius = 2 + $random->nextBoundedInt(2);
     $this->placeTrunk($level, $x, $y, $z, $random, $this->treeHeight - $random->nextBoundedInt(3));
     $radius = $random->nextBoundedInt(2);
     $maxR = 1;
     $minR = 0;
     for ($yy = 0; $yy <= $topSize; ++$yy) {
         $yyy = $y + $this->treeHeight - $yy;
         for ($xx = $x - $radius; $xx <= $x + $radius; ++$xx) {
             $xOff = abs($xx - $x);
             for ($zz = $z - $radius; $zz <= $z + $radius; ++$zz) {
                 $zOff = abs($zz - $z);
                 if ($xOff === $radius and $zOff === $radius and $radius > 0) {
                     continue;
                 }
                 if (!Block::$solid[$level->getBlockIdAt($xx, $yyy, $zz)]) {
                     $level->setBlockIdAt($xx, $yyy, $zz, $this->leafBlock);
                     $level->setBlockDataAt($xx, $yyy, $zz, $this->type);
                 }
             }
         }
         if ($radius >= $maxR) {
             $radius = $minR;
             $minR = 1;
             if (++$maxR > $lRadius) {
                 $maxR = $lRadius;
             }
         } else {
             ++$radius;
         }
     }
 }
Exemple #2
0
 public static function growTree(ChunkManager $level, $x, $y, $z, Random $random, $type = 0)
 {
     switch ($type) {
         case Sapling::SPRUCE:
             $tree = new SpruceTree();
             break;
         case Sapling::BIRCH:
             if ($random->nextBoundedInt(39) === 0) {
                 $tree = new BirchTree(true);
             } else {
                 $tree = new BirchTree();
             }
             break;
         case Sapling::JUNGLE:
             $tree = new JungleTree();
             break;
         case Sapling::OAK:
         default:
             $tree = new OakTree();
             /*if($random->nextRange(0, 9) === 0){
             			$tree = new BigTree();
             		}else{*/
             //}
             break;
     }
     if ($tree->canPlaceObject($level, $x, $y, $z, $random)) {
         $tree->placeObject($level, $x, $y, $z, $random);
     }
 }
Exemple #3
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);
 }
Exemple #4
0
 public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random)
 {
     if ($random->nextRange(0, $this->waterOdd) === 0) {
         $x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 16);
         $y = $random->nextBoundedInt(128);
         $z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 16);
         $pond = new \BukkitPE\level\generator\object\Pond($random, new Water());
         if ($pond->canPlaceObject($level, $x, $y, $z)) {
             $pond->placeObject($level, $x, $y, $z);
         }
     }
 }
Exemple #5
0
 public function __construct(Random $random, $octaves, $persistence, $expansion = 1)
 {
     $this->octaves = $octaves;
     $this->persistence = $persistence;
     $this->expansion = $expansion;
     $this->offsetX = $random->nextFloat() * 256;
     $this->offsetY = $random->nextFloat() * 256;
     $this->offsetZ = $random->nextFloat() * 256;
     for ($i = 0; $i < 512; ++$i) {
         $this->perm[$i] = 0;
     }
     for ($i = 0; $i < 256; ++$i) {
         $this->perm[$i] = $random->nextBoundedInt(256);
     }
     for ($i = 0; $i < 256; ++$i) {
         $pos = $random->nextBoundedInt(256 - $i) + $i;
         $old = $this->perm[$i];
         $this->perm[$i] = $this->perm[$pos];
         $this->perm[$pos] = $old;
         $this->perm[$i + 256] = $this->perm[$i];
     }
 }
Exemple #6
0
 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     $this->treeHeight = $random->nextBoundedInt(3) + 4;
     parent::placeObject($level, $x, $y, $z, $random);
 }