Giter VIP home page Giter VIP logo

Comments (3)

vberlier avatar vberlier commented on August 22, 2024 1

@DudleyFox I just published version 1.2.0, which now supports little-endian nbt data. I added a byteorder argument to most functions and methods. It defaults to 'big' for backward compatibility but you can set it to 'little' to use the little-endian format.

parsed_compound = Compound.parse(some_file, byteorder='little')

I also added an example in the examples folder that showcases how you could use nbtlib to read and edit level.dat files from Bedrock-based Minecraft editions. The level_dat_bedrock.py example defines a BedrockLevelFile class that takes care of parsing the header and the content of the file using the little-endian format.

# This is how you would edit a level.dat file

with BedrockLevelFile.load('level.dat') as level_data:
    level_data['LevelName'] = 'Something'

For the sake of convenience, I attached a schema that matches the structure of the level.dat file to the BedrockLevelFile class, but that's completely optional.

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

nbtlib currently uses big-endian byte ordering, which is the format used by the original version of Minecraft. I know that versions of Minecraft based on the pocket edition use little-endian ordering, so making it possible to choose the endianness when reading and writing nbt data is on my todo list.

However, nbtlib is not a library for working with Minecraft files specifically. It's an implementation of the official nbt specification. Nbt data is used in a lot of different ways, and it's often integrated within other file formats. This library is supposed to let you read sections of files that contain spec-conforming nbt data. It won't work out of the box on files that do not contain raw nbt data, such as the Minecraft Education level.dat file since it has a header that you'll need to parse yourself before getting to the section that contains actual nbt data.

from nbtlib.

DudleyFox avatar DudleyFox commented on August 22, 2024

That is very nice. Thank you!

from nbtlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.