Updated

A man who broke into Sandra Bullock’s home in 2014 was sentenced to continued mental health treatment and probation after pleading no contest to felony stalking and burglary charges.

At the time of the break-in, the 52-year-old Oscar-winning actress was forced to hide in her closet while she called police. Authorities later uncovered a cache of illegal weapons inside the intruder’s home, but all weapons charges were dropped.

Joshua James Corbett entered the plea Wednesday and was also ordered to stay away from Bullock and not attempt to contact her for 10 years. District attorney spokesman Greg Risling said Corbett entered the no contest plea without having an agreement for sentencing with prosecutors.

SANDRA BULLOCK DONATES $5,000 TO STRUGGLING FORMER BEVERLY HILLS POOL MANAGER

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

The 41-year-old received mental health evaluations while in custody and his attorneys had hoped to resolve the case with an agreement that ensured he received continued treatment.

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

SANDRA BULLOCK EXPLAINS WHY SHE'LL NEVER TAKE A SELFIE

Corbett, who was unarmed at the time, had 25 pages of writings describing his obsession with Bullock. When arrested, he described himself as Bullock’s husband to police.

Corbett’s attorneys challenged the basis for police searching his home and finding an arsenal of weapons that led to numerous felony firearms charges.

Corbett was charged with possessing a machine gun, two counts of possessing an assault weapon, as well as 10 counts of possessing a destructive device, which was described as tracer ammunition. He faced up to 12 years in prison if convicted of those charges.

SANDRA BULLOCK NAMED 'WORLD'S MOST BEAUTIFUL WOMAN'

In February, a California appellate court ruled Los Angeles police detectives had violated Corbett's rights when they obtained authorization to search his home for guns.

During a hearing last year, Corbett described his feelings about the break-in at Bullock's house, saying he gave police the combination to his gun safe because he felt guilty about breaking into Bullock's home.

"I'd already hurt somebody that I didn't intend to," he explained while testifying during a hearing. "I did not want to affect my family with my actions."

Corbett's attorneys have suggested he was experiencing opiate withdrawal when he granted police consent to search his home for several legally purchased weapons. However, a judge rejected their attempts to overturn his consent for the search, which turned up the illegal arms and ammunition.

The Associated Press contributed to this report.