From 0c3d9eeef9f21d0f25d6b397cecaff8d28267d97 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sat, 19 Feb 2011 18:19:16 -1000 Subject: [PATCH] added TAG_Int_Array introduced by ymod --- nbt.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nbt.py b/nbt.py index e9f6fa1..f4bd4d9 100644 --- a/nbt.py +++ b/nbt.py @@ -170,6 +170,28 @@ class TAG_Byte_Array(TAG_Value): valuestr = self.value.tostring() buf.write(struct.pack(self.fmt % (len(valuestr),), len(valuestr), valuestr)) +class TAG_Int_Array(TAG_Byte_Array): + """An array of ints""" + tag = 11; + def dataType(self, value): + return array(value, 'uint32') + + def __init__(self, value=zeros(0, "uint32"), name=None, data=""): + self.name = name + if(data == ""): + self.value = value; + else: + (string_len,) = struct.unpack_from(">i", data); + self.value = fromstring(data[4:string_len * 4 + 4], 'uint32').newbyteorder(); + + + def nbt_length(self) : + return len(self.value) * 4 + 4; + + def write_value(self, buf): + #print self.value + valuestr = self.value.tostring() + buf.write(struct.pack(self.fmt % (len(valuestr),), len(valuestr)/4, valuestr)) class TAG_String(TAG_Value): "String in UTF-8"