diff --git a/mce.py b/mce.py index 416f194..16b4b39 100755 --- a/mce.py +++ b/mce.py @@ -438,7 +438,7 @@ class mce(object): blockCounts = zeros( (256,), 'uint64') sizeOnDisk = 0; - print "Analyzing {0} chunks...".format(len(self.level.allChunks)) + print "Analyzing {0} chunks...".format(self.level.chunkCount) for i, cPos in enumerate(self.level.allChunks, 1): ch = self.level.getChunk(*cPos); diff --git a/mclevel.py b/mclevel.py index 3edf563..6ddda91 100644 --- a/mclevel.py +++ b/mclevel.py @@ -2125,9 +2125,9 @@ class MCInfdevOldLevel(MCLevel): return True; return False - + def getWorldBounds(self): - if len(self._allChunks) == 0: + if self.chunkCount == 0: return BoundingBox( (0,0,0), (0,0,0) ) allChunksArray = array(list(self.allChunks), dtype='int32') @@ -2581,7 +2581,15 @@ class MCInfdevOldLevel(MCLevel): @property def loadedChunks(self): return self._loadedChunks.keys(); - + + @property + def chunkCount(self): + """Returns the number of chunks in the level. May initiate a costly + chunk scan.""" + if self._allChunks is None: + self.preloadChunkPaths() + return len(self._allChunks) + @property def allChunks(self): """Iterates over (xPos, zPos) tuples, one for each chunk in the level.