The self-proclaimed “Looney Tunes terrorist” appeared in court Thursday sporting a black eye, as his attorney explained he’d been the subject of a jailhouse beat-down.

“My client was attacked,” defense lawyer James Darrow said of 22-year-old Ashiqul Alam, who’s been held at the Metropolitan Detention Center since his arrest last month. “He has a chipped tooth and a black eye.”

Darrow told Brooklyn federal court Judge LaShann DeArcy Hall that Alam — who was allegedly plotting to shoot up Times Square — has now been put in solitary confinement for his own safety.

Prosecutors say the Queens man initially planned to purchase hand grenades and a suicide vest, but instead opted to purchase a firearm with an obliterated serial number. He allegedly prepared for the attack by undergoing Lasik eye surgery, because he was worried about being dubbed “the Looney Tunes terrorist” if his glasses fell off in the middle of the shooting.

Assistant US Attorney David Kessler revealed Thursday the government has over 30 hours of video of Alam in action, including his purchase of the firearm.

Both sides said plea negotiations continue.