A yob threatened police with a knife in a drunken rage and screamed: "I'm going to f****** stab the lot of you up."
Simon Pickering, aged 27, of Smelter Wood Road, Richmond, brandished the blade after arguing with officers at a police cordon.
Sheffield Crown Court heard firefighters had attended a blaze in a downstairs flat in Upperthorpe last year.
The defendant was making his way back to a property, situated on the top floor, when he was stopped by police.
Prosecuting, Camille Morland said Pickering arrived back in a drunken state and tried to get past the police cordon into the flat.
The court heard he was pushed backwards by one officer and Pickering then rang 999 to report he had been assaulted, requesting another officer should replace him.
But Pickering managed to get past the cordon and the situation 'escalated' with the defendant returning with a weapon.
Ms Morland said: "The defendant got into the flat and got a kitchen knife and then proceeded to start waving it around shouting 'I'll f****** stab the lot of you up'.
"He was sprayed with PAVA spray and made his way back up and locked himself in the flat."
Police managed to force their way in and disarmed Pickering before cuffing him.
The 27-year-old originally denied having a knife when interviewed by police.
Andrew Smith, defending, cited his previous convictions and called his behaviour 'disgraceful'.
Mr Smith said Pickering had problems with his mental health and a factor was down to his 'long standing drug addiction'.
"In essence, he got the wrong end of the stick with the officers. He is prepared to cooperated with a drug rehabilitation order," Mr Smith said.
Pickering pleaded guilty to affray at an earlier hearing and was ordered to carry out a 18 month community order with a 15 day drug rehabilitation requirement.
Judge Paul Watson QC said Pickering had a history of offending but many of it was 'low grade'.
Addressing the defendant, Mr Watson QC added: "You're not a serious risk to the public but you certainly are a menace.
"If you do not comply with this community order you will be back here and you'll have to do this all over again."