Fence

Fences are wooden wall blocks added in the Seecret Friday update 8, version 1.0.17 Alpha. They count as one and a half blocks tall for player/mob collision, and one block tall for all other purposes. This prevents players and mobs from jumping over them, while using only one actual block space.

A fence occupies the center space of blocks and automatically connects to any block that is placed next to it. Fences are broken most quickly with an axe.

Fences also have a wide use of enclosing animals, such as pigs, chickens, cows, and sheep.

Occurrence
Fences can be found mainly in NPC Villages where they act as small enclosures around some of the houses, on roofs of some houses, lampposts with a block of black Wool placed on it or in houses with a wooden pressure plate placed on top of it, forming a table-like structure.

Outside the villages, fences occur in library rooms of Strongholds as railings or they form something similar to chandeliers. In the latter case, there are many Torches attached to them. Since 1.8.1 fences also form the uprights for the supports in Abandoned Mine Shafts.

Uses
A fence's primary use is for enclosing an area. Functionally, the fence serves to keep mobs and players either inside or outside. A wide area can be made monster-resistant by enclosing it in fences and lighting the inside portion heavily. This keeps any monsters from spawning within the fence, and keeps most monsters which spawned outside the fence from coming in; the exception is spiders, which can climb over it. In addition, while skeletons are unable to cross a fence, they can shoot over it.

Fences can also be used as railings, especially on the edges of balconies or floating platforms. Since fences cannot be jumped over, this keeps players and mobs from falling off while still allowing them to easily see past the fence.

Fences can replace glass for windows as mobs can't see through them as well as fences being renewable.

Before the official release of Minecraft, fence corners did not need to be complete in order to be sealed. A corner where two directions meet at a right angle could be created without the actual corner piece. This would create two separate fences which terminate next to each other without actually touching. While there is a visible gap, players and mobs will still be unable to pass through. This feature could be used to create lengths of diagonal fences, which will appear as nothing but posts, yet will still prevent anything from passing. However, in 1.0.0, the fence's collision box was fit around the fence itself (except for the 1.5 height), thus requiring the corner fence.

Fences can also be used to fuel a furnace, although the player would be better off using the one and a half wooden planks used to create each fence for fueling instead.

In addition, fences can also be used to protect farmland,

Before 1.0.0, placing fences underneath farmland would prevent the farmland from decaying to dirt, and thus the player did not need to worry about trampling crops. This was most likely a bug, although a very useful one.

Equation
To enclose an area of L x W in size (L being length and W being width), where the area does NOT include the fences:

Perimeter = 2L + 2W + 4.

If the area DOES include the fences:

Perimeter = 2L + 2W - 4.

To craft one stack of fences you need 24 logs. This produces three stacks of sticks, which can be made into one stack of fences.

History
When first implemented, the game prevented blocks from being placed above the fence but allowed the fence to be placed on a location when there is a block above it. This loophole was soon commonly exploited to allow fences to be stacked, mainly for aesthetic purposes.

The stacking process was done by creating a wall of blocks one layer shorter than the intended height of the fence and working down. Removing blocks from underneath the fence did not cause it to collapse like cacti and doors, so the lower layers of the wall could be replaced by fences easily, one-by-one. These rules were not applied underwater so they could be stacked just like any other block when submerged.

Minecraft Beta 1.7 lifted this restriction entirely, allowing all blocks, including torches and other fences to be placed on top of it.

Standing on top of a fence in multiplayer used to count as an illegal move, causing players to get stuck. This action has also crashed the server in the past. This bug was fixed in the Beta 1.3 update. Fences became flammable as of Beta 1.6.

As of the 1.9 Pre-release 2, mobs and players can walk directly adjacent to fences, and they will connect to any opaque blocks they are placed next to. The mining area of fences was changed from a full block to roughly the same as the fences themselves in Beta 1.9 Pre-release 5.

Bugs


Fences attempt to attach to all sides of a block if possible at all. As such, they will try to attach to the front and back of Fence Gates.

When two lines of fence meet to make a corner, the resulting corner acts as a block, and you cannot move onto its area.

The 1.9 Pre-release also introduced a new bug. When walking on the block that the fence is occupying, the player will not be 'seen' by mobs. If the player is low on health and being chased by mobs, the player can jump on a fence to avoid taking damage. If you put fences under stairs or slabs,it would glitch you and you cant move. This glitch was fixed.

In SMP, mobs can get on top and even over fences, even if is one layer of fences on top of another layer of fences.