Minor Improvements and Debugging Tweaks
Minor improvements to the readability and performance of SchematicLoader. Added a little temporary code for debugging purposes.
This commit is contained in:
@@ -101,9 +101,6 @@ public class SchematicLoader
|
|||||||
case 5:
|
case 5:
|
||||||
metadata = 3;
|
metadata = 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -184,18 +181,10 @@ public class SchematicLoader
|
|||||||
case 10:
|
case 10:
|
||||||
metadata = 13;
|
metadata = 13;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater ||Block.blocksList[blockID] instanceof BlockDoor ||blockID== Block.tripWireSource.blockID||Block.blocksList[blockID] instanceof BlockComparator)
|
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater ||Block.blocksList[blockID] instanceof BlockDoor ||blockID== Block.tripWireSource.blockID||Block.blocksList[blockID] instanceof BlockComparator)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
switch (metadata)
|
switch (metadata)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@@ -246,25 +235,12 @@ public class SchematicLoader
|
|||||||
case 15:
|
case 15:
|
||||||
metadata = 12;
|
metadata = 12;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
|
|
||||||
if(Block.blocksList[blockID] instanceof BlockStairs)
|
if(Block.blocksList[blockID] instanceof BlockStairs)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (metadata)
|
switch (metadata)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@@ -291,7 +267,6 @@ public class SchematicLoader
|
|||||||
case 4:
|
case 4:
|
||||||
metadata = 5;
|
metadata = 5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +274,6 @@ public class SchematicLoader
|
|||||||
{
|
{
|
||||||
switch (metadata)
|
switch (metadata)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
metadata = 3;
|
metadata = 3;
|
||||||
break;
|
break;
|
||||||
@@ -312,9 +286,6 @@ public class SchematicLoader
|
|||||||
case 5:
|
case 5:
|
||||||
metadata = 4;
|
metadata = 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -727,12 +698,9 @@ public class SchematicLoader
|
|||||||
//second 4 bytes of the block ID
|
//second 4 bytes of the block ID
|
||||||
byte[] addId = new byte[0];
|
byte[] addId = new byte[0];
|
||||||
|
|
||||||
NBTTagCompound[] tileEntityList;
|
|
||||||
|
|
||||||
|
|
||||||
NBTTagList entities;
|
|
||||||
NBTTagList tileEntities = null;
|
NBTTagList tileEntities = null;
|
||||||
|
NBTTagCompound[] tileEntityList;
|
||||||
|
NBTTagList entities;
|
||||||
|
|
||||||
//the wooden door leading into the pocket
|
//the wooden door leading into the pocket
|
||||||
Point3D entrance = new Point3D(0,0,0);
|
Point3D entrance = new Point3D(0,0,0);
|
||||||
@@ -781,7 +749,7 @@ public class SchematicLoader
|
|||||||
|
|
||||||
//load ticking things
|
//load ticking things
|
||||||
tileEntities = nbtdata.getTagList("TileEntities");
|
tileEntities = nbtdata.getTagList("TileEntities");
|
||||||
tileEntityList = new NBTTagCompound[width*height*length];
|
//tileEntityList = new NBTTagCompound[width*height*length];
|
||||||
/**
|
/**
|
||||||
for(int count = 0; count<tileEntities.tagCount(); count++)
|
for(int count = 0; count<tileEntities.tagCount(); count++)
|
||||||
{
|
{
|
||||||
@@ -846,9 +814,8 @@ public class SchematicLoader
|
|||||||
|
|
||||||
int schematicDoorMeta=0;
|
int schematicDoorMeta=0;
|
||||||
|
|
||||||
|
|
||||||
//first loop through the .schematic to load in all rift locations, and monolith spawn locations.
|
//first loop through the .schematic to load in all rift locations, and monolith spawn locations.
|
||||||
//also finds the incomingLink location, which determines the final position of the generated .schematic
|
//also finds the incomingLink location, which determines the final position and orientation of the dungeon
|
||||||
for ( x = 0; x < width; ++x)
|
for ( x = 0; x < width; ++x)
|
||||||
{
|
{
|
||||||
for ( y = 0; y < height; ++y)
|
for ( y = 0; y < height; ++y)
|
||||||
@@ -856,33 +823,33 @@ public class SchematicLoader
|
|||||||
for ( z = 0; z < length; ++z)
|
for ( z = 0; z < length; ++z)
|
||||||
{
|
{
|
||||||
int index = y * width * length + z * width + x;
|
int index = y * width * length + z * width + x;
|
||||||
|
int indexBelow = (y - 1) * width * length + z * width + x;
|
||||||
|
int indexDoubleBelow = (y - 2) * width * length + z * width + x;
|
||||||
|
|
||||||
int blockToReplace=blocks[index];
|
int currentBlock = blocks[index];
|
||||||
int blockMetaData=blockData[index];
|
|
||||||
|
|
||||||
|
|
||||||
//NBTTagList tileEntity = tileEntities;
|
//NBTTagList tileEntity = tileEntities;
|
||||||
//int size = tileEntity.tagCount();
|
//int size = tileEntity.tagCount();
|
||||||
|
|
||||||
|
|
||||||
if(blockToReplace==Block.doorIron.blockID&&blocks[ (y-1) * width * length + z * width + x]==Block.doorIron.blockID)
|
if (currentBlock == Block.doorIron.blockID && indexBelow >= 0 && blocks[indexBelow] == Block.doorIron.blockID)
|
||||||
{
|
{
|
||||||
sideLinks.add(new Point3D(x, y, z));
|
sideLinks.add(new Point3D(x, y, z));
|
||||||
}
|
}
|
||||||
else if(blockToReplace==Block.doorWood.blockID)
|
else if (currentBlock == Block.doorWood.blockID)
|
||||||
{
|
{
|
||||||
if( ((y-2) * width * length + z * width + x)>=0&&blocks[ (y-2) * width * length + z * width + x]==Block.sandStone.blockID&&blocks[ (y-1) * width * length + z * width + x]==Block.doorWood.blockID)
|
if (indexDoubleBelow >= 0 && blocks[indexDoubleBelow] == Block.sandStone.blockID &&
|
||||||
|
blocks[indexBelow] == Block.doorWood.blockID)
|
||||||
{
|
{
|
||||||
exitLinks.add(new Point3D(x, y, z));
|
exitLinks.add(new Point3D(x, y, z));
|
||||||
}
|
}
|
||||||
else if(((y-1) * width * length + z * width + x)>=0&&blocks[ (y-1) * width * length + z * width + x]==Block.doorWood.blockID)
|
else if (indexBelow >= 0 && blocks[indexBelow] == Block.doorWood.blockID)
|
||||||
{
|
{
|
||||||
entrance=(new Point3D(x,y,z));
|
entrance = new Point3D(x, y, z);
|
||||||
schematicDoorMeta=Math.abs(blockData[(y-1) * width * length + z * width + x]+2)%4;
|
schematicDoorMeta = Math.abs(blockData[indexBelow] + 2) % 4; //TODO: Write a function for extracting a door's orientation from its metadata or at least change this to use bitwise operations.
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (blockToReplace == Block.endPortalFrame.blockID)
|
else if (currentBlock == Block.endPortalFrame.blockID)
|
||||||
{
|
{
|
||||||
monolithSpawns.add(new Point3D(x, y, z));
|
monolithSpawns.add(new Point3D(x, y, z));
|
||||||
}
|
}
|
||||||
@@ -893,6 +860,26 @@ public class SchematicLoader
|
|||||||
//Compute the Y-axis translation that places our structure correctly
|
//Compute the Y-axis translation that places our structure correctly
|
||||||
int offsetY = riftY - entrance.getY();
|
int offsetY = riftY - entrance.getY();
|
||||||
|
|
||||||
|
//TODO: HAX REMOVE THIS!
|
||||||
|
schematicDoorMeta = NORTH_DOOR_METADATA;
|
||||||
|
|
||||||
|
if (orientation == schematicDoorMeta)
|
||||||
|
{
|
||||||
|
System.out.println("Intended Orientation: NORTH");
|
||||||
|
}
|
||||||
|
else if (orientation == (schematicDoorMeta + 1) % 4)
|
||||||
|
{
|
||||||
|
System.out.println("Intended Orientation: EAST");
|
||||||
|
}
|
||||||
|
else if (orientation == (schematicDoorMeta + 2) % 4)
|
||||||
|
{
|
||||||
|
System.out.println("Intended Orientation: SOUTH");
|
||||||
|
}
|
||||||
|
else if (orientation == (schematicDoorMeta + 3) % 4)
|
||||||
|
{
|
||||||
|
System.out.println("Intended Orientation: WEST");
|
||||||
|
}
|
||||||
|
|
||||||
//Loop to actually place the blocks
|
//Loop to actually place the blocks
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
@@ -905,7 +892,6 @@ public class SchematicLoader
|
|||||||
{
|
{
|
||||||
realX = (x - entrance.getX()) + riftX;
|
realX = (x - entrance.getX()) + riftX;
|
||||||
realZ = (z - entrance.getZ()) + riftZ;
|
realZ = (z - entrance.getZ()) + riftZ;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (orientation == (schematicDoorMeta + 1) % 4)
|
else if (orientation == (schematicDoorMeta + 1) % 4)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user