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.
This commit is contained in:
@@ -134,7 +134,7 @@ public class Schematic {
|
|||||||
throw new InvalidSchematicException("The schematic has data for fewer blocks than its dimensions indicate.");
|
throw new InvalidSchematicException("The schematic has data for fewer blocks than its dimensions indicate.");
|
||||||
if (volume != metadata.length)
|
if (volume != metadata.length)
|
||||||
throw new InvalidSchematicException("The schematic has metadata for fewer blocks than its dimensions indicate.");
|
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.");
|
throw new InvalidSchematicException("The schematic has extended block IDs for fewer blocks than its dimensions indicate.");
|
||||||
|
|
||||||
blocks = new short[volume];
|
blocks = new short[volume];
|
||||||
@@ -145,8 +145,8 @@ public class Schematic {
|
|||||||
int index;
|
int index;
|
||||||
for (index = 0; index < pairs; index += 2)
|
for (index = 0; index < pairs; index += 2)
|
||||||
{
|
{
|
||||||
blocks[index] = (short) (((highBits[index >> 1] & 0x0F) << 8) + lowBits[index]);
|
blocks[index] = (short) (((highBits[index >> 1] & 0x0F) << 8) + (lowBits[index] & 0xFF));
|
||||||
blocks[index + 1] = (short) (((highBits[index >> 1] & 0xF0) << 4) + lowBits[index + 1]);
|
blocks[index + 1] = (short) (((highBits[index >> 1] & 0xF0) << 4) + (lowBits[index + 1] & 0xFF));
|
||||||
}
|
}
|
||||||
if (index < volume)
|
if (index < volume)
|
||||||
{
|
{
|
||||||
@@ -157,7 +157,9 @@ public class Schematic {
|
|||||||
{
|
{
|
||||||
//Copy the blockIDs
|
//Copy the blockIDs
|
||||||
for (int index = 0; index < volume; index++)
|
for (int index = 0; index < volume; index++)
|
||||||
blocks[index] = lowBits[index];
|
{
|
||||||
|
blocks[index] = (short) (lowBits[index] & 0xFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the list of tile entities
|
//Get the list of tile entities
|
||||||
@@ -301,6 +303,8 @@ public class Schematic {
|
|||||||
|
|
||||||
public void copyToWorld(World world, int x, int y, int z)
|
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 index;
|
||||||
int count;
|
int count;
|
||||||
int dx, dy, dz;
|
int dx, dy, dz;
|
||||||
@@ -313,7 +317,8 @@ public class Schematic {
|
|||||||
{
|
{
|
||||||
for (dx = 0; dx < width; dx++)
|
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++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user