The time was around 660s A.D.
When the Great Monk WonHyo (元曉大師) was 40 years old, the monk Xuanzang (玄麌法師 현장법사), who had been in China at that time, had been called Tripitaka (삼장법사) since he had returned from India, and he was excellent in the three studies of sutras (경), vinaya (율), and sermons (논). Also, the great monk Ji-eom (智儼 지엄), who was a master of the Avatamsaka (화엄) school, was also famous in Tang China at the time.
So, Wonhyo wanted to study in China, and started the long journey to Tang China with a fellow monk, Uisang (義湘), who was 10 years younger than him. After leaving Gyeongju, his hometown and the capital of Sila, and arriving at the coast of Namyang (南陽) in Gangju, today's Suwon, Korea, the sun was setting. The weather was bad, and a sudden downpour of rain was pouring down, making it even darker. They decided to stay overnight in a hut to avoid the rain. In the middle of the night, Wonhyo felt very thirsty. So he felt around just in case, and he reached a bowl of water at the tip of his finger. He hurriedly drank the water and continued to fall into a deep sleep.
When the day dawned, he looked around. Then he was shocked. The place he had thought was a hut was actually a tomb, and the water in the bowl was rotten water that had collected in the skull. In the old days, there was a custom of building a stone house like a basement, making a room, putting a coffin in it, and storing things used in the living. When he looked at the skull filled with rainwater, he saw countless insects swarming inside. When he saw this, he felt ill, started to vomit, and threw up all the food he had eaten the day before.
However, after all this suffering, Wonhyo discovered a great truth and attained true enlightenment. The sermon from the Awakening of Faith came back to life.
That sermon was 心生卽種種心生 心滅卽種種心滅 如來大師云 三界虛僞 唯心所作, "When one thought arises, many various minds arise, and when one thought disappears, many various minds disappear. The Buddha said, “The three realms are false, and only the mind creates them.” The mind is born of the kind of mind, and the mind is destroyed of the kind of mind. Thus, Buddha said, “The three realms are false, and only the mind creates them.”
This is the essence of the Buddha's teaching. In other words, the interpretation of the mind is a thought that runs through numerous sutras.
Realizing that all events and phenomena arise solely from the discrimination of the mind is realizing the truth of Buddhism.
Wonhyo realized this. Then Wonhyo laughed like a madman, danced, and sang. Uisang asked him what was going on, but Wonhyo only smiled and did not answer. Finally, he said to Uisang.
“Did you see me struggling so much last night because I was thirsty?”
“I saw my brother suffering from thirst, drinking water from a bowl.”
“When I woke up this morning, it wasn’t ordinary water, but rotten water that had accumulated in a human skull. When I drank it last night, it was so refreshing that I slept without knowing anything, but this morning, when I discovered that it was rotten water from a skull, I vomited and suffered greatly.
My mind at night and my mind in the morning are probably no different. When I didn’t know, it was refreshing, but when I knew, I felt bad. Isn’t it true that the dirty and clean are not in the things themselves but in the mind? Therefore, I now realize that everything is created by the mind (一切唯心造).
In the Avatamsaka Sutra, “All dharmas arise from discrimination and also, conversely, disappear following discrimination. If all discriminating dharmas are eliminated, this dharma is not birth and death.”
"I realized this truth, so I cannot overcome my joyful heart. So how could I not dance and sing?”
But Uisang did not accept Wonhyo’s words, even though they sounded plausible. They parted. Uisang continued on his journey to China while Wonhyo went back to Gyeongju, Sila, because he had no reason to continue on to China. Through this experience, Wonhyo Daesa, who realized the idea of the three realms being mind-only, did not need to go all the way to Tang China to ask about the dharma.