Never resort to spending the night in a dirt hole ever again!
When you first enter the game, you will be gifted a Chunk Protector. This block will immediately teleport invading mobs away from you, so that you can gather resources in the day and build through the night. Even Skeleton arrows and Witch potions are nullified upon entering the border of safety!
Of course, there's a catch. Every day, the Chunk Protector will decay a bit. After a few (configurable) days, it will vanish without a trace. Hopefully by then you'll have built some walls!
Later, you can craft the Area Protector. This block won't go away, but instead of an entire chunk, only protects a small area around itself.
Note to modpack authors: the Area Protector recipe is a placeholder, feel free to change it!