pocketmine\level\format\mcregion\Chunk::getEmptyChunk PHP Method

getEmptyChunk() public static method

public static getEmptyChunk ( integer $chunkX, integer $chunkZ, pocketmine\level\format\LevelProvider $provider = null ) : Chunk
$chunkX integer
$chunkZ integer
$provider pocketmine\level\format\LevelProvider
return Chunk
    public static function getEmptyChunk($chunkX, $chunkZ, LevelProvider $provider = null)
    {
        try {
            $chunk = new Chunk($provider instanceof LevelProvider ? $provider : McRegion::class, null);
            $chunk->x = $chunkX;
            $chunk->z = $chunkZ;
            $chunk->data = str_repeat("", 16384);
            $chunk->blocks = $chunk->data . $chunk->data;
            $chunk->skyLight = str_repeat("ΓΏ", 16384);
            $chunk->blockLight = $chunk->data;
            $chunk->heightMap = array_fill(0, 256, 0);
            $chunk->biomeColors = array_fill(0, 256, 0);
            $chunk->nbt->V = new ByteTag("V", 1);
            $chunk->nbt->InhabitedTime = new LongTag("InhabitedTime", 0);
            $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", 0);
            $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", 0);
            $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", 0);
            return $chunk;
        } catch (Throwable $e) {
            return null;
        }
    }

Usage Example

Example #1
0
 public function getEmptyChunk($chunkX, $chunkZ)
 {
     return Chunk::getEmptyChunk($chunkX, $chunkZ, $this);
 }