Giter VIP home page Giter VIP logo

Comments (4)

iRath96 avatar iRath96 commented on July 28, 2024

Include the file /web-app/NBT.js (you're also required to have /web-app/NBT.js.mem in the same folder). NBT.js was compiled from the C++-files in /nbt-utils/ (and zlib as dependency) using emscripten, so if you want to alter the behavior of NBT.js, you'll have to edit the C++-files and recompile.

The most important methods exposed by NBT.js are:
Module.Tag.serialize and Module.Tag.serializeCompressed (these transform Tags into binary data)
Module.Tag.deserialize and Module.Tag.deserializeCompressed (these load Tags from binary data)

For more information on the methods exposed by NBT.js (especially instance methods of Tags) take a look at the emscripten bindings in /nbt-utils/main.cpp.

If there's anything else you need, let me know and I'll help you.

from webnbt.

dokranke avatar dokranke commented on July 28, 2024

Thanks man. Do I also need to wait for the depencies like in the app.js? And embed your TagLibrary?

EDIT: I don't know which parameters are needed, I tried it with the following:

  1. data
  2. String: "compressed" or "uncompressed"
  3. Boolean: named?

I tried both deserialize methods and the best i achieved was a byte tag (tagType 1), but the result should be compound (tagType 10). What am I doing wrong?

from webnbt.

iRath96 avatar iRath96 commented on July 28, 2024

No problem. You'll probably have to wait for the dependencies as well, I haven't found a better way to accomplish this.

The parameters for deserialize should be static Tag *deserialize(std::string input, bool withName = true, TagType::Enum type = TagType::Unknown); (see here)

So basically

  1. String: data
  2. Boolean: named?
  3. Tag Type: set this to -1 and it'll read the type from the data provided.

You can take a look at how I call deserialize within App.js.

Hope this helps. 🐱

from webnbt.

dokranke avatar dokranke commented on July 28, 2024

Got it :) Thanks. And I've seen that I can iterate throu the Tag with this.

Also you need to have the NBT.js.mem-file in the same folder as the html not the js.

from webnbt.

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.