private boolean tryConnection(ForgeDirection fd) {
    TileEntity rte =
        worldObj.getTileEntity(xCoord + fd.offsetX, yCoord + fd.offsetY, zCoord + fd.offsetZ);
    if (rte instanceof TileEntityConnectable) {
      TileEntityConnectable rtec = (TileEntityConnectable) rte;
      if (rtec.facing == this.facing
          && rtec.linkedDir == ForgeDirection.UNKNOWN
          && canConnectWith(rtec)) {

        linkedDir = fd;
        rtec.linkedDir = fd.getOpposite();
        onConnect(getMaster() == this, rtec);
        rtec.onConnect(getMaster() == rtec, this);
        rtec.sendPacket();
        return true;
      }
    }

    return false;
  }
 public boolean canConnectWith(TileEntityConnectable rtec) {
   return rtec.getClass() == this.getClass() && rtec.facing == this.facing;
 }