当前位置: 首页>>代码示例>>PHP>>正文


PHP level\ChunkManager类代码示例

本文整理汇总了PHP中pocketmine\level\ChunkManager的典型用法代码示例。如果您正苦于以下问题:PHP ChunkManager类的具体用法?PHP ChunkManager怎么用?PHP ChunkManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ChunkManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: populate

 public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random)
 {
     $chunk = $level->getChunk($chunkX, $chunkZ);
     for ($x = 0; $x < 16; ++$x) {
         for ($z = 0; $z < 16; ++$z) {
             $biome = Biome::getBiome($chunk->getBiomeId($x, $z));
             $cover = $biome->getGroundCover();
             if (count($cover) > 0) {
                 $diffY = 0;
                 if (!$cover[0]->isSolid()) {
                     $diffY = 1;
                 }
                 $column = $chunk->getBlockIdColumn($x, $z);
                 for ($y = 127; $y > 0; --$y) {
                     if ($column[$y] !== "" and !Block::get(ord($column[$y]))->isTransparent()) {
                         break;
                     }
                 }
                 $startY = min(127, $y + $diffY);
                 $endY = $startY - count($cover);
                 for ($y = $startY; $y > $endY and $y >= 0; --$y) {
                     $b = $cover[$startY - $y];
                     if ($column[$y] === "" and $b->isSolid()) {
                         break;
                     }
                     if ($b->getDamage() === 0) {
                         $chunk->setBlockId($x, $y, $z, $b->getId());
                     } else {
                         $chunk->setBlock($x, $y, $z, $b->getId(), $b->getDamage());
                     }
                 }
             }
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:35,代码来源:GroundCover.php

示例2: placeTrunk

 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);
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:12,代码来源:Tree.php

示例3: growGrass

 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]);
         }
     }
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:14,代码来源:TallGrass.php

示例4: placeObject

 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);
         //echo "ORE: $startX, $startY, $startZ,, $endX, $endY, $endZ\n";
         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) === 0) {
                                 $level->setBlockIdAt($x, $y, $z, $this->type->material->getId());
                                 if ($this->type->material->getDamage() !== 0) {
                                     $level->setBlockDataAt($x, $y, $z, $this->type->material->getDamage());
                                 }
                                 $level->updateBlockLight($x, $y, $z);
                                 //echo "Placed to $x, $y, $z\n";
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:49,代码来源:NetherOreTop.php

示例5: placeObject

 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     if ($this->leavesBottomY === -1 or $this->leavesMaxRadius === -1) {
         $this->findRandomLeavesSize($random);
     }
     $level->setBlockIdAt($x, $y - 1, $z, Block::DIRT);
     $leavesRadius = 0;
     for ($yy = $this->totalHeight; $yy >= $this->leavesBottomY; --$yy) {
         for ($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx) {
             for ($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz) {
                 if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) {
                     $level->setBlockIdAt($x + $xx, $y + $yy, $z + $zz, Block::LEAVES);
                     $level->setBlockDataAt($x + $xx, $y + $yy, $z + $zz, $this->type);
                 }
             }
         }
         if ($leavesRadius > 0 and $yy === $y + $this->leavesBottomY + 1) {
             --$leavesRadius;
         } elseif ($leavesRadius < $this->leavesMaxRadius) {
             ++$leavesRadius;
         }
     }
     for ($yy = 0; $yy < $this->totalHeight - 1; ++$yy) {
         $level->setBlockIdAt($x, $y + $yy, $z, Block::TRUNK);
         $level->setBlockDataAt($x, $y + $yy, $z, $this->type);
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:27,代码来源:SpruceTree.php

示例6: placeObject

 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     // The base dirt block
     $level->setBlockIdAt($x, $y, $z, Block::DIRT);
     // Adjust the tree trunk's height randomly
     //    plot [-14:11] int( x / 8 ) + 5
     //    - min=4 (all leaves are 4 tall, some trunk must show)
     //    - max=6 (top leaves are within ground-level whacking range
     //             on all small trees)
     $heightPre = $random->nextRange(-14, 11);
     $this->trunkHeight = intval($heightPre / 8) + 5;
     // Adjust the starting leaf density using the trunk height as a
     // starting position (tall trees with skimpy leaves don't look
     // too good)
     $leafPre = $random->nextRange($this->trunkHeight, 10) / 20;
     // (TODO: seed may apply)
     // Now build the tree (from the top down)
     $leaflevel = 0;
     for ($yy = $this->trunkHeight + 1; $yy >= 0; --$yy) {
         if ($leaflevel < self::$leavesHeight) {
             // The size is a slight variation on the trunkheight
             $radius = self::$leafRadii[$leaflevel] + $leafPre;
             $bRadius = 3;
             for ($xx = -$bRadius; $xx <= $bRadius; ++$xx) {
                 for ($zz = -$bRadius; $zz <= $bRadius; ++$zz) {
                     if (sqrt($xx ** 2 + $zz ** 2) <= $radius) {
                         $level->setBlockIdAt($x + $xx, $y + $yy, $z + $zz, Block::LEAVES);
                         $level->setBlockDataAt($x + $xx, $y + $yy, $z + $zz, $this->type);
                     }
                 }
             }
             $leaflevel++;
         }
         // Place the trunk last
         if ($leaflevel > 1) {
             $level->setBlockIdAt($x, $y + $yy, $z, Block::TRUNK);
             $level->setBlockDataAt($x, $y + $yy, $z, $this->type);
         }
     }
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:40,代码来源:SmallTree.php

示例7: placeObject

 public function placeObject(ChunkManager $level, $x, $y, $z, Random $random)
 {
     if ($this->leavesSizeY === -1 or $this->leavesAbsoluteMaxRadius === -1) {
         $this->findRandomLeavesSize($random);
     }
     $level->setBlockIdAt($x, $y - 1, $z, Block::DIRT);
     $leavesRadius = 0;
     $leavesMaxRadius = 1;
     $leavesBottomY = $this->totalHeight - $this->leavesSizeY;
     $firstMaxedRadius = \false;
     for ($leavesY = 0; $leavesY <= $leavesBottomY; ++$leavesY) {
         $yy = $this->totalHeight - $leavesY;
         for ($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx) {
             for ($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz) {
                 if (\abs($xx) != $leavesRadius or \abs($zz) != $leavesRadius or $leavesRadius <= 0) {
                     $level->setBlockIdAt($x + $xx, $y + $yy, $z + $zz, Block::LEAVES);
                     $level->setBlockDataAt($x + $xx, $y + $yy, $z + $zz, $this->type);
                 }
             }
         }
         if ($leavesRadius >= $leavesMaxRadius) {
             $leavesRadius = $firstMaxedRadius ? 1 : 0;
             $firstMaxedRadius = \true;
             if (++$leavesMaxRadius > $this->leavesAbsoluteMaxRadius) {
                 $leavesMaxRadius = $this->leavesAbsoluteMaxRadius;
             }
         } else {
             ++$leavesRadius;
         }
     }
     $trunkHeightReducer = $random->nextRange(0, 3);
     for ($yy = 0; $yy < $this->totalHeight - $trunkHeightReducer; ++$yy) {
         $level->setBlockIdAt($x, $y + $yy, $z, Block::TRUNK);
         $level->setBlockDataAt($x, $y + $yy, $z, $this->type);
     }
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:36,代码来源:PineTree.php

示例8: getAvailableBlockSpace

 private function getAvailableBlockSpace(ChunkManager $level, Vector3 $from, Vector3 $to)
 {
     $count = 0;
     $iter = new VectorIterator($level, $from, $to);
     while ($iter->valid()) {
         $iter->next();
         $pos = $iter->current();
         if (!isset($this->overridable[$level->getBlockIdAt($pos->x, $pos->y, $pos->z)])) {
             return $count;
         }
         $count++;
     }
     return -1;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:14,代码来源:BigTree.php

示例9: generateChunk

 public function generateChunk($chunkX, $chunkZ)
 {
     if ($this->emptyChunk !== null) {
         //Use the cached empty chunk instead of generating a new one
         $this->chunk = clone $this->emptyChunk;
     } else {
         $this->chunk = clone $this->level->getChunk($chunkX, $chunkZ);
         $this->chunk->setGenerated();
         $c = Biome::getBiome(1)->getColor();
         $R = $c >> 16;
         $G = $c >> 8 & 0xff;
         $B = $c & 0xff;
         for ($Z = 0; $Z < 16; ++$Z) {
             for ($X = 0; $X < 16; ++$X) {
                 $this->chunk->setBiomeId($X, $Z, 1);
                 $this->chunk->setBiomeColor($X, $Z, $R, $G, $B);
                 for ($y = 0; $y < 128; ++$y) {
                     $this->chunk->setBlockId($X, $y, $Z, Block::AIR);
                 }
             }
         }
         $spawn = $this->getSpawn();
         if ($spawn->getX() >> 4 === $chunkX and $spawn->getZ() >> 4 === $chunkZ) {
             $this->chunk->setBlockId(0, 64, 0, Block::GRASS);
         } else {
             $this->emptyChunk = $this->chunk;
         }
     }
     $chunk = clone $this->chunk;
     $chunk->setX($chunkX);
     $chunk->setZ($chunkZ);
     $this->level->setChunk($chunkX, $chunkZ, $chunk);
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:33,代码来源:Void.php

示例10: getHighestWorkableBlock

 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 0; $y <= 127; ++$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b == Block::AIR) {
             break;
         }
     }
     return $y === 0 ? -1 : $y;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:10,代码来源:GroundFire.php

示例11: getHighestWorkableBlock

 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;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:10,代码来源:LilyPad.php

示例12: getHighestWorkableBlock

 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 127; $y >= 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b == 0) {
             break;
         }
     }
     return $y === 0 ? -1 : ++$y;
 }
开发者ID:xpyctum,项目名称:Genisys,代码行数:10,代码来源:NetherGrowStone.php

示例13: getHighestWorkableBlock

 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;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:12,代码来源:Tree.php

示例14: getHighestWorkableBlock

 private function getHighestWorkableBlock($x, $z)
 {
     for ($y = 128; $y > 0; --$y) {
         $b = $this->level->getBlockIdAt($x, $y, $z);
         if ($b === Block::AIR or $b === Block::LEAVES) {
             if (--$y <= 0) {
                 return -1;
             }
         } else {
             break;
         }
     }
     return ++$y;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:14,代码来源:TallGrass.php

示例15: populateChunk

 public function populateChunk($chunkX, $chunkZ)
 {
     $this->random->setSeed(0.0 ^ $chunkX << 8 ^ $chunkZ ^ $this->level->getSeed());
     foreach ($this->populators as $populator) {
         $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
     }
 }
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:7,代码来源:Flat.php


注:本文中的pocketmine\level\ChunkManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。