Tutorials/Safe home

Unfortunately, there are many dangerous and scary things out there in the Minecraft world that would like to kill you. So here are a few ways to fortify your home and prevent that from happening.
== Environmental ==
=== Lava and water ===
When you extend your base, be sure that nothing fragile like torches or redstone circuits are on the floor in the area. If you strike a water source, it can wash such things away. If you are unlucky, you yourself can also be swept away (maybe into something dangerous) or drown. If you wish to be extra careful, you can place slabs around any redstone circuits you do not want to be accidentally flooded, as slabs block the flow of water.
Lava flows slower, but is much more hazardous, as it sets you and your wooden items on fire.
=== Sand and gravel ===
"Built on sand" is a real life saying which means "This won’t last long". This is true in Minecraft, too. Not only are sand and gravel subject to falls or cave-ins due to obeying gravity, but they also have less resistance to explosions than other materials. Additionally, both of these block types have sufficient other uses (such as sand for glass and gravel for flint, concrete or coarse dirt) that it is best to use them for those, rather than as a construction base.
If you have a floor of sand or gravel, be careful when mining — digging near sand that isn't supported from below WILL cause it to collapse. Be wary of placing torches on sand columns which may fall. If such a torch is destroyed, you may find a creeper or other mob which spawned in the darkness.
If you discover a natural cave with a roof of sand or gravel, be extra careful. Even if you don’t choose it to become your new home, as soon as you place or remove a block near it, the loose sand or gravel will suddenly be affected by gravity and fall down, suffocating you, flooding the cave with lava or water and/or allowing mobs to come in from the dark cave/night above.
In the same manner that sand or gravel makes a poor choice for flooring or a foundation, obsidian is particularly good, due to its high explosion resistance. While it is unlikely that you will be able to produce enough obsidian to build entire walls or floors out of it, it can still be used for foundations, wall trim, and entrance frames. If you are indeed going to use a large amount of obsidian, you may wish to see Tutorials/Obsidian farming.
== Mobs ==
=== General ===
* Don't build out of wood. Yes, it looks nice, but it is fragile to explosions, flammable, and vastly more labor-intensive to produce as a building material, than other blocks. If you must use it, build three block thick walls, with a cobblestone core, and a wood facade as the outer two. If you are in multiplayer, someone could burn your house.
* For general construction, cobblestone is ideal. It is easily obtainable, (via either mining or a cobblestone generator with lava and water, which can be constructed in the vanilla game) is non-flammable and impervious to ghast fire, and also has a decent resistance to explosions. Nether and stone brick are somewhat less plentiful, but more aesthetically pleasing alternatives, with the same defensive advantages as cobblestone. Obsidian is also an ideal choice, as it can resist explosions like TNT or creepers. However, obsidian is hard to find and pick up, as it requires a diamond or netherite pickaxe and lava, and is not very aesthetically pleasing.
* Mines and underground passageways should be no wider than two blocks, to discourage mob spawning. Torches should also be placed at four block intervals.
* Use a fence or a wall to keep all mobs except spiders and spider jockeys off your lawn. Though to keep spiders and spider jockeys out, just ring the top of your house with any block.
* You can create iron golems to defend your territory. These metal wonders will deal lots of damage to any mobs that come near it. They can be very useful for defending small houses. Beware of the creeper though! Iron golems will not attack creepers. 
* Use a cactus fence built from two rows of cacti (like this: (Note: The cactus has to be on sand. Under the sand, place a blast resistant block like obsidian. If you mine below it, the obsidian warns you not to dig up) or an alternating row of cacti and flames from netherrack to keep mobs from passing through it.
* Build a ditch deep enough that the mobs who fall in can’t get out anymore, which is either filled with lava or streaming water leading to a Mob Farm.
* Keep your home area well lit. Mobs only spawn if the light level is below 8; remember that a torch provides level 14 light and this decreases by one for every block away from the torch. Lit netherrack works well, since it doubles as both a light source, and a means of setting mobs on fire, although there is also the risk of setting yourself on fire. So if you do want use this method, bring a bucket of water.
* Another way to keep mobs out of your house is a staircase that has an overhang.
* If you are in single player, a door made of pistons keeps you hidden from mobs almost all the time. Place 2 pistons facing the outside. Then, place a lever right next to both of the pistons backs. Next, turn off the pistons, go outside, then make an arch around the spot where the pistons would stick out. Finally, where the pistons would stick out on the sides make a tunnel to your base. Make sure you can walk through it. When the pistons come out, the mobs can't enter, and skeletons can't reach through your door. Another good way to protect yourself from most Overworld mobs is to create a long hall with a lava floodgate to burn mobs. This can be done with both pistons, or dispensers containing lava buckets. This will not work on Nether mobs.
* Mobs cannot spawn on stairs or bottom-half slabs. Make roofs, catwalks, and even floors out of these to prevent mobs from spawning there.
* Elevate your base and use ladders to reach the entrance. Mobs (except spiders) cannot climb ladders.
=== Creepers ===
Widely considered to be the most dangerous mob(except the bosses) in Minecraft is the creeper, because of the damage it causes to buildings (they can effectively blow large holes in your structures). However, you are safe within your base if there are creepers outside, as they can't get close enough to you to explode. You might even be able to open your door and kill the creeper with a bow and arrows, as long as you keep your distance!
Also, be aware that creepers can detect you and start their fuse from one block away, even if there is a low wall or fence keeping them away. Ways to avoid this are: build a wall at least two full blocks tall (even if it is made of certain translucent blocks such as slabs, fence or glass); or build your home with all spawning surfaces on all traversable paths sufficiently lit.
Different blocks have different resistances to explosions. Dirt walls will be easily destroyed by creepers, while two block thick cobblestone will resist most creeper explosions. Obsidian is explosion-proof with the exception of blue wither skulls, so you can laugh in the face of creepers trying to destroy walls built of this block.
Cats are also a good defense, as creepers will run away if they are in a short distance of one. Even if you've attacked the creeper, it will run away as long as there is a cat nearby, so it is a good idea to put cats around your base.
=== Spiders ===
Spiders can jump 3 blocks, therefore 4 block wide ditches with over hangs won't protect you against spiders/spider jockeys.
Spiders are two blocks wide, which means they cannot move through 1-block wide spaces. Spiders can also climb walls and fences, so you won’t be safe in your walled garden anymore.
To effectively spider-proof your buildings, you’ll have to do one of these things:
 Build a lipped wall (a wall with overhang, mostly at the top. and are common wall-top profiles). This lip can have 1-block wide gaps in it, since spiders require a 2 block wide space to climb. An especially effective spider deterrent is making said lip out of burning netherrack.
 Fences can also work as a wall-top and have the advantage of being able to easily look down to see the wall itself—handy for making sure nothing is at the door before leaving. The wall must be at least two high to prevent spiders, though this is true of regular cobblestone wall-tops as well. 
 Completely cover it with a roof.
 Dump buckets of lava around your castle.
 Build your buildings underground. As long as the entrance to the underground building is only 1 block wide and/or completely enclosed with trapdoors, no Spiders will be able to get in. A top view example: .
 You can keep spiders from climbing walls using glass panes/iron bars to create an edge. example: 
Spiders can climb cactus fences, but they will suffer some hit damage doing so. Therefore, cactus fences only reduce the chances and speed of a spider climbing walls. Either make multiple fences or one fence tall enough to kill any spider that climbs all of them. Each fence only needs to be one row of cacti, because while cacti can’t be placed next to each other, spiders are two blocks wide. Use the method in the General section for a version which works on other mobs too. (If you prefer a wall for keeping off all other mobs, you can use this cactus fence: )
=== Skeletons ===
Skeletons are dangerous because they can fire arrows through gaps in your defenses. Wherever possible, fill open gaps with any of certain translucent blocks such as slabs, fence, or glass to make windows.
Additionally, build low walls or fences in places where you may be in the range of a skeleton since they will only fire arrows at you if they can see you.
=== Spider Jockeys ===
Spider jockeys are dangerous because of combining the climbing and tracking abilities of Spiders with the ranged attacks of Skeletons. You must combine your defensive strategies for both skeletons and spiders.
They're relatively rare, so it is unlikely, but not impossible, to encounter more than one Spider Jockey on the same night.
=== Zombies ===
Zombies are the simplest mob to defend against. With limited mobility and no ranged attacks, walls or pits will be enough to keep them at bay. However, zombies can break down wooden doors to reach you if you're in Hard difficulty. If you're in Hard, you can make a piston door so that zombies cannot get through, or you may make an iron door. Zombies very strongly prefer to smash the top half of a door, but can't jump and smash a door at the same time (jumping resets their progress smashing the door), so putting a 1-deep hole in front of your door should prevent zombies from breaking down the door while still allowing mobs (such as yourself) to enter when the door is open. To prevent other mobs from using the entrance put a two high pillar of sand above the door, though this won't stop or even hurt the offending zombie. A way to prevent zombies from breaking your doors is to put the doors in sideways, rendering them "open" when you close them. Or you could make an iron door with a button on each side. Zombies can break down wooden doors and not iron doors. Zombies will not jump over gaps, so you can use lava trenches. If you are starting/low on Iron, you can use a fence gate or place the Wooden door parallel to either side of the doorway (when you close the door, zombies will think it is open). 
You can also use traps such as pits, landmines, etc.
=== Ghasts ===
If you get lost in the Nether and have no choice but to start a new shelter there, or even if you just wish to try out Nether survival, your biggest problem is ghasts. They can fly through the air, shoot fireballs that explode on contact with the ground (although the explosion is fairly weak), and can spot you from 100 blocks away. Obviously, a simple fence won't suffice. The simplest solution is to build a roof over your entire living area, preferably fairly big, in case you feel like expanding your house later, and start building a house in it. The best material would be glass, as you can see through it and tell if any ghasts are nearby before leaving your dome, with the downside of breaking easily if a fireball hits it and not being a renewable resource in the Nether. A recommended material is to use cobblestone, stone, and any deepslate variant as they are highly defensive against the ghast's explosion, and very easy to obtain. (I have only tested this with cobbled deepslate.)
Because ghasts require a 5×5×5 space to spawn, it is possible to create a large ghast-free area in a cavern by placing blocks so that there is never enough space for the ghasts to spawn. Start by walling in any entrances to the cavern so that ghasts can't wander in. Then, you need to place blocks within that cavern to prevent any new ones from spawning (this is easiest to do in Peaceful difficulty). The simplest method would be 1×1 pillars of any material, placed in a grid across the entire cavern, with 4 clear squares in each direction between each pillar. A more complex method is to place glass blocks in a 3-dimensional grid to fill up the entire space rather than pillars. The only limit to how large an area you can protect is resources. Once you have protected a cavern like this, you can terraform it, and it is actually safer than anything you can build in the Overworld since the only mobs that can spawn are magma cubes and piglins. But you can even prevent these two mobs from spawning in your cavern by covering the entire floor with a material that mobs aren't able to spawn on, such as glass.
A harsh rule in surviving in the Nether is never to build a netherrack house as netherrack is highly flammable and ghasts will probably tear apart your house before you can even admire your beautiful netherrack mansion. (Think: Breaking netherrack with fists is quicker than punching stone.) Another harsh rule to follow is not to leave ANY gaps near the bottom of your house, or else fire will be able to come in if ghasts attack the ground around your house. It's strange, but ghasts seem to not be able to see through glass.
With the addition of nether bricks it is possible to build ghast-resistant structures of material that is readily available in the Nether. You can easily create nether bricks by smelting netherrack and then using the nether brick in a 2×2 square to make the block. 
Maybe build a full obsidian bunker and an iron door on the very front. Obsidian is very hard to retrieve, so build a shell out of stone or cobblestone and cover it steadily with obsidian. Don't use a nether portal for your door, because if you have nothing to reset it, you can be permanently trapped in the nether and can't come home! Although, you can use a fire charge to relight your portal.
== Video ==
Here are some building ideas to help you keep unwanted players and/or creatures from entering your base!
de:Anleitungen/Ein sicheres Zuhause
es:Tutoriales/Hogar seguro
fr:Tutoriels/Construction de maisons sûres
zh:教程/安全的家园