Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbtlib.Long can not set 64bytes value #193

Open
xkcb1 opened this issue Aug 11, 2023 · 1 comment
Open

nbtlib.Long can not set 64bytes value #193

xkcb1 opened this issue Aug 11, 2023 · 1 comment

Comments

@xkcb1
Copy link

xkcb1 commented Aug 11, 2023

a Long use 64 bytes cannot run ,error is "btlib.tag.OutOfRange: Long(14757395258967641292) is out of range"

@xkcb1 xkcb1 changed the title nbtlib nbtlib.Long can not set 64bytes value Aug 11, 2023
@vberlier
Copy link
Owner

A Long tag is a signed 64bit integer. The maximum allowed value is 9223372036854775807. Your value would fit in an unsigned 64bit integer. nbtlib has a from_unsigned helper for encoding unsigned integers into signed NBT tags

from nbtlib import Long
print(Long.from_unsigned(14757395258967641292))
Long(-3689348814741910324)

You do the opposite with as_unsigned

from nbtlib import Long
print(Long(-3689348814741910324).as_unsigned)
14757395258967641292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants