mstefarov / fNbt

A C# library for reading and writing Named Binary Tag (NBT) files and streams. A continuation of libnbt project, originally by Erik Davidson (aphistic).
116 stars 31 forks source link

Minecraft: Windows 10 Edition Compatibility issue #31

Open JERisBRISK opened 5 years ago

JERisBRISK commented 5 years ago

I just tried using fNbt to load the level.dat file for a Minecraft Windows 10 Edition save and was met with two exceptions.

The first was that it was unable to detect the compression format:

System.IO.InvalidDataException: Could not auto-detect compression format.
   at fNbt.NbtFile.DetectCompression(Stream stream)

I tried to remedy that by explicitly calling nbtFile.LoadFromFile(levelDatFile, NbtCompression.None, null). This worked, but the next error I encountered was:

fNbt.NbtFormatException: Given NBT stream does not start with a TAG_Compound
   at fNbt.NbtFile.LoadFromStreamInternal(Stream stream, TagSelector tagSelector)

So, whatever Mojang did for the Windows 10 Edition of Minecraft seems to have introduced some compatibility issues with fNbt.

tryashtar commented 4 years ago

Try this:

 var file = new NbtFile();
 file.BigEndian = false;
 byte[] data = File.ReadAllBytes(levelDatFile);
 file.LoadFromBuffer(data, 8, data.Length - 8, NbtCompression.None);
brammie15 commented 4 months ago

Try this:

 var file = new NbtFile();
 file.BigEndian = false;
 byte[] data = File.ReadAllBytes(levelDatFile);
 file.LoadFromBuffer(data, 8, data.Length - 8, NbtCompression.None);

How do i save the file then?