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:
David Vierra 2011-09-16 11:58:38 -10:00
parent dbd65c7e21
commit 21c756de78
3 changed files with 21 additions and 7 deletions

View File

@ -361,12 +361,24 @@ 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]

View File

@ -2419,6 +2419,7 @@ class MCInfdevOldLevel(EntityLevel):
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]

View File

@ -344,8 +344,9 @@ class MCLevel(object):
blocks = self.Blocks[slices[0], slices[2], slices[1]]
if len(blocksToReplace):
blocktable = self.blockReplaceTable(blocksToReplace)
shouldRetainData = (self.materials == alphaMaterials) and all([blockrotation.SameRotationType(blockInfo, b) for b in blocksToReplace])
if hasattr(self, "Data"):
if hasattr(self, "Data") and shouldRetainData:
data = self.Data[slices[0], slices[2], slices[1]]
mask = blocktable[blocks, data]