pocketmine\level\format\generic\BaseFullChunk::__construct PHP Method

__construct() protected method

protected __construct ( pocketmine\level\format\LevelProvider $provider, integer $x, integer $z, string $blocks, string $data, string $skyLight, string $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = [] )
$provider pocketmine\level\format\LevelProvider
$x integer
$z integer
$blocks string
$data string
$skyLight string
$blockLight string
$biomeColors array
$heightMap array
$entities array
$tiles array
$extraData array
    protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = [])
    {
        $this->provider = $provider;
        $this->x = (int) $x;
        $this->z = (int) $z;
        $this->blocks = $blocks;
        $this->data = $data;
        $this->skyLight = $skyLight;
        $this->blockLight = $blockLight;
        if (count($biomeColors) === 256) {
            $this->biomeColors = $biomeColors;
        } else {
            $this->biomeColors = array_fill(0, 256, 0);
        }
        if (count($heightMap) === 256) {
            $this->heightMap = $heightMap;
        } else {
            $this->heightMap = array_fill(0, 256, 127);
        }
        $this->extraData = $extraData;
        $this->NBTtiles = $tiles;
        $this->NBTentities = $entities;
    }

Usage Example

Example #1
0
 public function __construct($level, Compound $nbt = null)
 {
     if ($nbt === null) {
         $this->provider = $level;
         $this->nbt = new Compound("Level", []);
         return;
     }
     $this->nbt = $nbt;
     if (isset($this->nbt->Entities) and $this->nbt->Entities instanceof Enum) {
         $this->nbt->Entities->setTagType(NBT::TAG_Compound);
     } else {
         $this->nbt->Entities = new Enum("Entities", []);
         $this->nbt->Entities->setTagType(NBT::TAG_Compound);
     }
     if (isset($this->nbt->TileEntities) and $this->nbt->TileEntities instanceof Enum) {
         $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
     } else {
         $this->nbt->TileEntities = new Enum("TileEntities", []);
         $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
     }
     if (isset($this->nbt->TileTicks) and $this->nbt->TileTicks instanceof Enum) {
         $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
     } else {
         $this->nbt->TileTicks = new Enum("TileTicks", []);
         $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
     }
     if (!isset($this->nbt->BiomeColors) or !$this->nbt->BiomeColors instanceof IntArray) {
         $this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, 0));
     }
     if (!isset($this->nbt->HeightMap) or !$this->nbt->HeightMap instanceof IntArray) {
         $this->nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 0));
     }
     if (!isset($this->nbt->Blocks)) {
         $this->nbt->Blocks = new ByteArray("Blocks", str_repeat("", 32768));
     }
     if (!isset($this->nbt->Data)) {
         $this->nbt->Data = new ByteArray("Data", $half = str_repeat("", 16384));
         $this->nbt->SkyLight = new ByteArray("SkyLight", $half);
         $this->nbt->BlockLight = new ByteArray("BlockLight", $half);
     }
     parent::__construct($level, $this->nbt["xPos"], $this->nbt["zPos"], $this->nbt->Blocks->getValue(), $this->nbt->Data->getValue(), $this->nbt->SkyLight->getValue(), $this->nbt->BlockLight->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue());
     if (isset($this->nbt->Biomes)) {
         $this->checkOldBiomes($this->nbt->Biomes->getValue());
         unset($this->nbt->Biomes);
     }
     unset($this->nbt->Blocks);
     unset($this->nbt->Data);
     unset($this->nbt->SkyLight);
     unset($this->nbt->BlockLight);
     unset($this->nbt->BiomeColors);
     unset($this->nbt->HeightMap);
     unset($this->nbt->Biomes);
 }
All Usage Examples Of pocketmine\level\format\generic\BaseFullChunk::__construct