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.
This commit is contained in:
SenseiKiwi 2013-07-16 18:06:27 -04:00
parent c4f0a16af8
commit d805d63c0a

View file

@ -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);
}