int down = 0;
int left = 0;
int right = 0;
int meta = this.getBlockMetadata() & 7;
BlockVec3 vec = new BlockVec3(this);
TileEntityScreen tile = this;
while (up < 8)
{
if (tile.connectedUp)
{
up++;
TileEntity newTile = vec.getTileEntityOnSide(this.worldObj, 1);
if (newTile instanceof TileEntityScreen)
{
tile = (TileEntityScreen) newTile;
vec.translate(0, 1, 0);
}
else
{
System.out.println("Debug - connected up to a non-screen tile");
tile.connectedUp = false;
tile.markDirty();
up--;
break;
}
}
else
break;
}
vec = new BlockVec3(this);
tile = this;
while (down < 8 - up)
{
if (tile.connectedDown)
{
down++;
TileEntity newTile = vec.getTileEntityOnSide(this.worldObj, 0);
if (newTile instanceof TileEntityScreen)
{
tile = (TileEntityScreen) newTile;
vec.translate(0, -1, 0);
}
else
{
System.out.println("Debug - connected down to a non-screen tile");
tile.connectedDown = false;
tile.markDirty();
down--;
break;
}
}
else
break;
}
vec = new BlockVec3(this);
tile = this;
int leftside = this.getLeft(meta);
while (left < ((up + down == 0) ? 1 : 8))
{
if (tile.connectedLeft)
{
left++;
TileEntity newTile = vec.getTileEntityOnSide(this.worldObj, leftside);
if (newTile instanceof TileEntityScreen)
{
tile = (TileEntityScreen) newTile;
vec = vec.newVecSide(leftside);
}
else
{
System.out.println("Debug - connected left to a non-screen tile");
tile.connectedLeft = false;
tile.markDirty();
left--;
break;
}
}
else
break;
}
vec = new BlockVec3(this);
tile = this;
int rightside = this.getRight(meta);
while (right < ((up + down == 0) ? 1 : 8) - left)
{
if (tile.connectedRight)
{
right++;
TileEntity newTile = vec.getTileEntityOnSide(this.worldObj, rightside);
if (newTile instanceof TileEntityScreen)
{
tile = (TileEntityScreen) newTile;
vec = vec.newVecSide(rightside);
}
else
{
System.out.println("Debug - connected right to a non-screen tile");
tile.connectedRight = false;
tile.markDirty();
right--;
break;
}
}
else
break;
}
this.log("Screen size check midpoint "+up+" "+down+" "+left+" "+right+" ");
vec = new BlockVec3(this);
TileEntity newtile = vec.getTileEntityOnSide(this.worldObj, 1);
TileEntityScreen tileUp = (newtile instanceof TileEntityScreen) ? (TileEntityScreen)newtile : null;
newtile = vec.getTileEntityOnSide(this.worldObj, 0);
TileEntityScreen tileDown = (newtile instanceof TileEntityScreen) ? (TileEntityScreen)newtile : null;
newtile = vec.getTileEntityOnSide(this.worldObj, leftside);
TileEntityScreen tileLeft = (newtile instanceof TileEntityScreen) ? (TileEntityScreen)newtile : null;
newtile = vec.getTileEntityOnSide(this.worldObj, rightside);
TileEntityScreen tileRight = (newtile instanceof TileEntityScreen) ? (TileEntityScreen)newtile : null;
//Prevent 3 x 1 and longer
if (left + right == 0 && up + down >= 1)
{
if (up > 0 && !tileUp.connectedUp) //No need for null check if up > 0