Investigators probing a Nutley teenager's alleged social media threat possibly against the local high school discovered an ominous Instagram video wasn't the first disturbing media he'd shared online, an Essex County assistant prosecutor told a judge on Wednesday.

During their investigation, Assistant Prosecutor Alexander Albu said, detectives discovered a video Joseph Rafanello, 18, had posted online showing a replica of a school built in the popular video game Minecraft, in which online players can construct their own worlds out of Lego-like blocks.

In the video, a player's avatar can be seen walking through the virtual school, complete with lockers, Albu said. At some point in the video, he said, the avatar opened fire on people in front of the lockers.

Officials' discovery of Rafanello's Instagram video post, which featured footage both of him firing a gun at a shooting range and a picture of a school building, prompted a daylong closure of all district schools on Feb. 16.

Joseph Rafanello (Ed Murray | NJ Advance Media for NJ.com)

At the same hearing Wednesday, Rafanello's defense attorney, Alexandra Briggs of the state Public Defender's Office, said there was "absolutely no evidence that my client is the person who created (the Instagram) video," only that he had posted it on his account.

Superior Court Judge Peter V. Ryan ultimately declined prosecutors' motion to keep Rafanello jailed pending trial on a charge of creating a false public alarm, but ordered him placed on home detention with an electronic monitoring device.

In addition to the Minecraft video, Albu said, investigators found a number of other social media messages in which Rafanello joked about death or shared news of mass shootings.

School officials have said Rafanello will not be allowed to return.

"Frankly," Albu told the court, "we're lucky that we're here on a false public alarm today, and it's not something else."

Briggs said she had received numerous letters of support for Rafanello, including from the minister of his church, who wrote that he had known the teenager for years and never had a problem with his behavior.

The attorney said Briggs had been accepted to a program at Bergen Community College to study game testing, which he wanted to pursue as a career.

To detain Rafanello, she said, would be "I think, a big injustice."

As a condition of Rafanello's pre-trial release, Ryan barred him from having any access to firearms. Albu said Rafanello's father, a gun owner, has voluntarily turned over his firearms to the Nutley Police Department for safekeeping.

The judge on Wednesday denied a further request by the prosecutor that Rafanello's father also be made to turn over to police his firearms purchaser ID card.

Rafanello's parents left the courthouse without commenting after the hearing.

Thomas Moriarty may be reached at tmoriarty@njadvancemedia.com. Follow him on Twitter at @ThomasDMoriarty. Find NJ.com on Facebook.

Have a tip? Tell us. nj.com/tips