public Chunk GetChunk(NetChunk netChunk) { Chunk chunk = netChunk.chunk; _ms.SetLength(0); _ms.Write(netChunk.chunkData.data.data, 0, netChunk.chunkData.data.data.Length); _ms.Position = 0; IMTBCompress compress = MTBCompressFactory.GetCompress(netChunk.chunkData.data.compressType); _ms = (MemoryStream)compress.Decompress(_ms); _ms.Position = 0; chunk.Deserialize(_ms); return(chunk); }
//获取到的块数据 public bool GetChunkData(int x, int z, Chunk chunk) { if (_headData[x, z].status == ChunkDataStatus.Not_Create) { return(false); } _fs.Position = SectorToByte(_headData[x, z].BlockOffset) + 5; _cs.SetLength(0); _cs.Write(_fs, _headData[x, z].Length); _cs.Position = 0; IMTBCompress compress = MTBCompressFactory.GetCompress(_headData[x, z].CompressionType); _cs = (ChunkStream)compress.Decompress(_cs); _cs.Position = 0; chunk.Deserialize(_cs); return(true); }