add property chunkCount because allChunks is now exposed as an iterator

This commit is contained in:
David Vierra 2011-02-07 18:58:22 -10:00
parent 25e4ec07c1
commit 4dbccca9dd
2 changed files with 12 additions and 4 deletions

2
mce.py
View File

@ -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);

View File

@ -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.