*Going forward imagine the "three kingdoms" as you would the kingdoms of Britain and Ireland on the map.
The earliest diplomatic contact between Japan and China comes from the Han Commanderies in Korea where Japan actively sought to engage in trade. When the War of 8 Princes occurs in Jin Dynasty China, King Micheon- who used to live as a servant throwing rocks overnight at ponds to keep the frogs quiet and a salt merchant- drives out many of these commanderies (Xuantu, Lelang, Daifeng) to solidify royal power. And with the Xianbei also taking advantage of the chaos in the Jin Dynasty, Micheon allies with Jin to attack Yan to expand westward into Liaodong. This pits Goguryeo (K-Scoland) into a perennial state of war with Yan for the next 100 years.
With Lelang cut off, Japan needed new ways to receive Chinese goods and culture. Since Silla (K-England) was allied w/ K-Scotland at the time and the land route to China was torn up by war, they chose Baekje (K-Ireland) and Gaya (K-Wales), who had grown into a major sea power whilst its northern neighbor was pitched in war. It should also be mentioned that K-Ireland had the best farmland and by the time of the Wa approach, King Geunchogo had annexed the Han Valley where Seoul lies today. The fertile region used to belong to K-Ireland, when it first detached from K-Scotland and had set up its capital in Seoul, but K-Scotland had gained control over it.
When the Sui Dynasty finally unified China, they set their eyes upon K-Scotland. Sui welcomed the Wa (Japanese) envoys with open arms (605, 607, 608) which irked the Korean kingdoms that had been shunned in comparison. The Sui-Goguryeo War ensued and the resulting Korean victory (Battle of Pyeongyang, 500 vs 40,000 while the Sui navy is busy with loot and 10,000 vs 300,000 at Salsu River as the Sui army crosses in retreat due to their navy being destroyed prior and their rucks being abandoned on the long march down) as well as the large building projects opened the dynasty up for usurpation. It should also be noted that direct mainland contact resulted in the transition from Go-On (Cantonese reading transmitted from Baekje and also called Kudara-On or Baekje-Reading) to Kan-On (Mandarin readings popularized during the Tang Dynasty).
The Tang Dynasty followed. King Gwanggaeto of K-Scotland had managed to pacify Yan and a K-Scot royal by the name of Gao Yun became king in Northern Yan, providing a buffer for a time. He also managed to beat back K-Ireland and its ally Japan, basically unifying the peninsula for the first time. However, his descendants -Anjang and Anwon- would reign over natural disasters and infighting between heirs and consorts. K-England took the chance to rebel and allied itself with K-Ireland to take the Seoul region- for itself, as it turned out and they went further to attack what remained of the Gaya Confederacy which was allied to both K-Ireland and Japan. K-Ireland, spiteful that the territorial gains were not shared according to promises, turned on K-England for K-Scotland. Finding itself isolated, K-England opened diplomatic channels to Tang, which intervened albeit reluctantly. Japan then was involved in a war against Tang for the survival of K-Ireland, which it lost. Still, new schools of Buddism and the tea they would bring flowed into Japan from Tang through Ryukyu which served as a prospering middle-man.
The Tang was followed by Liao, Song, Jin, Yuan and Ming Dynasties. Of Which, only the last held Han Chinese control over the whole of the Chinese mainland (Song having shared its territories with Liao and Jin). And Ming is when active diplomatic relations is brought back. It is also when the Wokou or Japanese pirates, who had been recorded raiding K-England shores since the 4th century, would meet its hay-day with better ships able to traverse open seas. Internally, the Nanbokucho and Sengoku Period provided the leeway for pirates bands to operate freely during the many strifes.
When the Sengoku Period ended and Toyotomi Hideyoshi inherited the powers of Oda Nobunaga, who the former served as a faithful lieutenant, he invaded Joseon Korea, a faithful tributary to Ming China. A Japanese double-agent tricked the king, who had been ridiculed in contrast for abandoning his kingdom, into torturing and demoting Admiral Yi SunShin. When he is brought back into service, his proud fleet, which he- as an army general fighting nomadic Manchu Jurchens at the northern border- had to build from scratch, had been decimated by his jealous lieutenant; Won was initially senior to Yi in age and position. Still, he managed to win an engagement 13 vs 133 at the Battle of Myeongryang (usually he would use civilian intelligence to quickly swarm the enemy, having no real naval training) and regain control of Korean seas while the Ming army drove out the Japanese land forces. Japan and China would find itself at war with each other again during the First Sino-Japanese War on the Korean Peninsula which put a death knell, in conjunction with the Opium Wars, to imperial China.
TL;DR- The Japanese sought out Chinese goods and culture through Korea and Ryukyu, with diplomacy as well as piracy. Sui China elevated Wa on equal footing as the rest of the neighboring kingdoms but envoys were sent to China and not the other way around. Japan being a small island nation until Western intervention, held bilateral diplomatic relations mostly with Baekje.