Giter VIP home page Giter VIP logo

Comments (10)

ch-yx avatar ch-yx commented on August 22, 2024 1

by the way,I'm now starting to try to implement NBT Path.
https://minecraft.gamepedia.com/Commands/data#NBT_path
I'm planning to make it like Pathlib's Path

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

I'm not sure what you mean by unsigned numeric tags, as far as I know all integer tags are signed. Do you have a specific example in mind?

from nbtlib.

ch-yx avatar ch-yx commented on August 22, 2024

Add something like that to numberic tag:

@property 
def unsign (self):
 return self&(len(self.range)-1)

and

@classmethod
def from_unsign(c,x):
 range =len(c.range)
 x=x%range
 return c(x-(x not in c.range)*range)

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

Hmm okay so it would allow you to interpret the tag as an unsigned integer. I don't know if there's a real use-case but I think I would just prefer to create my own userland function for this.

from nbtlib.

ch-yx avatar ch-yx commented on August 22, 2024

There is.
For example,If you want to use UUIDLeast/Most and string UUID 😏

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

Wait UUIDLeast/Most is not just a long tag?

from nbtlib.

ch-yx avatar ch-yx commented on August 22, 2024

I'm not saying it is just a long tag.
But meaning of these two tag is unsigned.
Sometimes you have to connect them together or convert them to or from String form(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
It will be neat if we have these two helper method.


By the way,I will try to not use any "magic" thing to solve that without slowness.

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

Hmm okay I think I understand. I guess adding these two helpers won't cost much anyway. It would be cool to also add a working example showing how to use them to combine and split a UUID string.

# examples/uuid.py

def combine_uuid(uuid_most_tag, uuid_least_tag):
    uuid_most = uuid_most_tag.as_unsigned
    uuid_least = uuid_least_tag.as_unsigned
    return ...

def split_uuid(uuid_string_tag):
    uuid_most = ...
    uuid_least = ...
    return Long.from_unsigned(uuid_most), Long.from_unsigned(uuid_least)

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

Just added the unsigned helpers with the uuid example I talked about 74a8028.

Nbt paths could be a pretty useful feature, but we should probably discuss that in a separate issue.

from nbtlib.

vberlier avatar vberlier commented on August 22, 2024

Okay just released v1.5.0, closing the issue.

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.