Portals

Here is a brief explanation of how portals work, edited slighty from minecraftwiki.net.

The Nether is 1/8 the size of the Overworld horizontally. By moving 1 block horizontally in the Nether, players have moved the equivalent of 8 blocks on the Overworld. This does not apply to the Y-axis. Portals do not "remember" which portal they are linked to, but perform the following whenever a portal is used by a player:


 * 1) Calculate the destination coordinates based on the entry coordinates by flooring the X- and Z-coordinates (Java floor method the largest integer less than or equal to the argument, so an X- or Z-coordinate of -29.5 becomes -30, not -29), then multiplying or dividing them by 8 depending on direction of travel. The Y-coordinate is not modified. This translation can be represented by the following pseudocode: {X, Y, Z} → {floor(X) ×/÷ 8, Y, floor(Z) ×/÷ 8}
 * 2) * Note that in the XBox 360 version, the ratio is 3 instead of 8 because of the world size limitations.
 * 3) At destination, the game looks for the closest active portal block within a 128-block "radius" (actually, a maximum distance along a horizontal axis) of the player (257 × 257 × 128 tall box volume centered horizontally on destination coordinate). An active portal is defined as a portal block that does not have another portal block below it, thus only the 2 lowest portal blocks in the obsidian frame are considered. If one exists, teleport the player to the closest one as determined by a 3D distance in the new coordinate system (including the Y coordinate, which can cause seemingly more distant portals to be selected).
 * 4) Only the coordinates 0-127 on the vertical Y-axis is searched, even for new worlds with high limits larger than 127 after patch 1.20, so the search algorithm will not find any portals created above Y=128.
 * 5) If no active portal blocks exists in the above search region, the game creates one by looking for the closest possible valid position within a 16-block "radius" column (33 × 33 × 128 tall box volume centered horizontally on the destination coordinate) that has enough space to spawn a portal and is on solid ground. The game prefers to create the exit portal with the same facing orientation as the entry portal, but will check the other 3 directions as well. Regardless of orientation, the closest valid position in 3D distance is always picked.
 * 6) Only the coordinates 0-127 on the vertical Y-axis is searched, even for new worlds with high limits larger than 127 after patch 1.20, so the search algorithm will not build any portals above Y=128.
 * 7) And if there are no valid spawn locations within the spawn region above, the game will finally create a portal at the destination coordinate (and clamp the Y-coordinate to between 70 and 118), converting any blocks (including air blocks) in the way into a portal. Such a portal has 4 extra obsidian blocks placed on both sides of the portal to prevent the player from falling.

[Read More]