public static TileEntity getTileEntity(IBlockAccess blockaccess, int x, int y, int z) {
   HashSet<ChunkCoordinates> visited = Sets.newHashSet();
   Block block = blockaccess.getBlock(x, y, z);
   while (block != NailedBlocks.portalController) {
     if (isValidLinkPortalBlock(block) == 0) {
       return null;
     }
     ChunkCoordinates pos = new ChunkCoordinates(x, y, z);
     if (!visited.add(pos)) {
       return null;
     }
     int meta = blockaccess.getBlockMetadata(x, y, z);
     if (meta == 0) {
       return null;
     }
     if (meta == 1) {
       y--;
     } else if (meta == 2) {
       y++;
     } else if (meta == 3) {
       z--;
     } else if (meta == 4) {
       z++;
     } else if (meta == 5) {
       x--;
     } else if (meta == 6) {
       x++;
     } else {
       return null;
     }
     block = blockaccess.getBlock(x, y, z);
   }
   return blockaccess.getTileEntity(x, y, z);
 }
  @Override
  public void setBlockBoundsBasedOnState(
      IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
    int i = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
    float f = 0.375F;

    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.375F);
    if (i == 0) {
      setBlockBounds(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 1) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    }

    if (i == 2) {
      setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
    }

    if (i == 3) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
    }

    if (i == 4) {
      setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 5) {
      setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
    }
  }