From 113163226060f4a21770f30be3062e3bab7f596f Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sun, 4 Oct 2015 00:30:47 -1000 Subject: [PATCH] Add explicit copyAir flag to copyBlocksIter --- src/mceditlib/block_copy.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mceditlib/block_copy.py b/src/mceditlib/block_copy.py index 48d2698..2a11c4c 100644 --- a/src/mceditlib/block_copy.py +++ b/src/mceditlib/block_copy.py @@ -6,33 +6,35 @@ """ import time import logging + +import numpy + +import mceditlib.blocktypes as blocktypes from mceditlib import relight from mceditlib.selection import BoundingBox, SectionBox log = logging.getLogger(__name__) -import numpy -import mceditlib.blocktypes as blocktypes -def sourceMaskFunc(blocksToCopy): +def sourceMaskFunc(blocksToCopy, copyAir=False): if blocksToCopy is not None: typemask = numpy.zeros(blocktypes.id_limit, dtype='bool') typemask[blocksToCopy] = 1 + else: + typemask = numpy.ones(blocktypes.id_limit, dtype='bool') - def maskedSourceMask(sourceBlocks): - return typemask[sourceBlocks] + typemask[0] = copyAir - return maskedSourceMask + def maskedSourceMask(sourceBlocks): + return typemask[sourceBlocks] - def unmaskedSourceMask(_sourceBlocks): - return numpy.ones((1,), bool) - - return unmaskedSourceMask + return maskedSourceMask def copyBlocksIter(destDim, sourceDim, sourceSelection, destinationPoint, blocksToCopy=None, entities=True, create=False, biomes=False, - updateLights="all", replaceUnknownWith=None): + updateLights="all", replaceUnknownWith=None, + copyAir=False): """ Copy blocks and entities from the `sourceBox` area of `sourceDim` to `destDim` starting at `destinationPoint`. @@ -65,7 +67,7 @@ def copyBlocksIter(destDim, sourceDim, sourceSelection, destinationPoint, allChangedY = [] allChangedZ = [] - makeSourceMask = sourceMaskFunc(blocksToCopy) + makeSourceMask = sourceMaskFunc(blocksToCopy, copyAir) copyOffset = destBox.origin - sourceSelection.origin