added shouldRetainData check - checks BlockRotation to see if they have the same rotation type, implying their blockData has the same meaning.
This commit is contained in:
parent
dbd65c7e21
commit
21c756de78
@ -361,13 +361,25 @@ def masterRotationTable(attrname):
|
||||
|
||||
return table
|
||||
|
||||
def rotationTypeTable():
|
||||
table = {}
|
||||
for cls in rotationClasses:
|
||||
for b in cls.blocktypes:
|
||||
table[b] = cls
|
||||
|
||||
return table
|
||||
|
||||
class BlockRotation:
|
||||
rotateLeft = masterRotationTable("rotateLeft");
|
||||
flipEastWest = masterRotationTable("flipEastWest");
|
||||
flipNorthSouth = masterRotationTable("flipNorthSouth");
|
||||
flipVertical = masterRotationTable("flipVertical");
|
||||
|
||||
|
||||
typeTable = rotationTypeTable()
|
||||
|
||||
def SameRotationType(blocktype1, blocktype2):
|
||||
#use different default values for typeTable.get() to make it return false when neither blocktype is present
|
||||
return BlockRotation.typeTable.get(blocktype1.ID) == BlockRotation.typeTable.get(blocktype2.ID, BlockRotation)
|
||||
|
||||
def FlipVertical(blocks, data):
|
||||
data[:] = BlockRotation.flipVertical[blocks, data]
|
||||
|
||||
|
@ -2412,14 +2412,15 @@ class MCInfdevOldLevel(EntityLevel):
|
||||
#if shouldRetainData:
|
||||
# info( "Preserving data bytes" )
|
||||
shouldRetainData = False #xxx old behavior overwrote blockdata with 0 when e.g. replacing water with lava
|
||||
|
||||
|
||||
info("Replacing {0} with {1}".format(blocksToReplace, blockInfo))
|
||||
|
||||
changesLighting = True
|
||||
|
||||
if len(blocksToReplace):
|
||||
blocktable = self.blockReplaceTable(blocksToReplace)
|
||||
|
||||
shouldRetainData = all([blockrotation.SameRotationType(blockInfo, b) for b in blocksToReplace])
|
||||
|
||||
newAbsorption = self.materials.lightAbsorption[blockInfo.ID]
|
||||
oldAbsorptions = [self.materials.lightAbsorption[b.ID] for b in blocksToReplace]
|
||||
changesLighting = False
|
||||
|
7
level.py
7
level.py
@ -340,12 +340,13 @@ class MCLevel(object):
|
||||
info(u"Filling blocks in {0} with {1}, replacing{2}".format(box, blockInfo, blocksToReplace))
|
||||
|
||||
slices = map(slice, box.origin, box.maximum)
|
||||
|
||||
|
||||
blocks = self.Blocks[slices[0], slices[2], slices[1]]
|
||||
if len(blocksToReplace):
|
||||
blocktable = self.blockReplaceTable(blocksToReplace)
|
||||
|
||||
if hasattr(self, "Data"):
|
||||
shouldRetainData = (self.materials == alphaMaterials) and all([blockrotation.SameRotationType(blockInfo, b) for b in blocksToReplace])
|
||||
|
||||
if hasattr(self, "Data") and shouldRetainData:
|
||||
data = self.Data[slices[0], slices[2], slices[1]]
|
||||
mask = blocktable[blocks, data]
|
||||
|
||||
|
Reference in New Issue
Block a user