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,12 +361,24 @@ def masterRotationTable(attrname):
|
|||||||
|
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
def rotationTypeTable():
|
||||||
|
table = {}
|
||||||
|
for cls in rotationClasses:
|
||||||
|
for b in cls.blocktypes:
|
||||||
|
table[b] = cls
|
||||||
|
|
||||||
|
return table
|
||||||
|
|
||||||
class BlockRotation:
|
class BlockRotation:
|
||||||
rotateLeft = masterRotationTable("rotateLeft");
|
rotateLeft = masterRotationTable("rotateLeft");
|
||||||
flipEastWest = masterRotationTable("flipEastWest");
|
flipEastWest = masterRotationTable("flipEastWest");
|
||||||
flipNorthSouth = masterRotationTable("flipNorthSouth");
|
flipNorthSouth = masterRotationTable("flipNorthSouth");
|
||||||
flipVertical = masterRotationTable("flipVertical");
|
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):
|
def FlipVertical(blocks, data):
|
||||||
data[:] = BlockRotation.flipVertical[blocks, data]
|
data[:] = BlockRotation.flipVertical[blocks, data]
|
||||||
|
@ -2419,6 +2419,7 @@ class MCInfdevOldLevel(EntityLevel):
|
|||||||
|
|
||||||
if len(blocksToReplace):
|
if len(blocksToReplace):
|
||||||
blocktable = self.blockReplaceTable(blocksToReplace)
|
blocktable = self.blockReplaceTable(blocksToReplace)
|
||||||
|
shouldRetainData = all([blockrotation.SameRotationType(blockInfo, b) for b in blocksToReplace])
|
||||||
|
|
||||||
newAbsorption = self.materials.lightAbsorption[blockInfo.ID]
|
newAbsorption = self.materials.lightAbsorption[blockInfo.ID]
|
||||||
oldAbsorptions = [self.materials.lightAbsorption[b.ID] for b in blocksToReplace]
|
oldAbsorptions = [self.materials.lightAbsorption[b.ID] for b in blocksToReplace]
|
||||||
|
3
level.py
3
level.py
@ -344,8 +344,9 @@ class MCLevel(object):
|
|||||||
blocks = self.Blocks[slices[0], slices[2], slices[1]]
|
blocks = self.Blocks[slices[0], slices[2], slices[1]]
|
||||||
if len(blocksToReplace):
|
if len(blocksToReplace):
|
||||||
blocktable = self.blockReplaceTable(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]]
|
data = self.Data[slices[0], slices[2], slices[1]]
|
||||||
mask = blocktable[blocks, data]
|
mask = blocktable[blocks, data]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user