Police were called to Sainsbury’s, on Prospect Precinct, on January 13, where Anthony Burton was shouting at staff and telling them not to keep watching him.
“He threw a tub of custard down the aisle and tried to dive at the shelves and was arrested,” said Robert Carr, prosecuting.
Burton, 35, admitted threatening, abusive or disorderly conduct when he appeared before magistrates in Mansfield on Wednesday.
Yvonne Wragg, mitigating, said he had been addicted to heroin and amphetamine since he was 13, but had finally been accepted on a rehab programme.
She said he slept rough the night before and was drenched and freezing.
“He tried to overdose on drink and drugs and caused a bit of a nuisance,” she said.
“He deliberately got arrested so he could have a roof over his head and some food.”
She said police officers contacted him some days later and put him in touch with the Hope for Homeless project, who found him a place to live on Queen Street, Worksop.
“He knows that he needs to change his ways so he can have a decent relationship with his son,” Mrs Wragg added.
He was given a 12 month conditional discharge and ordered to pay a £20 victim surcharge.