[MC-6820] The generation of terrain surface layer produces local straight glitches (fix included) Created: 10/Jan/13  Updated: 14/Aug/20  Resolved: 09/Sep/13

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w07a, Snapshot 13w09b, Snapshot 13w09c, Minecraft 1.5, Minecraft 1.6.1, Minecraft 1.6.2
Fix Version/s: Minecraft 13w36a

Type: Bug
Reporter: Markku Assignee: [Mojang] Jeb (Jens Bergensten)
Resolution: Fixed Votes: 7
Labels: overworld, terrain, world-generation
Environment:

Platform/environment shouldn't matter, as the bug is in the java code.
(Windows 7 64-bit, java 7 64-bit, naturally unmodified Minecraft).


Attachments: PNG File 2013-01-10_18.00.18.png     PNG File 2013-01-10_18.01.53.png     PNG File 2013-01-11_02.05.28.png     PNG File area_3_bugged.png     PNG File example_in_137.png     PNG File sand_bugged_map_2.png     PNG File stripes_on_mycelium.png    
Issue Links:
Duplicate
is duplicated by MC-10296 Basin destroy mycelium, and the sceen... Resolved
Relates
relates to MC-1242 randomly missing topmost layers of th... Resolved
relates to MC-7192 The generation of "terrain" surface l... Resolved
relates to MC-411 Terrain Generation Issues Resolved
CHK:
Confirmation Status: Confirmed
Game Mode: Creative

 Description   

(Closely related to MC-7192.)

The seed for the world of two first screenshots (with swamp and desert) is -807116175.

Bug as seen in 1.4.7
Attached screenshot (..00.18) shows the visual effect of the problem with unmodified 1.4.7: one block too little sand in a straight line form, often repeating in 16-block period. The problem may affect other than sand surface, too. Note, the area around had not yet been fully loaded/generated at the time of the screenshot, so ignore the missing stuff in the distance.

What I expect to be seen
The other screenshot (..01.53) shows the same world and the same location after applying the proposed code fix shown below.

Background/other info
Examples of the bug are quite easy to find in almost any world, given enough flying around. While mostly investigating this in creative mode, it should be just as valid for survival mode.

(Note, this same problem has been around since a loooong time ago, and I submitted a bug report and (almost) the same fix back then. Apparently it was never fixed back then and the soon after implemented changes to terrain generation just made it less noticeable, or the bug has crawled back in.)

Bugged code
The bugged part of code (as seen with MCP 7.26) is:
ChunkProviderGenerate.replaceBlocksForBiome(int, int, byte[], BiomeGenBase[]), 3rd line of the method:
this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);

Fixed code
The fixed version swaps the latter two coordinate axes (Y and Z, I suppose):
this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, 0, par2 * 16, 16, 1, 16, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);

Added
One more screenshot and map snippet, from very old worlds, at the time when I first checked this and made the fixes. The map snippet should clearly visualize it is not about "basins", and the screenshot also shows it is (back then) not about basins, as it was between sand and dirt at the same level. (This difference is because back then the same bug could affect not only thickness, but also the material, if I remember it right. I did have to make changes to 3 more lines in that same method to get all the related things fixed, but with the new biome code, only 1 line is enough.)

Added more
The stone-gray screenshot is taken with a modified client, in order to reveal the full extent of the bug. I modified the world generator to create the ground at fixed height of 7, and for the replace method (which has the bug) to switch the surface stone layer into air instead of dirt or sand. This way the height variation on the ground is actually showing only the surface layer thickness function (and some further random features, like those small ponds, caves and ravines).

As can be seen, there are a lot of straight long east-west steps, exactly at chunk borders. Most of the effect is normally hidden by the random variation in the height of ground. That is, the visual effect of this bug is hidden below random noise of the normal ground level function. One would not detect that bad signs if all the dirt/sand would be digged away in a normally generated map, but the effect is still there.

Uh oh, there is even more
I'm going to make another entry about an equal bug for Nether, but FYI, the corresponding class and method for Nether has the same bug, and another similar, as it is basically an adapted copy of the older overworld generator (with its multiple bugs it had back then).



 Comments   
Comment by [Mojang] Jeb (Jens Bergensten) [ 09/Sep/13 ]

Thanks for the research. I actually found the same problem while I was investigating how the noise patterns worked. Should be fixed in the 1.7 snapshots.

Comment by [Mod] Ezekiel (ezfe) [ 10/Jul/13 ]

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Comment by Markku [ 28/Feb/13 ]

Added 'example_in_137.png'. Seed "137" (defaults), location about 20, 240. (Easier to type in and get to than the mycelium one).

Comment by Markku [ 26/Feb/13 ]

Added stripes_on_mycelium.png, example from issue MC-10296. It is better than my original screenshot for this issue. Notice the z coordinate; the straight mycelium-stone edges run east-west along the chunk borders.

Comment by Adam Navigato [ 26/Feb/13 ]

Yup, this is the exact problem I had. exept mine destroyed half my mushroom biome.
E: and the exact same thoughts. THE EXACT

Comment by Markku [ 11/Jan/13 ]

After analyzing the source code a bit more, I figured that there is a specific piece of code just to create "basins" (i.e. areas where stone is seen directly), and it indeed works by detecting when the surface layer thickness function returns negative values. After a bit of flying around, I was able to find a proper natural looking basin even when that fix was in effect (and thus the basin had no straight edges).

So, while the fix does change the surface layer thickness all around (and thus locations of basins will not match before and after the fix), basins will still exist, and the straight edges will not.

Comment by Markku [ 11/Jan/13 ]

Added one more screenshot, this one with a bit modified client in order to reveal the full extent of the bug.

Comment by Markku [ 10/Jan/13 ]

In that particular location (of my screenshot) it indeed hides it all. Which should indicate that at that position, there shouldn't be any "basin" to start with. I can try and find a spot with a "real" basin (when generated with my fixed code), but do not hold your breath, as it is actually possible that no basins should exist at all, as they could be just a side effect of this bug.

Note, there is a better way to create such basins than swapping to coordinates. Namely, just increase the variation range for the surface layer thickness a little bit (to the lesser direction) and clip at 0.

Comment by Tails [ 10/Jan/13 ]

Alright reopening.

Comment by Markku [ 10/Jan/13 ]

Older example and map snippet.

Comment by Tails [ 10/Jan/13 ]

Well as far as I can tell your fix does not only remove the straight line, but the hole basin itself. Looking at the original generation of the basin, it extends beyond those straight lines.

Comment by Markku [ 10/Jan/13 ]

It sure is a bug. Or really silly joke from the developer who swapped the two coordinate parameters.

Back when I first checked it out, there were 3 similar code lines in that location. The two other lines had parameters in the order x, y, z, but this one bugged line had (and still has) the parameters in the order x, z, y, and they all called the same method. Also, if the "feature" was indeed a intended, those "basins" would have natural edges, not straight steps repeated at every chunk edge and running sometimes for more than 30-40 blocks.
(EDIT: I found my old notes; it was 1 line correctly, 2 lines incorrectly, and a misunderstanding when using a noise-generation function.)

I still have somewhere some even worse screenshots (but I can not redo those worlds any more as the terrain generation changes made old seeds useless), once with "combs" of more than 10 such stripes in a row. The problem was much more stronger back then.

The MC-1242 provides two screenshots, neither showing straight edges on chunk borders. They could be because of this bug (just so small patches that one can not notice the problem), or they could just as well be proper small "basins". So, I can not say whether this is duplicate of that issue or not. Nor can any moderator unless they have better information at hand (like facts from MC developers or access to unobfuscated MC source code).

Note, basins can be indeed a feature, but the straight edges are definitely not. Or does those stripes in my screenshot look like a "basin"?!? Also, the screenshot in the wiki-article has nice natural looking random curves along top and bottom of the picture, but the right and left sides are showing symptoms of those straight edges. Straight edges are possible even normally (just random luck...), but when they are long, and repeat exactly at chunk borders, luck has nothing to do with it. (I can not say yes or no for that wiki screenshot, as I would need to be at the spot, looking at F3-coordinates... But the screenshot I provided for this bug report does have the glitches exactly at chunk edges (as can be noticed from the F3 data)).

Note, minecraftwiki is written mostly by people who do not "read the source code" (and btw, I do, although decompiled only), and they make often incorrect assumptions. For example, that section about basins seems to be lacking any references (to developers or claims of reading source code) that would validate what is written. Unless wikitext provides credible sources/references, it should not be used as an authority.

Comment by Tails [ 10/Jan/13 ]

That's not a bug, it's a world gen feature, a so called "basin". Threrefore duplicate of MC-1242.

Comment by Markku [ 10/Jan/13 ]

This is NOT a duplicate of that whole chunk stripes. Look more carefully at the screenshots provided, this bug only affects the surface layer locally. It does NOT affect e.g. trees etc. and typically does not continue for long distances, like that other bug does. Also, this same bug has been around for a very long time, well before that striped chunks -bug appeared.

(Oh, and I DID use the search, and did see/find that other bug, and after few seconds could easily realize it is different issue.)

Generated at Sun Jan 12 12:12:28 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.