From 78b6ebf9eb1ddd4373e1c1c37ddc3ac92af5872e Mon Sep 17 00:00:00 2001 From: David Vierra Date: Mon, 8 Aug 2016 17:25:20 -1000 Subject: [PATCH] Fix passing unsigned longs to TAG_Long, which requires signed longs --- src/mceditlib/nbtattr.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mceditlib/nbtattr.py b/src/mceditlib/nbtattr.py index 305e00f..dfe6a26 100644 --- a/src/mceditlib/nbtattr.py +++ b/src/mceditlib/nbtattr.py @@ -119,11 +119,16 @@ class NBTUUIDAttr(object): least = uuidInt & 0xffffffffffffffffL most = (uuidInt >> 64) & 0xffffffffffffffffL tag = instance.rootTag - tag["UUIDLeast"].value = least - tag["UUIDMost"].value = most + tag["UUIDLeast"].value = _signed(least) + tag["UUIDMost"].value = _signed(most) instance.dirty = True +def _signed(bits): + if bits >= (1 << 63): + bits -= (1 << 64) + return bits + class NBTCompoundRef(object): def __init__(self, rootTag, parent): """