spnda / dart_minecraft

A Dart library for Minecraft and Mojang Web-APIs, authentication, and NBT Files.
https://pub.dev/packages/dart_minecraft
MIT License
20 stars 8 forks source link

NBTReader.getContentEndian() returns Endian.big without condition #12

Closed ComeixAlpha closed 11 months ago

ComeixAlpha commented 11 months ago

In lib/src/nbt/nbt_reader.dart, class NbtReader Line 70 to 72

Endian getContentEndian() { return Endian.big; }

This code is going to cause that whenever I try to get the endian of a NBT file, I would get Endian.big. Is this an oversight? Or maybe you just don't intend to implement this function?

Also, can you please add an argument that receives Endian type variable to NbtWriter().writeFile() to enable us to write NBT file in little endian? I read a NBT file in little endian then write it as another file but then the new NBT file seems broken.

spnda commented 11 months ago

As for getContentEndian always returning Endian.big, yes I think that's a bug and I agree that that function probably should never have existed. I'll remove it.

In the test file for NBT I do read and write files in little endian format, and it is fully supported. See #5 for a related issue information.

To read and write little-endian use NbtReader.setEndianness and NbtWriter.setEndianness before calling read and writeFile, respectively. You can see an example of that in the linked issue or in nbt_test.dart.