King Statue

The King Statue is one of 42 statues introduced in the 1.1 update. It can be found randomly in underground caverns, and may be harvested with a hammer. When activated, it teleports a random male NPC to the statue's location.

You could use a King and Queen Statue to teleport all your NPCs to an underground safehouse, when there is a Blood Moon or a Goblin Invasion, to keep them safe.