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