public static RegionFile_Chunk GetChunkByLocation(RegionFile_Location location, Stream st) { RegionFile_Chunk tempChunk = new RegionFile_Chunk(); BinaryReader br = new BinaryReader(st); { br.ReadBytes(8192); long ichi = br.BaseStream.Position; br.BaseStream.Position = location.offset * 4096; byte[] chunkData = br.ReadBytes(location.sectorCount * 4096); BinaryReader chunkDataBR = new BinaryReader(new MemoryStream(chunkData)); tempChunk.length = BinaryJava.ReadInt(chunkDataBR); tempChunk.compressionType = chunkDataBR.ReadByte(); if (tempChunk.compressionType == 2) { //tempChunk.Data = Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)); // chunkData.Skip(5).Take(tempChunk.length).ToArray()); //File.WriteAllBytes( "decomBytesNewnewnew",Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length))); tempChunk.tag = RegionFile_Chunk.ReadTags(Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length))); chunkDataBR.Dispose(); return(tempChunk); } else { throw new Exception("Unknown compression type"); } } }
private void button10_Click(object sender, EventArgs e) { //byte[] level=Deflactor.DeCompress(Deflactor.ZLibToDeflactor( File.ReadAllBytes(textBox1.Text))); //Tag leveltags = mcRegionReader.Tag.readFrom(new MemoryStream(level)); //treeView1.Nodes.Add(addToTree(leveltags)); FileStream fs = new FileStream(textBox1.Text, FileMode.Open); using (GZipStream zipStream = new GZipStream(fs, CompressionMode.Decompress)) { byte[] level = StreamToBytes(fs); level = Deflactor.Decompress(level); Tag leveltags = mcRegionReader.Tag.ReadFrom(new MemoryStream(level)); treeView1.Nodes.Add(AddToTree(leveltags)); } }