From 95b65a8cf97593470db78443b4a16f2e2287c67f Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 24 Sep 2010 11:42:29 -1000 Subject: [PATCH] None argument to fillBlocks means operate on every chunk in the world. previously, getChunks over a huge box would waste a lot of time skipping absent chunks in large, sparse levels. --- mclevel.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mclevel.py b/mclevel.py index 864dd3e..23e537a 100644 --- a/mclevel.py +++ b/mclevel.py @@ -2251,7 +2251,11 @@ class MCInfdevOldLevel(MCLevel): chunk.TileEntities.append(entity); def fillBlocks(self, box, blockType, blockData = 0, blocksToReplace = None): - chunkIterator = self.getChunkSlices(box) + if box is None: + chunkIterator = self.getAllChunkSlices() + else: + chunkIterator = self.getChunkSlices(box) + changesLighting = True if blocksToReplace != None: @@ -2302,7 +2306,13 @@ class MCInfdevOldLevel(MCLevel): if blocksToReplace != None: print "Replace: Skipped {0} chunks, replaced {1} blocks".format(skipped, replaced) - + + def getAllChunkSlices(self): + for cpos in self.presentChunks: + xPos, zPos = cpos + yield ( self.getChunk(xPos, zPos), ( slice(0,16),slice(0,16),slice(0,128), ), (xPos * 16, 0, zPos * 16) ) + + def getChunkSlices(self, box): """ call this method to iterate through a large slice of the world by visiting each chunk and indexing its data with a subslice.