From 8b64165e2eaf1c7eb8d35fd62b8ba05901e66935 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 28 Jul 2013 23:02:56 -0400 Subject: [PATCH] Improvements to Schematic Fixed bugs and made minor changes to Schematic. I've tested that it works properly now. It still needs to perform additional DD-specific functions and must be integrated to dungeon importing. --- .../mod_pocketDim/schematic/Schematic.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/schematic/Schematic.java b/StevenDimDoors/mod_pocketDim/schematic/Schematic.java index 1c4c4d5..a7baeb9 100644 --- a/StevenDimDoors/mod_pocketDim/schematic/Schematic.java +++ b/StevenDimDoors/mod_pocketDim/schematic/Schematic.java @@ -134,7 +134,7 @@ public class Schematic { throw new InvalidSchematicException("The schematic has data for fewer blocks than its dimensions indicate."); if (volume != metadata.length) throw new InvalidSchematicException("The schematic has metadata for fewer blocks than its dimensions indicate."); - if (volume > 2 * highBits.length && highBits.length != 0) + if (volume > 2 * highBits.length && hasExtendedBlockIDs) throw new InvalidSchematicException("The schematic has extended block IDs for fewer blocks than its dimensions indicate."); blocks = new short[volume]; @@ -145,8 +145,8 @@ public class Schematic { int index; for (index = 0; index < pairs; index += 2) { - blocks[index] = (short) (((highBits[index >> 1] & 0x0F) << 8) + lowBits[index]); - blocks[index + 1] = (short) (((highBits[index >> 1] & 0xF0) << 4) + lowBits[index + 1]); + blocks[index] = (short) (((highBits[index >> 1] & 0x0F) << 8) + (lowBits[index] & 0xFF)); + blocks[index + 1] = (short) (((highBits[index >> 1] & 0xF0) << 4) + (lowBits[index + 1] & 0xFF)); } if (index < volume) { @@ -157,7 +157,9 @@ public class Schematic { { //Copy the blockIDs for (int index = 0; index < volume; index++) - blocks[index] = lowBits[index]; + { + blocks[index] = (short) (lowBits[index] & 0xFF); + } } //Get the list of tile entities @@ -301,6 +303,8 @@ public class Schematic { public void copyToWorld(World world, int x, int y, int z) { + //This isn't implemented as a WorldOperation because it doesn't quite fit the structure of those operations. + //It's not worth the trouble in this case. int index; int count; int dx, dy, dz; @@ -313,7 +317,8 @@ public class Schematic { { for (dx = 0; dx < width; dx++) { - world.setBlock(x + dx, y + dy, z + dz, blocks[index], metadata[index], 3); + //Don't cause block updates! + world.setBlock(x + dx, y + dy, z + dz, blocks[index], metadata[index], 2); index++; } }