LOS ANGELES — A man who broke into Sandra Bullock’s home in 2014 and forced the Oscar-winning actress to hide in her closet while calling police has been sentenced to continued mental health treatment and probation after pleading no contest to felony stalking and burglary charges.

Joshua James Corbett entered the plea Wednesday and was also ordered to stay away from the actress and not try to contact her for 10 years. He was arrested inside Bullock’s residence in June 2014 and authorities later uncovered a cache of illegal weapons at his home, but all weapons charges were dropped.

Corbett entered the no contest plea without having an agreement for sentencing with prosecutors, district attorney’s spokesman Greg Risling said.

Bullock never personally appeared during the case, but her frantic 15-minute 911 call was a key piece of evidence that led a judge in 2015 to order Corbett to stand trial.

Corbett, 41, has received mental health evaluations while in custody and his attorneys had hoped to resolve the case with an agreement that ensured he received continued mental health treatment.

He lurked outside the gates of Bullock’s home for several days before hopping the fence on June 8, 2014, according to court testimony. He rang Bullock’s doorbell for several minutes before entering her home through a sunroom door. The actress caught a glimpse of him as he walked past her bedroom door, allowing her to lock herself in a closet and call police.

Corbett was unarmed but he had 25 pages of writings describing his obsession with the actress and calling himself her husband when police arrested him inside the home.