From 110bd10569d142edad9a32a595d1b9ed46b3f8e6 Mon Sep 17 00:00:00 2001 From: Ryan Rector Date: Mon, 11 Jul 2011 21:42:24 -0600 Subject: [PATCH] Handle more regions This is much, much slower than numpy would do it. I should probably do this right sometime, but right now I just want it to work. --- nbt.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nbt.py b/nbt.py index 7a095e8..d5c8e96 100644 --- a/nbt.py +++ b/nbt.py @@ -339,9 +339,21 @@ class MCRFileReader(object): # read chunk location table locations_append = self._locations.append - for _ in xrange(32*32): + locations_index = [] + for x in xrange(32*32): locations_append(self._read_chunk_location()) - self._locations = numpy.reshape(numpy.rot90(numpy.reshape(self._locations, (32,32)),self.get_north_rotations()), -1) + locations_index.append(x) + try: + temp = numpy.reshape(self._locations, (32, 32)) + temp = numpy.rot90(temp, self.get_north_rotations()) + self._locations = numpy.reshape(temp, -1) + except ValueError: + temp = numpy.reshape(locations_index, (32, 32)) + temp = numpy.rot90(temp, self.get_north_rotations()) + temp = numpy.reshape(temp, -1) + ttemp = self._locations[:] + for i, e in enumerate(temp): + self._locations[i] = ttemp[e] # read chunk timestamp table timestamp_append = self._timestamps.append