[Tex/LaTex] Add fourth argument to address command in moderncv class

addressesmoderncv

I'm trying to add a fourth argument to the address command in the moderncv class. I've looked for a solution around the internet and tried a few things including attempting to edit the moderncv class file, but I haven't got anything to work properly. The closest I came was using this method; How can I add a new address line within moderncv style, which did get the end result that I wanted except that the last line of the address (Country) and the phone are on the same line. The code and result it produces are as follows:

\documentclass[12pt,a4paper,sans]{moderncv}
\moderncvtheme[blue]{classic}
\usepackage[scale=0.75]{geometry}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\makecvtitle}{\ifthenelse{\equal{\@addresscountry}{}}}%
{\ifstrempty{\@addresscountry}}{}{}
\makeatother

\firstname{John}
\familyname{Smith}
\title{Curriculum Vitae}
\address{42 Apartment complex}{Street}{City\\Country}
\mobile{0000000000}
\email{email@email.email}

Country and phone on same line

Does anyone have any solution to offer, preferably to add a fourth argument to the command, but I would take an amendment to the above code that would move the country onto its own line? Any help is appreciated.

Best Answer

Maybe something like this if I've understood correctly:

\documentclass[12pt,a4paper,sans]{moderncv}
\moderncvtheme[blue]{classic}
\usepackage[scale=0.75]{geometry}
\usepackage{etoolbox}

\makeatletter
\RenewDocumentCommand{\address}{mG{}G{}G{}}{%
  \def\@addressapartment{#1}\def\@addressstreetonly{#2}\def\@addresscity{#3}\def\@addresscountry{#4}%
  \def\@addressstreet{%
  \ifthenelse{\isundefined{\@addressapartment}}{}{\@addressapartment}%
  \ifthenelse{\isundefined{\@addressstreetonly}}{}{\makenewline\@addressstreetonly}%
  }}
\makeatother

\firstname{John}
\familyname{Smith}
\title{Curriculum Vitae}
\address{42 Apartment complex}{Street}{City}{Country}
\mobile{0000000000}
\email{email@email.email}

\begin{document}
    \makecvtitle
\end{document}

Hacked moderncv output