setChunk() public method

public setChunk ( integer $chunkX, integer $chunkZ, pocketmine\level\format\FullChunk $chunk = null )
$chunkX integer
$chunkZ integer
$chunk pocketmine\level\format\FullChunk
示例#1
0
文件: Void.php 项目: iTXTech/Genisys
 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);
 }
示例#2
0
 public function generateChunk($chunkX, $chunkZ)
 {
     if ($this->chunk === null) {
         if (isset($this->options["preset"]) and $this->options["preset"] != "") {
             $this->parsePreset($this->options["preset"], $chunkX, $chunkZ);
         } else {
             $this->parsePreset($this->preset, $chunkX, $chunkZ);
         }
     }
     $chunk = clone $this->chunk;
     $chunk->setX($chunkX);
     $chunk->setZ($chunkZ);
     $this->level->setChunk($chunkX, $chunkZ, $chunk);
 }
示例#3
0
 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);
 }
示例#4
0
 public function generateChunk($chunkX, $chunkZ)
 {
     $spawn = $this->getSpawn();
     // Adjust spawn so it is relative to current chunk...
     $spawn->x = $spawn->x - ($chunkX << 4);
     $spawn->z = $spawn->z - ($chunkZ << 4);
     $inSpawn = -$this->radius <= $spawn->x && $spawn->x < 16 + $this->radius && -$this->radius <= $spawn->z && $spawn->z < 16 + $this->radius;
     if ($inSpawn || $this->chunk === null) {
         $chunk = $this->level->getChunk($chunkX, $chunkZ);
         $chunk->setGenerated();
         $c = Biome::getBiome($this->biome)->getColor();
         $R = $c >> 16;
         $G = $c >> 8 & 0xff;
         $B = $c & 0xff;
         $rad2 = $this->radius * $this->radius;
         for ($Z = 0; $Z < 16; ++$Z) {
             for ($X = 0; $X < 16; ++$X) {
                 $chunk->setBiomeId($X, $Z, $biome);
                 $chunk->setBiomeColor($X, $Z, $R, $G, $B);
                 $chunk->setBlock($X, 0, $Z, $this->baseFloor, 0);
                 for ($y = 1; $y < 128; ++$y) {
                     $chunk->setBlock($X, $y, $Z, Block::AIR, 0);
                 }
                 if (self::inSpawn($rad2, $spawn->x, $spawn->z, $X, $Z)) {
                     $chunk->setBlock($X, $this->floorLevel, $Z, $this->block);
                 }
             }
         }
         if (!$inSpawn) {
             $this->chunk = clone $chunk;
         }
     } else {
         $chunk = clone $this->chunk;
     }
     $chunk->setX($chunkX);
     $chunk->setZ($chunkZ);
     $this->level->setChunk($chunkX, $chunkZ, $chunk);
 }