directed by Tsui Hark . It is a prequel to Hark's 2010 filmDetective Dee and the Mystery of the Phantom Flame, which starred Andy Lau . Taiwanese-Canadian actor Mark Chao takes over from him as a young Detective Dee, Feng Shaofeng plays Justice Department Chief Minister Yuchi, with Angelababy , Lin Gengxin , a returning Carina Lau and South Korean actor Kim Bum making his Chinese debutrounding up the ensemble cast.
In the South China Sea a Chinese fleet is attacked by a mysterious sea creature, destroying many ships and leaving the remaining severely damaged. Shortly after, the young Dee Renjie ( Mark Chao ) arrives in the Imperial Capital Luoyang , after receiving a recommendation to join the Ministry of Justice. In an attempt to appease the sea creature, the city officials have selected the beautiful courtesan Yin Ruiji ( Angelababy ) to be given to the monster. Empress Wu ( Carina Lau ), currently serving as the regent for the current emperor, charges Yuchi ( Feng Shaofeng ), a member of the Ministry of Justice, to investigate the sea monster attacks, threatening execution if he does not succeed in ten days. Shortly after arriving at the temple to be cleansed before the ceremony, Yin Ruiji is attacked by a group of bandits. The attackers are intercepted by Dee, who uses his powers of deduction to anticipate the threat against Ruiji. While Dee and the kidnappers are occupied, the unconscious Ruiji is taken by "the sea monster" but is rescued by Dee before the creature is able to escape. Upon arriving at the temple and defeating the last of the attackers, Yuchi has Dee arrested and sends Yin to Swallow House to rest and to protect her. After being taken to prison, Dee catches the attention of medical assistant Shatuo ( Lin Gengxin ). Dee quickly deduces Shantuo's origins and background and enlists his help to feign a dangerous illness. They immediately ride to Swallow House.
Meanwhile at Swallow House, Yin is interrupted while writing poetry by the sea monster. The monster does not attack but instead lays a jade hairpin at her feet. Yin remembers how she gave that hairpin to her lover, Yuan Zhen. Yuan, in monster form, tries to write but the paintbrush breaks in his grip and he get angry and seems to leave as a group of thugs in masks swim underwater to attack the house. Dee and Shatuo arrive and work to fight off the thugs. Yuchi confronts the thugs but is poisoned by bee stings and dragged into the water. Dee and Shatuo rescue him as he passes out. Dee confronts Yin that she is hiding something about the attack but is suddenly attacked by Yuan. As they fight, Yin suddenly stabs Dee with the hairpin and orders Yuan to flee. Yuan instead almost kills Dee but relents when Yin holds the hairpin to her throat and threatens to end her life. Yuan gives her a sad look and escapes.
The thugs return to their master, who kills one in anger at their failure. Later at Tranquility Teahouse, the same master is seen giving special Bird's Tongue's tea to a wealthy patron, and sadly says his master, Yuan Zhen, is still traveling and doesn't know when he will return. Dee confronts Yin again, and she tells him how she was the most famous courtesan and everyone wanted to be her First Patron. But she didn't care about their wealth and fell for Yuan Zhen, master of Tranquility Teahouse. She loved writing poetry with him, and gave him the jade hairpin as a token of her love. But six months ago, the last letter described an unknown illness, and she had heard nothing since. Dee notices that the faded colors of the hairpin and Yin says it must have been tainted by something. Yin also gives Dee the fabric Yuan was trying to write on. Shantuo appears and tells them someone has been arrested for questioning.
A local mask maker is being tortured and Dee stops them from continuing, declaring that the masks were not made with local materials. Also that the thugs spoke the Dondo language, people who live between the Fuyu Kingdom and Tang Dynasty. Fishing being their main trade, they are excellent swimmers and can stay underwater for long periods of time. Dee gives Yuchi the fabric, and they read the words 'Bird's Tongue'. And Bird's Tongue is only sold at Tranquility Teahouse, given to members of high society including the Imperial court. Dee also deduces that the thugs were not after Yin, but the creature Yuan. They immediately ride to Tranquility Teahouse.
When they arrive, nobody is there so Dee deduces there is a traitor in the police department who informed tea house workers to evacuate. Fortunately Dee had left Shantuo a note to escape with Yin. When they meet, Shantuo tells Dee that the substance that faded the hairpin was a dye mixed with pine oil, called 'Shaxi'. Only a few shops use it and only one is close to Swallow House.
Dee, Shatuo and Yin visit Yuan who is aggressive at first, but calms down after seeing Yin. They take Yuan to the imperial doctor Wang Pu who has been acting psychotic to get a new hand. Wang Pu cuts open Yuan's head and stops Yuan's disease from worsening.