level = $level; $this->x = (int) $x; $this->z = (int) $z; foreach($sections as $Y => $section){ if($section instanceof ChunkSection){ $this->sections[$Y] = $section; }else{ trigger_error("Received invalid ChunkSection instance", E_USER_ERROR); return; } if($section >= self::SECTION_COUNT){ trigger_error("Invalid amount of chunks", E_USER_WARNING); return; } } } public function getX(){ return $this->x; } public function getZ(){ return $this->z; } public function getLevel(){ return $this->level; } public function getBlock($x, $y, $z, &$blockId, &$meta = null){ $this->sections[$y >> 4]->getBlock($x, $y - ($y >> 4), $z, $blockId, $meta); } public function setBlock($x, $y, $z, $blockId = null, $meta = null){ $this->sections[$y >> 4]->setBlock($x, $y - ($y >> 4), $z, $blockId, $meta); } public function getBlockSkyLight($x, $y, $z){ return $this->sections[$y >> 4]->getBlockSkyLight($x, $y - ($y >> 4), $z); } public function setBlockSkyLight($x, $y, $z, $data){ $this->sections[$y >> 4]->getBlockSkyLight($x, $y - ($y >> 4), $z, $data); } public function getBlockLight($x, $y, $z){ return $this->sections[$y >> 4]->getBlockSkyLight($x, $y - ($y >> 4), $z); } public function setBlockLight($x, $y, $z, $data){ $this->sections[$y >> 4]->getBlockSkyLight($x, $y - ($y >> 4), $z, $data); } public function getHighestBlockAt($x, $z){ for($Y = self::SECTION_COUNT; $Y >= 0; --$Y){ if(!$this->isSectionEmpty($Y)){ $column = $this->sections[$Y]->getBlockIdColumn($x, $z); for($y = 15; $y >= 0; --$y){ if($column{$y} !== "\x00"){ return $y + $Y << 4; } } } } return 0; } public function isSectionEmpty($fY){ return $this->sections[(int) $fY] instanceof EmptyChunkSection; } public function getSection($fY){ return $this->sections[(int) $fY]; } public function setSection($fY, ChunkSection $section){ $this->sections[(int) $fY] = $section; } }