Fearing he would be discovered, Yang then killed 17 of his neighbours and fled to Yunnan’s provincial capital Kunming, it said, adding that the murder weapon was a pickaxe.
Yang, who was born in 1989, pleaded guilty to all charges and apologised to the relatives of the dead, it added.
The court adjourned Wednesday afternoon for sentencing.
While mass killings are rare, violent crime has been on the rise in China in recent decades as the economy has boomed and the gap between rich and poor has expanded rapidly.
Studies have also described a rise in the prevalence of mental disorders, some of them linked to stress, as the pace of life becomes faster and support systems wither.