A police officer holds an AR-15, the same model of firearm David Spragg illegally had when his house was searched (file photo).

A self-described "country boy" says he never meant to keep an illegal AR-15 semi-automatic rifle he found in a woolshed, but he did not get around to handing it in.

David Spragg said in the Levin District Court on Wednesday he understood how serious it was to have the gun, given it was made illegal after the March 15 terror attack in Christchurch.

He was sentenced to six months' community detention for having the illegal gun and two other firearms without a licence.

The court, sitting in Palmerston North due to structural problems with the Levin building, heard police searched his Levin property on September 25.

READ MORE:

* AR-15 rifle parts used in Christchurch mosque attacks ruled illegal by police

* Does gun buyback strike the right balance?

* Gun owners say they are being unfairly targeted by proposed law changes

They found the AR-15, a shotgun and a .22 rifle.

He admitted to not having a firearms licence, telling police he used the .22 for hunting and kept the guns in a cupboard.

Defence lawyer Margaret Overton said Spragg, 30, was going to hand in the guns at the police amnesty buyback events held following the March 15 attack.

However, he procrastinated and never got around to it.

He worked full-time and cared for his 5-year-old son and thought taking the guns from the woolshed was safer than leaving them in there.

He was a "country boy" who used his guns for hunting and had no previous convictions, so community work could be appropriate, Overton said.

Judge Gerard Lynch said deterrence was key in the case and not just because having an illegal gun has a maximum punishment of five years' jail.

The AR-15 was no longer being produced by Colt after the much-publicised March 15 attack on a Christchurch mosque, which ended with 51 dead and dozens injured.

"If you didn't need a good reason to hand them in because of your 5-year-old son, the tragic events [of March 15] should have spurred you into action," the judge said.

Handing them in at a buyback event would have ensured no prosecution. "It was a missed opportunity."

Although home detention could have been the punishment, the judge said he did not want to sentence Spragg out of a job.

The judge also ordered the firearms be destroyed.