From d805d63c0a0045469aafc993a562b15b4d6fac05 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Tue, 16 Jul 2013 18:06:27 -0400 Subject: [PATCH] Fixed Metadata Issue in SchematicLoader I modified the way SchematicLoader handles blocks with metadata. Previously, we would always copy metadata over without additional checks. If we converted a mod block into Fabric of Reality, metadata would have no effect because FoR did not have subtypes. Now that FoR has subtypes, loading metadata blindly could cause unexpected effects, such as generating Ancient Fabric instead of FoR. I changed the code so that we only count a block as "changed" if we change its block ID and we don't want to preserve the original metadata. In that case, the metadata is set to 0. --- .../mod_pocketDim/SchematicLoader.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/SchematicLoader.java b/StevenDimDoors/mod_pocketDim/SchematicLoader.java index 40a895c..b678dbb 100644 --- a/StevenDimDoors/mod_pocketDim/SchematicLoader.java +++ b/StevenDimDoors/mod_pocketDim/SchematicLoader.java @@ -900,12 +900,10 @@ public class SchematicLoader else if (currentBlock == DungeonHelper.FABRIC_OF_REALITY_EXPORT_ID) { currentBlock = mod_pocketDim.blockDimWall.blockID; - blockChanged = true; } else if (currentBlock == DungeonHelper.PERMAFABRIC_EXPORT_ID) { currentBlock = mod_pocketDim.blockDimWallPerm.blockID; - blockChanged = true; } else if ((Block.blocksList[currentBlock] == null && currentBlock != 0) || currentBlock > MAX_VANILLA_BLOCK_ID) { @@ -916,23 +914,32 @@ public class SchematicLoader //Place blocks and set metadata if (currentBlock > 0) { - //Calculate new metadata for blocks that have orientations (e.g. doors, pistons) - //We're using a workaround to get the desired rotation relative to the schematic's entrance - int fixedMetadata = transformMetadata(blockMetadata, (orientation + NORTH_DOOR_METADATA - entryDirection + 16) % 4, currentBlock); + int fixedMetadata; + + if (!blockChanged) + { + //Calculate new metadata for blocks that have orientations (e.g. doors, pistons) + //We're using a workaround to get the desired rotation relative to the schematic's entrance + fixedMetadata = transformMetadata(blockMetadata, (orientation + NORTH_DOOR_METADATA - entryDirection + 16) % 4, currentBlock); + } + else + { + //Don't include metadata for changed blocks. It's possible that the metadata belonged to a mod block. + //If we include it now, it could cause our Fabric of Reality to change into permafabric. + fixedMetadata = 0; + } //Convert vanilla doors to dim doors or place blocks if (currentBlock == Block.doorIron.blockID) { setBlockDirectly(world, realX, realY, realZ, properties.DimensionalDoorID, fixedMetadata); - blockChanged = true; } else if (currentBlock == Block.doorWood.blockID) { setBlockDirectly(world, realX, realY, realZ, properties.WarpDoorID, fixedMetadata); - blockChanged = true; } else - { + { setBlockDirectly(world, realX, realY, realZ, currentBlock, fixedMetadata); }