Andre C's Channel, Episode 62: How far can you go before the game gives in?
The cause of the "Far Lands": (Very technical)
The terrain is generated based on 16 octaves of Perlin noise. Each noise generator takes floating-point inputs and uses those to interpolate between noise values at whole numbers. It does so by:
1.casting to a 32-bit integer, where Java rounds toward zero and handles overflow by picking the closest representable value;
2.subtracting one if the integer is greater than the original input, to always round down;
3.subtracting that integer from the original input to get a remainder in the interval [0, 1) suitable for interpolation.
It covers an interval of [−2^31, 2^31) without causing any problems. The problem is that many of the octaves cover a scale much smaller than a block, with up to 171.103 noise units per block. Indeed, 2^31≈171.103×12,550,824.053. Once this value is exceeded, the integer will always be 2^31−1, picking the same noise values on that axis every time. This is the reason for those long unchanging tunnels in the Edge Far Lands, and plains in the Corner Far Lands.
At the positive end the remainder starts out relatively small but usually much larger than 1, and grows by 171.103 per block. At the negative end, the remainder starts at −2^32. This value is then adjusted by ((6x−15)x+10)x^3 for quintic interpolation. Even one block in at the positive end, this is already around 10^11. The negative end starts all the way around −10^49! For the Corner Far Lands, multiply the values of both edges. When interpolation (really extrapolation) is attempted with values as large as these, it produces similarly large output. That output completely dwarfs all other terms that would normally give the terrain its shape, instead effectively only passing the sign of this one noise function through.
It was fixed by taking the remainder of the input divided by 2^24. Noise repeats every 2^8 units anyway, so it has no side effects. But it does prevent the overflow. By removing these instructions, the Far Lands can be returned to current versions of the game.
There are several factors making things slightly more complicated:
*Noise is only sampled every four blocks and linearly interpolated in between. This is why when 12,550,824 is affected by the bug, it reaches out three more blocks to 12,550,821.
*Each noise generator picks a random offset in [0, 256) to add to its input. This will usually move the boundary under 12,550,824, starting the Far Lands at 12,550,821. With a few seeds it might not, putting the start at 12,550,825. Very rarely, if the boundary is just barely within 12,550,824, the first couple blocks of the Far Lands might look somewhat normal. The southern and eastern Far Lands do this independently of one another. At the negative end, the Far Lands always start at block coordinate −12,550,825, with the positive edge of those blocks at −12,550,824.
*There are actually two sets of noise generators, which are blended together based on another noise generator. This is responsible for relatively smooth alternation between two sets of tunnels or plains. Occasionally, one of the noise generators starts generating Far Lands before the other because it uses a different offset, producing an incongruous boundary.
*A second set of Far Lands starts around ±25,101,648, where another octave overflows. There is no visible change because the original Far Lands dwarf them like everything else.