コード例 #1
0
ファイル: TallGrass.php プロジェクト: MunkySkunk/BukkitPE
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 127; $y >= 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER) {
             break;
         }
     }
     return $y === 0 ? -1 : ++$y;
 }
コード例 #2
0
ファイル: Tree.php プロジェクト: MunkySkunk/BukkitPE
 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 127; $y > 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b === Block::DIRT or $b === Block::GRASS) {
             break;
         } elseif ($b !== 0 and $b !== Block::SNOW_LAYER) {
             return -1;
         }
     }
     return ++$y;
 }
コード例 #3
0
ファイル: TallGrass.php プロジェクト: MunkySkunk/BukkitPE
 public static function growGrass(ChunkManager $level, Vector3 $pos, Random $random, $count = 15, $radius = 10)
 {
     $arr = [[Block::DANDELION, 0], [Block::POPPY, 0], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1], [Block::TALL_GRASS, 1]];
     $arrC = count($arr) - 1;
     for ($c = 0; $c < $count; ++$c) {
         $x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
         $z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
         if ($level->getBlockIdAt($x, $pos->y + 1, $z) === Block::AIR and $level->getBlockIdAt($x, $pos->y, $z) === Block::GRASS) {
             $t = $arr[$random->nextRange(0, $arrC)];
             $level->setBlockIdAt($x, $pos->y + 1, $z, $t[0]);
             $level->setBlockDataAt($x, $pos->y + 1, $z, $t[1]);
         }
     }
 }
コード例 #4
0
ファイル: Ore.php プロジェクト: MunkySkunk/BukkitPE
 public function placeObject(ChunkManager $level, $x, $y, $z)
 {
     $clusterSize = (int) $this->type->clusterSize;
     $angle = $this->random->nextFloat() * M_PI;
     $offset = VectorMath::getDirection2D($angle)->multiply($clusterSize)->divide(8);
     $x1 = $x + 8 + $offset->x;
     $x2 = $x + 8 - $offset->x;
     $z1 = $z + 8 + $offset->y;
     $z2 = $z + 8 - $offset->y;
     $y1 = $y + $this->random->nextBoundedInt(3) + 2;
     $y2 = $y + $this->random->nextBoundedInt(3) + 2;
     for ($count = 0; $count <= $clusterSize; ++$count) {
         $seedX = $x1 + ($x2 - $x1) * $count / $clusterSize;
         $seedY = $y1 + ($y2 - $y1) * $count / $clusterSize;
         $seedZ = $z1 + ($z2 - $z1) * $count / $clusterSize;
         $size = ((sin($count * (M_PI / $clusterSize)) + 1) * $this->random->nextFloat() * $clusterSize / 16 + 1) / 2;
         $startX = (int) ($seedX - $size);
         $startY = (int) ($seedY - $size);
         $startZ = (int) ($seedZ - $size);
         $endX = (int) ($seedX + $size);
         $endY = (int) ($seedY + $size);
         $endZ = (int) ($seedZ + $size);
         for ($x = $startX; $x <= $endX; ++$x) {
             $sizeX = ($x + 0.5 - $seedX) / $size;
             $sizeX *= $sizeX;
             if ($sizeX < 1) {
                 for ($y = $startY; $y <= $endY; ++$y) {
                     $sizeY = ($y + 0.5 - $seedY) / $size;
                     $sizeY *= $sizeY;
                     if ($y > 0 and $sizeX + $sizeY < 1) {
                         for ($z = $startZ; $z <= $endZ; ++$z) {
                             $sizeZ = ($z + 0.5 - $seedZ) / $size;
                             $sizeZ *= $sizeZ;
                             if ($sizeX + $sizeY + $sizeZ < 1 and $level->getBlockIdAt($x, $y, $z) === 1) {
                                 $level->setBlockIdAt($x, $y, $z, $this->type->material->getId());
                                 if ($this->type->material->getDamage() !== 0) {
                                     $level->setBlockDataAt($x, $y, $z, $this->type->material->getDamage());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: Tree.php プロジェクト: MunkySkunk/BukkitPE
 protected function placeTrunk(ChunkManager $level, $x, $y, $z, Random $random, $trunkHeight)
 {
     // The base dirt block
     $level->setBlockIdAt($x, $y - 1, $z, Block::DIRT);
     for ($yy = 0; $yy < $trunkHeight; ++$yy) {
         $blockId = $level->getBlockIdAt($x, $y + $yy, $z);
         if (isset($this->overridable[$blockId])) {
             $level->setBlockIdAt($x, $y + $yy, $z, $this->trunkBlock);
             $level->setBlockDataAt($x, $y + $yy, $z, $this->type);
         }
     }
 }