def _readChunk(self, cx, cz, world, readOptions=None):
        """
        :param cx, cz: int Coordinates of the chunk
        :param readOptions: ReadOptions
        :return: chunk data in a tuple: (terrain, tile_entities, entities)
        """
        # PE 1+ worlds can contain pre 1.0 chunks.
        # Let check which version of the chunk we have before doing anything else.
        with self.world_db() as db:
            rop = self.readOptions if readOptions is None else readOptions
            key = struct.pack('<i', cx) + struct.pack('<i', cz)+dimension
            raise_err = False
            try:
                chunk_version = db.Get(rop, key + chr(118))
                if chunk_version is None:
                    raise_err = True
            except:
                raise_err = True
            if raise_err:
                raise ChunkNotPresent((cx, cz, self))
            if DEBUG_PE:
                write_dump("** Loading chunk ({x}, {z}) for PE {vs} ({v}).\n".format(x=cx, z=cz, vs={"\x02": "pre 1.0", "\x03": "1.0", "\x04": "1.1"}.get(chunk_version, 'Unknown'), v=repr(chunk_version)))

            if chunk_version == "\x02":
                # We have a pre 1.0 chunk
                data = self._readChunk_pre1_0(cx, cz, rop, key)
                if data is None:
                    raise ChunkNotPresent((cx, cz, self))
                chunk = PocketLeveldbChunkPre1(cx, cz, world, data, world_version=self.world_version)
            # Let assume that any chunk wich version is greater or equal to 3 in a PE 1+ one.
            elif ord(chunk_version) >= 3:
                # PE 1+ chunk detected. Iterate through the subchunks to rebuild the whole data.
                # If the world version was set o pre1.0 during initialization, change it for 1+.
                # Change also the world height to 256...
                if world.world_version == 'pre1.0':
                    logger.info("Detected pre 1.0 world, but 1.0+ chunk found. Changing world version and height accordingly.")
                    world.world_version = '1.plus'
                    world.Height = 256
                    self.world_version = '1.plus'

                    # Reload the 'allChunks' object
                    world._allChunks = None
                    world.allChunks

                chunk = PocketLeveldbChunk1Plus(cx, cz, world, world_version=self.world_version, chunk_version=chunk_version)
                d2d = db.Get(rop, key + "\x2d")
                if d2d:
                    # data_2d contains the heightmap (currently computed dynamically, may change)
                    # and the biome information of the chunk on the last 256 bytes.
                    chunk.data_2d = d2d
                    biomes = numpy.fromstring(d2d[512:], 'uint8')
                    biomes.shape = (16, 16)
                    chunk.Biomes = biomes
                for i in range(16):
                    tr, te, en = self._readSubChunk_1plus(cx, cz, i, rop, key)
                    chunk.add_data(terrain=tr, tile_entities=te, entities=en, subchunk=i)

                # Generate the lights if we have a PE 1.1 chunk.
                if ord(chunk.chunk_version) >= 4:
                    chunk.genFastLights()
                if DEBUG_PE:
                    write_dump(">>> Chunk (%s, %s) sub-chunks: %s\n" % (cx, cz, repr(chunk.subchunks)))
            elif chunk_version is not None:
                raise AttributeError("Unknown PE chunk version %s" % repr(chunk_version))
            elif chunk_version is None:
                if DEBUG_PE:
                    write_dump("Chunk (%s, %s) version seem to be 'None'. Do this chunk exists in this world?" % (cx, cz))
                return None
            else:
                if DEBUG_PE:
                    write_dump("Unknown chunk version detected for chunk (%s, %s): %s" % (cx, cz, repr(chunk_version)))
                raise AttributeError("Unknown chunk version detected for chunk (%s, %s): %s" % (cx, cz, repr(chunk_version)))
            logger.debug("CHUNK LOAD %s %s" % (cx, cz))
            return chunk

        :param cx, cz: int Coordinates of the chunk
        :param readOptions: ReadOptions
        :return: chunk data in a tuple: (terrain, tile_entities, entities)
        
pymclevel/leveldbpocket.py