Tutorials/Defense

Some of the best defense measures are those that prevent hostile mobs from spawning entirely or at least prevent hostile mobs from ever getting close to the protected area or defense mechanism. As such, integral to all Minecraft defense systems:
*Coverage - All defenses need to completely defend the protected area or defense, so that mobs entering from any side or angle and of any type will not break through
*Light - A regular system of lighting with torches, fire, or death is needed to prevent hostile mobs from spawning within the protected area
*Sustainability - Defenses should work regardless of player input and, ideally can protect an area indefinitely, either by never degrading in the first place (e.g. walls) or by renewing themselves automatically
*Ease of use - The best defense in the world is useless, if it kills the owner or friends. A good defense must be safe and easy to use. If you have to press 2 buttons and destroy a block to activate it, it is too complicated.
==Video==
==Passive Defenses==
Passive defenses prevent hostile mobs from entering the protected area without any input or sensory devices. The most common example is walls - they do not have to sense a mob coming or sense its position to prevent it from entering a walled off area. The following sections discuss various types of passive defenses, their construction, maintenance, and applicability.
Passive defenses generally fall into one or more categories, sorted by their impact on an aggressive force. 
*Delayers slow down the progress of an enemy inwards. A ring of torches is a delayer because it increases the distance mobs must spawn from the structure (and player), thus increasing the time it takes for them to reach the next layer of defense. Soul sand, slime blocks, honey blocks and slowness potion turrets are also delayers because it reduces the movement speed of anything moving on it, including mobs. Mobs avoid walking on honey blocks and prevent entities from jumping.
*Obstacles are structures that mobs cannot move past without somehow overcoming them. The quintessential obstacle is a wall; a zombie cannot move past a wall without somehow creating a breach or slipping in through an unclosed door.
*Damagers cause harm to an enemy, in addition to just stopping or slowing them down. They might also do neither, letting the mob through without a reduction in speed, but hitting them for damage as they pass. Currently, damagers either inflict direct hit point damage on a mob or set them on fire. If additional status effects are added for example, if the player can create a block, which poisons anything that moves over it, these would also fall into this category. A damaging delayer could be a moat of lava; while a damaging obstacle could be a wall of cacti.
It is important to note that each mob type will treat each defense differently; for example, a ring of burning netherrack does damage to most mobs but is not at all effective against zombie pigmen. Likewise, a wall is an obstacle to a creeper, but is only a delayer to a spider (and not a very effective one at that).
===Walls===
Walls are simple vertical barriers and are the most common means of stopping mobs from entering an area. They can be constructed of just about any material, with varying advantages and disadvantages.
These are simple to make, just make sure to:
*Make them at least 3 blocks high
*Add an extension around the outside to defend against spiders. (consider making it out of glass or another clear block so zombies and skeletons cannot use it to take cover from the sun).
*Torches should be added to the top or sides of the wall, unless low visibility is desired (for example, to reduce the chance of other players noticing a camouflaged wall on a multiplayer server). Torches will prevent unwanted mobs from spawning near a player's wall, and provide a source of light.
*Ditches or moats can be added on the inside or outside the wall as an extra barrier. Cactus can also damage mobs, so placing it is an effective defense.
====Materials====
Cobblestone and dirt are the most common materials for making walls, due to their abundance and ease of obtaining. Walls made in desert biomes may also be made of sand or sandstone.
While dirt does not resist explosions well, it is suitable for most purposes. Both dirt and sand walls are frequently used to surround "first night" shelters. 
Cobblestone and stone are the preferred materials for established miners. They have respectable blast resistance, while being plentiful. 
Sandstone is only marginally better than sand, and should be avoided except for aesthetic reasons.
Glass, ice, fences, fence gates, glass panes, and iron bars are useful as they can be seen through, revealing threats on the other side without exposure. These blocks can also be used to view endermen without attracting their aggression. However, these blocks are vulnerable to damage by creeper explosions. 
The ultimate in wall construction without cheats or ops privileges is obsidian. When constructing, it is faster to position buckets of lava and cool them with water than it is to cool a pool of lava and mine it. 
Although walls are not necessary in creative mode, an indestructible wall would be made mostly or entirely out of obsidian and/or bedrock. Barrier blocks are useful when commands are allowed.
If the player spawns near a desert, it is quite easy to make a wall of cacti, provided the rules for cactus placement are followed. One cactus block will be required on each sand block, which will then grow to be 3 blocks tall, and damaging to mobs which run into it.
Fences are also good for a wall, as even though they appear to be 1 block tall, their collision box is 1.5 blocks tall, making it impossible for mobs to jump over them.
Walls are not effective against spiders and cave spiders, as they can move vertically. However, the addition of protrusions and overhangs on the wall will prevent the spiders from climbing further. A fence as the center block of a wall also prevents spiders while providing no shade for undead mobs. Make this high enough for the fall to deal damage on the spider, unless if low on resources.
======Liquid Walls======
Liquid walls are walls, which are coated on the outside with a layer of water or lava. While they can allow mobs to enter the liquid and float over the top (undead mobs will sink), they can be used as a damage dealer by drowning or burning them. They can also prevent creepers, ghasts and player-made TNT cannons outside the walls from breaking the wall, and water also prevents endermen from taking blocks out of the wall. While liquid walls are much harder to break than regular walls, though, it is still recommended to build an overhang structure to prevent climbing mobs.
======Walls on demand======
The following video shows how to make a large cobblestone wall semi-automatically, using water and lava:
You can see more designs for similar defenses at Tutorials/Shelters#Defense.
===Cheap mob proof doorway===
Here is a cheap mob proof door that can double as a mob trap. However, be careful when using this if you have pets, as it will kill any pets that are sitting.
This method doesn't work in versions 1.13 and later of Java Edition.
=== Pufferfish ===
Dig a block two blocks deep, fill the bottom block with water, and insert a pufferfish into the water block. Fill the top block with the block of the surrounding or a block of your choice. Any mob (including the player) that comes over it will get poisoned by the pufferfish's defense.
===Moats and Ditches===
These obstacles, like walls, present a vertical barrier to incoming (and outgoing) mobs and players. The difference between a moat and a ditch is that a moat usually has water or lava at the bottom.
Dry ditches, like walls, should be at least three blocks tall on the inside edge, with an overhang or protrusions to prevent spiders from climbing them. They should also be at least three blocks wide at their narrowest point in order to prevent spiders from jumping over them. It is recommended that players leave a means of escaping the ditch to the outside (not the inside, which would defeat the purpose of a ditch), in the event that they are knocked into it by injuries, explosions or simple mistakes. 
Moats are constructed identically to ditches, but they are additionally filled with either water or lava, with the specific liquid depending on whether harming the mobs or obtaining their drops is required. A water-filled moat, if constructed correctly, can be built into a drowning tank to kill mobs. The down side to this is that a player needs to be nearby to lure mobs into the water, and the AI for mobs makes it hard to do this. On another note, water-filled moats will still slow mobs down allowing them to be easily picked off with a bow and some arrows, after which the player can swim out and pick them up, or have water currents deliver them to a pick-up point. 
Moats can also be made so that water currents push mobs away; while this makes the moat ill-suited for drop collection, any mob which lands in it will be directed away from the wall, since mobs do not resist water currents, unless they are trying to attack the player.
With the introduction of the new water mechanics in 1.13, moats can be mixed with magma blocks to create an effective mob killing system, as bottom of the magma block will create whirlpool bubble columns that pull a mob to the bottom and then proceed to both pin them at the bottom and deal damage. If you wish to collect any drops created, use a hopper minecart on a powered rail one directly underneath the magma block to collect the drops and deposit them into a storage system.
A lava-filled moat, on the other hand, will kill any mobs in short order by itself, but also destroy any drops. Lava-moats have the additional benefit of producing light, stopping mobs from spawning nearby without torches. However, it can be laborious to collect large quantities of lava, which requires at minimum buckets and the discovery of a sizable source of lava. Structures over a lava moat (bridges, overhanging walls, etc.) should have fences or a raised edge to stop players from falling or being knocked in. Lava should not be used where there are flammable blocks nearby, especially trees, planks blocks, or wool (among others).
Cobweb ditches are more compact than regular ones. They are one block deep and one block wide ditches filled with cobwebs. Mobs get stuck in the cobwebs, immobilizing them to be killed. They can be easily jumped over. This ditch is useful for making a border for your safe area, the outside of which does not need lit up. Cobwebs are found in mineshafts, stronghold library, spider spawner rooms of Woodland Mansions, and zombie villages.
Note: spiders and cave spiders can move freely in cobwebs without being stuck, also some mobs capable of ranged attack can still attack player even though they are stuck in a cobweb.
===Fire===
Walls and ditches of all types can be enhanced with burning netherrack. The base and/or top of walls can be lined with the burning block. Mobs running into the wall stand in the flames, while those that make it over the wall must pass through flames on the way. 
A ditch is easily enhanced in the same way, with the row of fire placed either before the ditch, so that burning mobs fall into the ditch and cannot escape (leaving drops to be collected later), or in the base of the ditch itself, where drops may be destroyed by the fire.
Take note that by itself burning netherrack is not an effective barrier, as many mobs that have more health points can run through the flames and attack the player before burning to death. Combining cacti with netherrack is rather effective. Another option would be to put multiple rows of netherrack with fire, allowing mobs to burn for a longer period of time.
Magma blocks also work, as it can hurt mobs that step on it plus fire will burn indefinitely on magma block, similar to netherrack.
===Cactus===
Creating a ditch filled with cacti at the bottom can be deadly, as the cacti will deal damage and the rugged terrain will severely hinder any mobs that attempt to cross the ditch. A well-crafted cactus ditch can also double as a cactus farm or a cactus wall when the cacti grow.
===TNT===
TNT is a very effective way to kill mobs. Try making a field system in where blocks of TNT pop-up to deal area damage to only mobs. However, TNT is rather expensive to make, as although gunpowder is renewable, the only way to make sand renewable is to buy some from wandering trader, so when making this, it's recommended to have a desert or beach nearby. However, one disadvantage is that TNT can quickly ruin the landscape unless it is exploded in water.
===Mob Navigation Trick===
Instead of a door, a useful trick is to make a 3 block high entrance, then cover the top and the bottom with any sort of slab. The mob's navigation system tells them that they cannot go through the opening. Beware though, as skeletons can still shoot you and creepers can still explode. Planting vines in front of the entrance will cut their vision. Bamboo can also do the same thing as slabs, while skeletons can still shoot through.
====Light====
Light, in the form of evenly dispersed source blocks, should not be underestimated. Even without any physical defensive measures, a wide ring of torches prevents most hostile mobs from spawning. Additionally, if the area is large enough, their random wanderings will not bring them within attack range of the player.
 
Torches are by far the most commonly used light source for this purpose. Moats of lava, glowstone, jack o'lanterns, sea lantern and lantern can also be used, though the scarcity of glowstone and sea lantern in singleplayer is a limiting factor, and pumpkins, which are used to make jack-o-lanterns, are rather hard to find. Lava is sometimes problematic to use because it ignites flammable materials that are within four blocks.
====Soul sand====
A ring of soul sand can be a highly effective delaying mechanism, useful for keeping mobs within range of an active defense or just away from a structure. Keep in mind that a player could use the soul speed enchantment on their boots to go a lot faster. A strip three blocks wide is the minimum for an effective delayer.
Soul sand also makes an excellent bottom for a ditch, although it is worth noting that soul sand also prevents zombies and skeletons from burning.
====Waterfall====
Waterfalls are an effective way to protect your doorway as a last line of defense. By using an overhang, a player can run a waterfall down and over the entrance to their home. A one block deep ditch as wide as the waterfall will prevent the water from flowing in unwanted directions. If a creeper, skeleton, or zombie walks into the waterfall, they will be pushed down into the ditch, effectively stopping them. Though the ditch can be made deeper, it is inadvisable since the player may accidentally fall into the ditch themselves. The downward pressure of the waterfall will cause the player to swim upwards much more slowly than usual, so one block deep is recommended. To enter their home, a player must jump into the waterfall and keep moving forward. This will deposit the player safely on the other side of the waterfall.
====Covered Hole====
A Carpet on top of a String will be invisible to mobs; therefore, mining a hole deep enough to cause damage when you fall through and placing the Carpet over it will stop mobs from pathfinding over. This is useful for mapmakers who want a hidden way to keep mobs from reaching certain areas.
===Combination Defenses===
Like historical defensive formations, the most secure perimeters are based around multiple concentric systems used in synergistic combination. A classic example is a moat surrounding a walled compound - creatures which might reach and breach the wall (e.g., endermen) are delayed or killed before they can reach the wall by the moat (water or lava). 
Any and all of the aforementioned passive defensive measures can be used to make an area secure; the only limit is the amount of time the player is willing to put into it at the expense of other goals and the amount of space and time available.
==Shelter Defenses==
Every shelter needs good defenses, and here are some tips to avoid trouble.
===Explosion resistant houses===
Explosion resistant houses are fairly easy to build, and aren't extremely expensive. Use the Materials section above to assist you in choosing explosive resistant materials.
===Tips===
You should have many windows, so as to be aware of any mobs around. Make sure to light your house and surrounding area well. It is suggested to have an automatic door and protect the surrounding area with a minefield, trap(s), or some sort of defense.
Try making multiple panic rooms or bunkers, preferably for different situations (i.e. creeper in front of your house, skeleton stalking you etc.). Another good idea is to make an emergency exit- this is a deep hole with water at the bottom and some supplies; only use this in an emergency.
Another idea is make a way to get behind, under, or above a hostile mob around your house. This could include a tunnel, a water slide or even a roller coaster. However, this can be rather difficult to make.
Try putting a dispenser filled with arrows in front of your door(s). This way, if there are dangerous mobs in front of your house, you can just press a button and activate the dispenser. You could also use sticky pistons and other blocks to block the entrance. However, this requires you to stay inside or make a second exit.
===Security===
This can come in handy if you have some security systems up. Here are some ideas:
An alarm can be very useful for security. Here's what you will need to make one:
*At least 1 pressure plate
*Lots of redstone (Depends on how far away you want the alarm)
*At least 1 note block
Place pressure plates around an area you would like to protect, or your entrance(s); try to keep them separated as much as possible (optional). Then, attach the note block(s) to the pressure plates with redstone wire. From now on, whenever a mob or a player walks on a pressure plate, the note blocks will generate a sound notifying you. If you mine often, put a note block(s) in your mine or along a rail road.
• A self-destruct system might be useful, to prevent others in multiplayer from stealing your belongings. For this to work, the TNT has to be concealed in a wall, and there should be redstone (that is concealed) attached to a button to activate the TNT. It is also recommended that you have a blast-proof room where you store or hide in before you activate the self-destruct. The button should also be in this room.
• If you have a lot of iron ingots and pumpkins, then you can make the perfect defense. Iron golems have 50 hearts and can kill most mobs in 1-2 hits. Make sure to keep them near your house though; as they may wander away. To prevent this, put the iron golems inside of a trench surrounding your house. The trench should be 2 wide and at least 4 deep, otherwise the golems will fling mobs back out of the trench. An alternative is to leash them to a fence using leads.
You could try dispensers to defend your home entrance, but you would need a lot of arrows. Another idea is to push the mob or player in a moat to it a pressure plate, activating a dispenser. It works better with multiple dispensers, all with redstone repeater.
Finally, you could use fireworks as flares. These can be used when you have a large perimeter wall and a few of your friends as sentries. The sentries can raise the alarm by firing the fireworks. You can also attach the fireworks to redstone circuits. However, note that fireworks are expensive to acquire.
==Active Defenses==
===Materially Inexpensive===
====Overall====
If you have a bow or crossbow and arrows, this is a good way to kill mobs (and perhaps players) that get within range is murder holes. Often incorrectly described as "holes in the ground", the actual term is a hole in a ceiling or gateway, in which defenders can fire at enemies. To make one, extend an overhang over your walls to 5-6 blocks outward. Be sure to add battlements. After you've done that, dig a 1-block hole in the floor every little bit, so no bit of ground is uncovered. You can optionally add trapdoors. Make sure to build it off the ground so that creepers cannot blow up while you are looking through a murder hole. This also adds to the overall safety, as you do not have to lean over the walls and subject yourself to skeleton arrow fire when you're sniping a zombie.
If you make a pit with signs and then water on top of it, you can hold space to swim over it, where as mobs will fall.
====Creepers====
A simple way to protect yourself against creepers (or any other 1x1x2 mobs) is a four door trap. Place four doors with left hinges around a pressure plate. Then, place a block above the pressure plate to prevent the mob from jumping free.
Adding a waterfall layer around your wall will stop any explosions from damaging your wall.
 --
 |PP|
 --
====Zombies / Zombified Piglins====
Zombies are well-known of being easy to deal with, and should only cause concern to the inexperienced player or in the presence of other mobs. Zombified Piglins, on the other hand, are peaceful by default and usually only serve as a nuisance within your Overworld base, but could become a problem in your Underworld (or Nether) base. Zombies can only break down wooden doors, and therefore the best defense against these mobs is always a passive defense. However, protecting your base can be done in multiple other ways which are more effective:
*Placing a column of sand above the door, which will seal the door when it is broken down by a Zombie.
*Placing water next to the bottom of the door. When the door breaks the offending zombie will enter, but other mobs will be slowed down.
*Placing water next to the top of the door and doing the same for lava on the other side.
*Pistons and pressure plates.
*You may also place your door 1 block above ground, so zombies cannot destroy it because zombies destroy doors by breaking the top.
 1 2 3 D=door T= Tunnel wall
 S S=sand W= Water
 S L= Lava
 TDT TDT WDL 
 TDT WDT TDT
====Skeletons====
Since skeletons attack from a distance, the best defense is a good offense. You may need to try and out-range them with a dispenser trap, or simply just bow and arrow to kill from a distance. Skeletons will only chase the player if within 16 blocks, so if you are further than 16 blocks from a skeleton, you should be able to kill it pretty easily with a bow and arrow.
====Spiders====
A clever way to fight spiders is to dig a one wide two deep ditch. Spiders cannot pass through it, but players and another mobs that are 1x2, can. This way, you can simply hit the underbelly of the spider. Spiders also can climb walls, but adding an outcropping or overhang prevents them from getting over since they can't wall-climb on ceilings.
====Spider Jockeys====
Spider jockeys have the dangerous qualities of both skeletons and spiders; they are fast, they can climb walls, and can shoot arrows. Therefore, the best course of action when you are facing one is to kill it off with arrows. Like when fighting skeletons, try to stay at least 16 blocks from the jockey.
====Slimes====
Slimes may spawn above ground during the day. Unfortunately, drowning traps are rather hard to make for slimes, because of the fact that they swim in water instead of sink. However, slimes can be easily defeated using bow and arrow. Due to their melee only attack, they can also be defeated by sword easily. Tiny slimes will not hurt you, though they will push you around. TNT is also very effective against slimes, though it's also quite expensive.
To protect against them if they spawn underground, simply wait and see if any spawn. If they don't, you're fine. If not, try to find where in your mine they are spawning. It's recommended to block off cave systems and noting and cutting off slime chunks, if this happens.
Remember, slimes are also able to spawn in lit up areas.
====Ghasts====
Building a base around your Portal in the Nether is essential to protect from ghasts. Keep in mind that ghast fireballs have low blast penetration, so many materials are ghast-proof (cobblestone being the best known). This doesn't apply to netherrack (which is extremely weak). It is traditional (due to Mojang suggesting it to players constantly on the Xbox version) to build a cobblestone room around the nether portal to protect it. Also, since ghast fireballs can put out an unprotected portal, always bring a flint and steel with you. Note that a ghast fireball can also relight an unlit portal, but only if the fireball itself lands in the frame (rather than with its area effect).
====Players====
Arrow turrets are one way to defend yourself against other players.
They consist of any number of dispensers attached to a rapid pulsar redstone alternater. Simply add a lever to the side of the pulsar, and switch it on or off at will. Make sure the dispensers are loaded with something that will damage the players, such as arrows.
A good, fast machine gun requires one sticky piston, four redstone blocks, one slime block, and four dispensers. Place the sticky piston horizontally and the slime block on the head. Take the redstone blocks and place them on the sides, top, and bottom of the slime block, but not the front. Then go one block forward and place your dispensers. Activating the piston causes a redstone update, causing the piston to go to and fro VERY quickly due to quasi-connectivity. It fires off a stack of ammo in less than a minute. Please note that you cannot turn it off, unless you keep it constantly on by placing a torch on the back.
Players with elytra can raid from the sky, making walls useless (unless it's seriously tall). This causes the need for air defenses. As of recent updates, dispensers shoot fireworks in the direction they're facing, instead of just up. One can build a missile launcher this way, using the quasi-connectivity method stated above, or with a rapid pulsar. The fireworks will explode in the aerial attacker's face and hopefully kill them. However, flying attacks makes the defensive area a 3D space, so multiple launchers may be needed in multiple directions. Range can be altered with the firework's flight duration. This can be used for intimidation purposes rather than actually defending.
These will give any player trying to grief, or steal from, one of your structures, a nice shock. This turret is fully automatic, and as long as you have the arrows to support it, it will demolish anything in front of it. Fire charges can also be used if you have the resources. However, these are not recommended if your structure is made out of a flammable material, as it could set it on fire and burn it down. An easier (and lower resource cost) way to make the turrets more damaging is to put a lava curtain in front of them. This will set the arrows passing through on fire so they cause more damage.
===Materially Expensive===
The following methods require more materials but are much more effective
====Creepers====
Creepers have an explosion nearly as powerful as TNT, so they can easily blow through a wall made of stone; if this happens, it can break a hole in the wall, so that other uninvited mobs can enter your protected area. The only true wall that will protect against creepers is a wall made of bedrock or obsidian, although the former can only be used on a multiplayer server with item spawning enabled, with a mod, or via creative mode. A self-repairing wall can also be created using a cobblestone generator. Place lava and air alternating and also place waters diagonal to the lava. Note that you have to have the lava as source blocks. See Tutorials/Cobblestone farming for more information about different designs of cobblestone generators.
====Zombies and Zombified Piglins====
Zombies are difficult creatures to face when in a claustrophobic area, such as a cave. They can only attack when they are near you which gives you an advantage and a disadvantage. The advantage is that you can take them from a distance and be safe. However, this method gives the zombified piglins an upper hand when there are multiple of either one and they surround you. This leaves you unable to escape. If building a defensive structure to prioritize against zombies, you should try and stay away from them, but in the case that you cannot make sure you have an open area both inside and outside of your defensive structure such as a courtyard, so that you have alternatives of escape. The best defense from piglins and the zombified versions of them is not to attack them. This is because unless you damage them somehow, they will not attack you.
If you have a supply of villagers, you can make an automatic zombie killing machine. There are many ways to do this but the cheapest and most compact is a 1x1, 3 deep pit. Put the villager in the pit, cover it with netherrack and ignite the netherrack. Zombies will walk towards the villager and get set on fire.
====Spider jockeys====
Create a 1 (or more) block wide hole in your wall and shoot the spider (or attack with your sword). When the spider gets killed, shoot the skeleton. You can also try an arrow dispenser trap instead of shooting them yourself.
====Slimes====
You may defend against slimes by simply creating a long 1 block wide, 2 block tall corridor as an entrance to a walled-off area. Place dispensers loaded with arrows on the bottom row of each side, and any solid block on the top. The floor can be made with any material, but cover it with pressure plates.
The said slime will travel through the corridor, and every time it lands on a pressure plate, it will be struck by two arrows, and if or when it splits, the process will simply repeat itself. To collect the drops, simply remove the pressure plates, stroll on through (reloading as you go if needed) and then when you are done, simply replace the pressure plates on the way out. to help prevent mobs entering while you do this, it may be useful to place a door at the entrance or exit in the wall, so you may close it when you are in the corridor and open it to begin the executions. This also works for most other mobs that will fit through the corridor.
====Ghasts====
There is no particularly expensive way to defend against ghasts. Glass or cobblestone (which ghasts cannot damage) will do just fine, but you could also use an expensive material like iron blocks, or obsidian. However, while glass panes protect you from being noticed and fired on by ghasts, they are shattered in the event a stray fireball explodes near the panes. Glass blocks, on the other hand, do not shatter even when hit directly. To fully ghast-proof a Nether fort, use only glass blocks, and use iron bars or nether brick fences for windows.
Ghasts are easy to kill if you can hit them or reflect their fireball at them. Two well-charged arrows or hits with an iron sword will take one down.
====Endermen====
Since endermen can move blocks, but are hurt by water, make a moat instead of a wall. Also, it's better if it flows through a 1x1 block hole in your house, so you get the drops. However, note that endermen can teleport onto the other side of the moat, making this method not as effective.
====Players====
;Basic Redstone Defenses
A drawbridge is a very effective entrance mechanism for a multiplayer base. It works better if within faction land so that it can't be destroyed.
#Create a 8x8x8 pit next to your walls, then fill the bottom layer with lava.
#Build a 4 wide, 8 long bridge over the pit, with one high blocks at each side.
#Remove the floor of the bridge and place trapdoors instead, attached to the side barriers.
#Place redstone all the way along the top of the barriers.
#Place blocks one level above the redstone, so that players cannot jump onto the sides.
#Link the two lines of redstone at a lever.
Pull the lever to open the drawbridge, not letting anything in; or close it so you and your faction can get out.
Spiders can't jump the bridge, players will fall in the lava, and zombies and other mobs cannot cross it, unless it is left closed. So, it pretty much keeps everything out, as long as it is built on faction land.
Another effective trap against enemy players is sometimes known as the "KILL" land mine. Place an upwards-facing dispenser, filled with splash potion of Harming VII, surrounded by pressure plates. This is most effective if there is a ceiling above, so that the player can't run or walk out of range as easily. However, note that splash potion of Harming VII cannot be obtained without item spawning (in multiplayer) or mods. What you can do is use a lower Harming potion that is obtainable in survival, but it won't kill the player instantly.
One of the most cost-effective ways of base protection, especially against players, is camouflaging. Build your base under the ground or high up in the sky, so that it would be hard for players to find it.
;Advanced defense mechanisms
A more advanced defense mechanisms is to make a fake base to mislead players. See the following steps for how to make one:
#Build a hidden base, preferably underground and sealed off with sticky pistons. This is the real base; store all your valuables here and make all the important rooms (crafting rooms, storage rooms, etc.) inside this base.
#Find a flat piece of land around 20-100 blocks away from the your real base's entrance. (If no flat area is available, find whatever comes closest and flatten that out).
#Build a base (a castle-like structure or a village-like one) in this area. If possible, make it a very defensive-looking base, for defending yourself and to keep your enemies out of your actual base.
Though it is best on faction servers, cannons loaded with TNT, potions, or arrows are very fun to use and can do a lot of damage. Keep in mind that TNT will damage terrain, and that an incorrectly-built TNT cannon(s) may blow up your house. There are many designs of TNT cannons you can use. Plus, with slime blocks, you can make them cheaper than ever.
Optional features:
*A secret tunnel from the fortress or fake base to your real base, sealed off with a piston hatch or door at the entrance to the fortress, only operated from the inside (the side of the real base)
*Moats, traps and/or sniping towers around. For towers, make sure they are only accessible from your own base(s)
*A fortress-destruct button at the real base (in case it gets overrun by enemies and you have fled into your real base) to get rid yourself of the foes
Lastly, if your real base is found as well, you do not want to be lost completely. That is why you should always have both a regular storage room as well as a secret one. In the regular one, put items such as iron armor/swords, food, bows and arrows, and building blocks. You could also put a little diamond stuff to stop the attackers from getting suspicious. Then, also build a secret room, with sticky pistons and only open or closable from the inside of it, where you put your really valuable stuff (diamond armor, enchantment table, potions, anvil, diamonds, diamond swords, enchanted bows, etc.)
NEVER allow any member of your faction (provided that you are playing on a faction server) to see this secret room unless you really trust and/or know them. This is because most of the PvP (player vs player) servers with griefing allowed are riddled with traitors and disloyal people who will take your valuables the moment you turn your back on them.
A useful way to protect your valuable items can be found on Tutorials/Traps.
====Mob Defenses====
Mob defenses can be effective, when using the right mobs. The mobs you can use for this are iron golems, snow golems, tamed wolves, or tamed cats. Also, the fact that these do not affect the player (with the exception of an annoyed iron golem or wolves turning on you, if you manage to attack yourself) makes these defenses a little more useful.
;Iron golems:
The best way to use these is keep them in an enclosed space with a door operable by lever. If invading mobs get too close for comfort, you can flick the lever and release the golems to clear the area. Alternatively, you can simply leave them wandering free in a walled-off area.
;Snow golems:
The most efficient way to use snow golems is in a one block wide tunnel. The snowballs from the golems cause no damage (except to blazes), but push mobs back. This can be used to push mobs into lava or something else that damages them, such as cactus. It can also simply be used to delay hostiles.
Placing snow golems in fenced-off "watch towers" may help protect you from hostile mobs as, the mobs will then attack the snow golems, and snow golems snow balls push away hostile mobs.
When using snow golems, make sure you protect the golems from the rain or they will die. Also, as mentioned on the snow golem page, they will take damage in a desert or jungle biome, so defenses utilizing them cannot be used in these biomes.
For more information on utilizing snow golems for defense, see Tutorials/Snow golems.
;Cat:
The easiest way to use cats is to build a fence around them or just let it simply wander around a closed off area. This way, once a creeper comes, the cat will scare the creeper away.
;Tamed Wolf:
Tamed wolves will kill all hostile things except creepers. If they are in sit mode will not attack if chasing a skeleton. The skeleton will not fight back it will only run away. If you are too far away from your wolf it will teleport to you so keep it on a lead attached to a fence.
===TNT Defenses===
TNT, although dangerous and lag intensive, is very effective when killing mobs. Obsidian or self repairing land is useful in an area of little or no use to minimize damage. If you use more than 1 TNT, most drops will also be destroyed.
It can be useful to place the TNT trap above sand or gravel so that a player will be trapped with the charge and a mob won't be able to wander away.
====TNT Cannons====
TNT cannons are one of the best weapons to use. These should be put outside your perimeter. Go to Tutorials/TNT Cannons to find steps to build these.
====TNT Self Destructing Systems====
When you are on multiplayer server, and you don't want your enemies taking your loot. To prevent this, you can make TNT SDS (Self Destruct System) under your base. You need the following to build SDS:
*A lot of TNT
*Plenty of redstone
*Any block (It is recommended that you use a "junk block" like dirt.)
*A lever
*Redstone repeaters
To make a TNT SDS, first dig 3 blocks under your base. Fill it with TNT on 3 blocks under your base. On top of the TNTs, put your normal blocks. On top of that, fill the 3rd floor with redstone. Now put repeaters on the 3rd floor (right-bottom of the real base's floor) and make a road to where you want activator be. Put a lever in the activating zone, and connect your SDS to the lever lever using redstone and repeaters. When your base is in danger and lots of enemies in your base, take as much loot of yours as you can and run. When you are near the Activating Zone, you can now pull the lever and kill all the enemies. One SDS looks like this: 
 
Advantages:
*You can take some of your loot
*Can kill a lot of your enemies at once
Disadvantages:
*You will lose at least 90% of your base
*Takes time to build
*Will lose most of your loot
====Land Mines====
To create a land mine, you'll need:
*Some TNT
*Pressure plates
*Any block except obsidian or bedrock
To make a landmine, you need to dig a two-block deep hole. At the bottom of this hole, place a single block of TNT. Next, place any block on top of the TNT. Lastly, place a pressure plate on top of the block that was placed on the TNT. Once an entity steps on the plate, the TNT will explode, thus causing damage to the entity and the terrain.
Advantages:
*Mobs are usually killed in one blast
*Landmines are relatively easy to make
*They can be triggered from a safe location with redstone
Disadvantages:
*Landmines must be recreated after each use
*The blast may set off other landmines
*You or your shelter could be destroyed
*The mob may go past the TNT while chasing you
*In most cases, TNT is more valuable than the killing of a single hostile mob.
To prevent terrain or structures from being destroyed, place water on a side of the TNT. This trap will still damage mobs, but the surrounding blocks will not be destroyed. However, the trap won't be as effective. You can also put blocks that have tough blast resistance like obsidian around TNT landmine.
If you want to make sure that the mob is killed in the explosion and that your base won't blow up, dig a deep hole (break the block NEXT to the one that you're standing on). Jump in, then replace the bottom block(s) with obsidian and pillar back up. Break the blocks again, and put a TNT block two blocks down, followed by a gravity affected block (either sand or gravel). Finally, put a pressure plate on top.
====Instant Land Mine====
Regular land mines take a couple seconds to detonate, allowing players to run away from the blast. You could always add more TNT to make the blast too big to run away from, but that is a lot more expensive than an instant land mine, which explodes as soon as a player touches the pressure plate and can be made to do more damage than normally.
Tutorial
You will need the following to make one land mine:
*1 pressure plate (Preferably stone, as things such as drops from burning mobs can activate wooden pressure plates.)
*1 powered rail
*2 or more minecart with TNT (If you use more than 2, the explosion will do more damage.)
*1 block (Choose a block that matches the rest of the ground on which the mine will be made on/in.)
*1 rail (You will get it back once you are done.)
To make it, dig a 1x1 hole 2 blocks deep where you want the mine the pressure plate to be located. At the bottom, put the powered rail on one of the blocks. Then, place the regular rail like this:
[] = Normal blocks
__ = Regular rail
== = Powered rail
++ = Pressure plate
 __
 [][] [][]
 [][]==[][]
 [][][][][]
Place a minecart with TnT on the regular rail and push it off the ledge onto the powered rail. Repeat this with the other minecart(s) with TNT. Once you are done with that, remove the rail and a block next to the powered rail. The block you remove has to be one of the blocks that the powered rail is facing. When you are done, it will look like this:
 [][] [][]
 [][]== []
 [][][][][]
Next, replace the block above the powered rail (and minecarts with TNT) and put the pressure plate on it. The finished product is this:
 ++
 [][][][][]
 [][]== []
 [][][][][]
When the pressure plate is pressed down, the powered rail will activate, moving the minecarts with TNT off the rail. They will then detonate, blowing the player into the sky. If the explosion does not kill the player, the fall into the newly formed crater will kill them, or if it doesn't it will severely damage them.
Advantages
*Instantly blows up, giving players no time to escape
*Deals lots of damage
*Easily concealable
Disadvantages
*Damages terrain
*Has a higher chance of detonating during construction than regular landmines
*Are more expensive than regular landmines
*Like all landmines, it can be easily noticed by a vigilant player
==Defense on the Move==
If stuck out on an expedition, always bring a torch. 
By quickly digging 3x3x3 cube into the ground, jumping in, and covering the top layer you've created a little burrow.
Add a torch and a bed and you've got a very quick home.
A variation uses the giant mushrooms. All you need is dirt, bonemeal and a mushroom and you can grow a pretty good shelter near instantly. Bring some blocks to fill out gaps (You should always carry some anyway) and maybe some ladders. Fill with bed and torches, and your home is finished.
Another option is to simply build a 1x2 wall around a space of any desired size, and add some torches and a bed. This is another way to have an instant, quick shelter. However, if you want visibility and have slabs with you, there is a variation. Make the wall, but only 1x1, and add slabs on top of the wall.
If you happen to be stuck in a dense forest and cannot make a wall shelter or hole easily, here are some tips on how to make a shelter. Either pillar jump or use ladders to get to the top of a tree. Then, make a platform on top of the tree. You can add walls if you don't have a bed, although it is recommended to have a bed. Once the platform is made, add torches (or a bed) and either wait or sleep the night away.
==Tips & Tricks==
1#Armor, even leather armor, is very helpful for defense and could potentially save a player's life. If you are going to hunt for ender pearls, looking for strongholds or underground mines, or just going for a nighttime stroll, armor will be very handy.
2#Always have sword with you, as a sword is your main source of offense. It's strongly recommended to have at least 2 swords, and swords can break fairly quickly.
3#In the Nether, it is useful to carry a bow and a stack of arrows to defend yourself from ghasts. Additionally, snowballs will deal points of damage to blazes, making snowballs and snow golems useful in the Nether, assuming you kept the snow golem alive using splash potions of Fire Resistance.
4#Make a hole on one side of your house that is 2 high and 1 wide. Leave the top block open, and for the bottom block, place a dispenser facing outwards, stacked with arrows. Place a pressure plate directly in front of the dispenser, so that you can stand at your window at night, draw a monster's attention, and lure it onto the pressure plate. This will activate the dispenser and effectively kill the offending mob. One will regularly find rotten flesh, bones and arrows underneath. The arrows can be used to replenish your dispenser. Make sure your pressure plate is made of stone, because otherwise, the drops of the dead mobs will keep activating the plate, causing the plate to be disabled for 5 minutes after every use, or until the player picks the items up.
5#Though many players like to use gold for its color and value, it is inadvisable to use gold in armor. It is only a little bit better than leather and is expensive to acquire. It's much more efficient to use iron.
6#Placing a door from the outside is reliable for killing mobs at your door, such as zombie sieges. You can attack mobs from the outside without breaking or opening the door. However, if the door is placed from the inside, you will only open the door, instead of attacking mobs outside.
#If you have diamond armor, wear it when you are fighting other players. This is because other players are just as good as you, and you need to be prepared.
==Innovative Defenses==
These defense tactics are usually only used to impress others in multiplayer, but may also be used as an overly expensive way to secure a shelter. 
===Trapdoor Floating Island===
On the surface, where you enter looks like a 5x5x4 block high house that floats, but on the inside, basically your main house is above the surface, your ditch would be one block out but 3 blocks down so that the basement of your float monstrosity can be a mob farm. It is 5x5 as spiders can jump, so you have 8 opportunities to escape from the spiders and have murder hole on the higher level to kill those spiders.
===Trapdoor Drawbridge===
This is a bridge that can be toggled to let the player in and to keep hostiles out. You will need a standard ditch or moat, a half stack or so of any opaque block, and enough trapdoors to cross over your ditch twice. The blocks should be placed like so:
T=trapdoorB=opaque block
A=air
Layer 1
BBBBTTTTTTTTBBBB
Layers 2 and 3
BBBB
AAAAAAAA
BBBB
It's optional to add an overhang to defend from spiders. Also, to prevent mobs from walking on the side of the trapdoors, place blocks like fences or glass panes. This will make sure that the mobs go through the middle.
LAYER 1
LAYER 2
LAYER 3
===Jumping Puzzle Entrance===
For people who do rather well with jumping puzzles, implement a course that leads to your door. Mobs can't solve jumping puzzles, so your house is safe.
===Floating Island===
Make a floating island house and parkour on from a nearby mountain. This is highly inconvenient, but almost completely immune to mob invasion. You must also make a separate shelter for a mine.
===Fire Mine===
Place a dispenser facing upwards in the ground. Place a pressure plate on the outside edge of the dispenser. Put a flint and steel in the dispenser. Now, when something tries to walk past it, they will trigger the pressure plate. This will cause the dispenser to use the flint and steel, lighting the entity walking past it on fire. The fire will go out shortly, but it will cause massive damage to most mobs.
This defense is best used as a ring around an area you want to defend. Anything steps on the line of pressure plates and it goes up in flames.
===Auto-Refilling Arrow Rapidfire Dispenser===
Place an observer. Put a dirt block on the input side of the observer. Put two dispensers, one on top of the observer, on the same level facing outwards in opposite directions. Connect the two dispensers with redstone and fill the one on top of the observer with one bucket of water and fill the other dispenser with arrows. 
Now connect the arrow dispenser to a redstone comparator which is the input of a redstone torch NOT circuit which then connects to a command block with the /replaceitem command, which finally replaces more arrows in the arrow dispenser. 
To activate the contraption, break the dirt block. The dispenser will rapidly fire arrows in the corresponding direction until it runs out. When it does, the command block will automatically refill the dispenser with arrows. To deactivate the contraption, replace the dirt block in front of the observer.
== blast-proof stone wall ==
position stairs so it looks like a wall from the outside, then water-log them.
==Troubleshooting==
Most problems in your defense will likely stem from a poor light net around your base. Changing the settings to the classic lighting engine can help you find holes in your light pattern.
In the end, a good defensive strategy is only as good as the people that run it. Remember a strategy requires discipline. If you plan on running out for a midnight stroll every night, then don't build a defense, it won't make you any safer.
ja:チュートリアル/防衛
pt:Tutoriais/Defesa