diff --git a/blockrotation.py b/blockrotation.py index fa4688b..d67e81a 100644 --- a/blockrotation.py +++ b/blockrotation.py @@ -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] diff --git a/infiniteworld.py b/infiniteworld.py index 03fdc70..1a46961 100644 --- a/infiniteworld.py +++ b/infiniteworld.py @@ -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 diff --git a/level.py b/level.py index 7bf943a..a83c6f8 100644 --- a/level.py +++ b/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]