Esempio n. 1
0
        public override ChunkColumn LoadChunk(int x, int z)
        {
            var u      = Globals.Decompress(File.ReadAllBytes(_folder + "/" + x + "." + z + ".cfile"));
            var reader = new MSGBuffer(u);

            var blockLength = reader.ReadInt();
            var block       = reader.ReadUShortLocal(blockLength);

            var metalength = reader.ReadInt();
            var blockmeta  = reader.ReadShortLocal(metalength);

            //var blockies = new Block[block.Length];
            //var blocks = new ushort[block.Length];
            //for (var i = 0; i < block.Length; i++)
            //{
            //	blockies[i] = new Block(block[i]) {Metadata = (byte) blockmeta[i]};
            //}


            var skyLength = reader.ReadInt();
            var skylight  = reader.Read(skyLength);

            var lightLength = reader.ReadInt();
            var blocklight  = reader.Read(lightLength);

            var biomeIdLength = reader.ReadInt();
            var biomeId       = reader.Read(biomeIdLength);

            var cc = new ChunkColumn
            {
                Blocks     = block,
                Metadata   = blockmeta,
                Blocklight = { Data = blocklight },
                Skylight   = { Data = skylight },
                BiomeId    = biomeId,
                X          = x,
                Z          = z
            };

            Debug.WriteLine("We should have loaded " + x + ", " + z);
            return(cc);
            //throw new NotImplementedException();
        }