Fixed cuboid algorithm! Multiblock now code-wise functions properly

Signing off. Night all!
This commit is contained in:
Aidan Brady 2013-08-04 03:17:46 -04:00
parent 935b257f51
commit 796ab2eee2

View file

@ -30,6 +30,8 @@ public class BatteryUpdateProtocol
* @param tile - the TileEntity to loop over
*/
public void loopThrough(TileEntity tile)
{
if(structureFound == null)
{
World worldObj = tile.worldObj;
@ -44,20 +46,20 @@ public class BatteryUpdateProtocol
int x = 0, y = 0, z = 0;
if((isViableNode(origX + 1, origY, origZ) && isViableNode(origX - 1, origY, origZ)) ||
(isViableNode(origX, origY + 1, origZ) && isViableNode(origX, origY - 1, origZ)) ||
(isViableNode(origX, origY, origZ + 1) && isViableNode(origX, origY, origZ - 1)))
if((isBattery(origX + 1, origY, origZ) && isBattery(origX - 1, origY, origZ)) ||
(isBattery(origX, origY + 1, origZ) && isBattery(origX, origY - 1, origZ)) ||
(isBattery(origX, origY, origZ + 1) && isBattery(origX, origY, origZ - 1)))
{
isCorner = false;
}
if(isCorner)
{
if(isViableNode(origX+1, origY, origZ))
if(isBattery(origX+1, origY, origZ))
{
xmin = 0;
while(isViableNode(origX+x+1, origY, origZ))
while(isBattery(origX+x+1, origY, origZ))
{
x++;
}
@ -67,7 +69,7 @@ public class BatteryUpdateProtocol
else {
xmax = 0;
while(isViableNode(origX+x-1, origY, origZ))
while(isBattery(origX+x-1, origY, origZ))
{
x--;
}
@ -75,11 +77,11 @@ public class BatteryUpdateProtocol
xmin = x;
}
if(isViableNode(origX, origY+1, origZ))
if(isBattery(origX, origY+1, origZ))
{
ymin = 0;
while(isViableNode(origX, origY+y+1, origZ))
while(isBattery(origX, origY+y+1, origZ))
{
y++;
}
@ -89,7 +91,7 @@ public class BatteryUpdateProtocol
else {
ymax = 0;
while(isViableNode(origX, origY+y-1 ,origZ))
while(isBattery(origX, origY+y-1 ,origZ))
{
y--;
}
@ -97,11 +99,11 @@ public class BatteryUpdateProtocol
ymin = y;
}
if(isViableNode(origX, origY, origZ+1))
if(isBattery(origX, origY, origZ+1))
{
zmin = 0;
while(isViableNode(origX, origY, origZ+z+1))
while(isBattery(origX, origY, origZ+z+1))
{
z++;
}
@ -111,7 +113,7 @@ public class BatteryUpdateProtocol
else {
zmax = 0;
while(isViableNode(origX, origY, origZ+z-1))
while(isBattery(origX, origY, origZ+z-1))
{
z--;
}
@ -125,7 +127,7 @@ public class BatteryUpdateProtocol
{
for(z = zmin; z <= zmax; z++)
{
if(!isViableNode(origX+x, origY+y, origZ+z))
if(!isBattery(origX+x, origY+y, origZ+z))
{
rightBlocks = false;
break;
@ -161,7 +163,7 @@ public class BatteryUpdateProtocol
if(structure.locations.contains(new Vector3(pointer)))
{
structureFound = structure;
return;
}
}
}
}
@ -182,7 +184,7 @@ public class BatteryUpdateProtocol
}
}
private boolean isViableNode(int x, int y, int z)
private boolean isBattery(int x, int y, int z)
{
if(pointer.worldObj.getBlockTileEntity(x, y, z) instanceof TileEntityBattery)
{