Add explicit copyAir flag to copyBlocksIter

This commit is contained in:
David Vierra 2015-10-04 00:30:47 -10:00
parent e24aebd2d0
commit 1131632260

View File

@ -6,33 +6,35 @@
""" """
import time import time
import logging import logging
import numpy
import mceditlib.blocktypes as blocktypes
from mceditlib import relight from mceditlib import relight
from mceditlib.selection import BoundingBox, SectionBox from mceditlib.selection import BoundingBox, SectionBox
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
import numpy
import mceditlib.blocktypes as blocktypes
def sourceMaskFunc(blocksToCopy): def sourceMaskFunc(blocksToCopy, copyAir=False):
if blocksToCopy is not None: if blocksToCopy is not None:
typemask = numpy.zeros(blocktypes.id_limit, dtype='bool') typemask = numpy.zeros(blocktypes.id_limit, dtype='bool')
typemask[blocksToCopy] = 1 typemask[blocksToCopy] = 1
else:
typemask = numpy.ones(blocktypes.id_limit, dtype='bool')
def maskedSourceMask(sourceBlocks): typemask[0] = copyAir
return typemask[sourceBlocks]
return maskedSourceMask def maskedSourceMask(sourceBlocks):
return typemask[sourceBlocks]
def unmaskedSourceMask(_sourceBlocks): return maskedSourceMask
return numpy.ones((1,), bool)
return unmaskedSourceMask
def copyBlocksIter(destDim, sourceDim, sourceSelection, destinationPoint, def copyBlocksIter(destDim, sourceDim, sourceSelection, destinationPoint,
blocksToCopy=None, entities=True, create=False, biomes=False, 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`. 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 = [] allChangedY = []
allChangedZ = [] allChangedZ = []
makeSourceMask = sourceMaskFunc(blocksToCopy) makeSourceMask = sourceMaskFunc(blocksToCopy, copyAir)
copyOffset = destBox.origin - sourceSelection.origin copyOffset = destBox.origin - sourceSelection.origin