A Ryedale man threatened to murder everyone in his block of 25 flats and then burn down the building, York Crown Court heard.