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


PHP FullChunk::setBlockId方法代码示例

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


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

示例1: 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

示例2: parsePreset

 protected function parsePreset($preset)
 {
     $this->preset = $preset;
     $preset = explode(";", $preset);
     $version = (int) $preset[0];
     $blocks = @$preset[1];
     $biome = isset($preset[2]) ? $preset[2] : 1;
     $options = isset($preset[3]) ? $preset[3] : "";
     preg_match_all('#(([0-9]{0,})x?([0-9]{1,3}:?[0-9]{0,2})),?#', $blocks, $matches);
     $y = 0;
     $this->structure = [];
     $this->chunks = [];
     foreach ($matches[3] as $i => $b) {
         $b = Item::fromString($b);
         $cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
         for ($cY = $y, $y += $cnt; $cY < $y; ++$cY) {
             $this->structure[$cY] = [$b->getID(), $b->getDamage()];
         }
     }
     $this->floorLevel = $y;
     for (; $y < 0xff; ++$y) {
         $this->structure[$y] = [0, 0];
     }
     $this->chunk = $this->level->getChunk(0, 0);
     $this->chunk->setGenerated();
     for ($Z = 0; $Z < 16; ++$Z) {
         for ($X = 0; $X < 16; ++$X) {
             for ($y = 0; $y < 128; ++$y) {
                 if ($this->structure[$y][0] !== 0) {
                     $this->chunk->setBlockId($X, $y, $Z, $this->structure[$y][0]);
                 }
                 if ($this->structure[$y][0] !== 0) {
                     $this->chunk->setBlockData($X, $y, $Z, $this->structure[$y][1]);
                 }
             }
         }
     }
     preg_match_all('#(([0-9a-z_]{1,})\\(?([0-9a-z_ =:]{0,})\\)?),?#', $options, $matches);
     foreach ($matches[2] as $i => $option) {
         $params = true;
         if ($matches[3][$i] !== "") {
             $params = [];
             $p = explode(" ", $matches[3][$i]);
             foreach ($p as $k) {
                 $k = explode("=", $k);
                 if (isset($k[1])) {
                     $params[$k[0]] = $k[1];
                 }
             }
         }
         $this->options[$option] = $params;
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:53,代码来源:Flat.php

示例3: generateChunk

 public function generateChunk($chunkX, $chunkZ)
 {
     $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);
             }
         }
     }
     $this->chunk->setBlockId(8, 64, 8, Block::GRASS);
     $chunk = clone $this->chunk;
     $chunk->setX($chunkX);
     $chunk->setZ($chunkZ);
     $this->level->setChunk($chunkX, $chunkZ, $chunk);
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:23,代码来源:Void.php


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