(Possible test cases moved under own heading below.)
Slightly related to MC-7196, same classes and methods in question, almost the same effect, but different bug in the code.
Cave/tunnel generator, both for Nether and overworld, may sometimes cut tunnels of at chunk borders, leaving flat straight walls, or have straight-angle incursions of stone into the tunnel. For this bug I do not have examples, because knowing which particular straight wall is because of this bug (rare) or because of the much more common MC-7196 is difficult.
However, explanation of mistake in the code might suffice...
Background
The tunnel generation algorithm has an optimization which calculates if the distance from the algorithm's current "tunnel digging" point to the generated chunk's center is longer than the remaining length of the tunnel. If the former length is longer, the tunnel can not reach the chunk, so the algorithm can be stopped there.
The bug
The distance between current digging point and chunk center is basically calculated correctly (though kept in the squared value), but the comparison is done with incorrect math, trying to subtract the square of the remaining length from the squared distance, and then compare the result to tunnel's maximum diameter (and a bit more) squared. Squared values can not be subtracted or compared like that.
If one does so (like in this case), the results will (incorrectly) vary depending on which particular relative locations are in question. Thus, at one chunk, the algorithm may think that the tunnel can not reach the chunk, while drawing the neighbour chunk, the algorithm thinks it will easily reach that chunk, and can correctly carve it, right the to edge of that chunk, leaving nasty straight cut at some chunk border.
Here is the bad code, with my variable name interpretations:
MapGenCavesHell.generateCaveNode(...)
double xDeltaToChunkCenter = startX - chunkCenterX;
double zDeltaToChunkCenter = startZ - chunkCenterZ;
double remainingLength = (double)(fullLength - currentDistance);
double tunnelDiameterAndMore = (double)(diameterVariance + 2.0F + 16.0F);
if (xDeltaToChunkCenter * xDeltaToChunkCenter + ZDeltaToChunkCenter * ZDeltaToChunkCenter - remainingLength * remainingLength > tunnelDiameterAndMore * tunnelDiameterAndMore) {
return;
}
Exactly equal bug exists in the MapGenCaves class.
The fix
MapGenCavesHell.generateCaveNode(...)
double xDeltaToChunkCenter = startX - chunkCenterX;
double zDeltaToChunkCenter = startZ - chunkCenterZ;
double remainingLength = (double)(fullLength - currentDistance);
double tunnelDiameterAndMore = (double)(diameterVariance + 2.0F + 16.0F);
double directDistanceSquared = xDeltaToChunkCenter * xDeltaToChunkCenter + zDeltaToChunkCenter * zDeltaToChunkCenter;
double tunnelsMaximumRemainingReachSquared = (remainingLength + tunnelDiameterAndMore) * (remainingLength + tunnelDiameterAndMore);
if (directDistanceSquared > tunnelsMaximumRemainingReachSquared) {
return;
}
That is, the math has been changed to compare the distance squared against remaining reach squared, which should be valid math.
Possible test cases
From Jens-Oliver Tofahrn, looks like possibly at least 3 "cuts" near each other; tp goes right in there, dark place, get torch:
Demo seed "North Carolina" or -343522682, F3-n, F3-g/tp @s -48.42 18.94 0.10 -463.95 55.80
Multiple cuts near each other, the first place even has two cuts in the same view:
Seed 1479112774635546442/tp @p -440 62 11 107 20
/tp @p -457 62 18 -140 19
/tp @p -447 62 -96 114 -12
(Wery Old: Semi-quick test case, though not 100% certain if it is caused by this issue: seed -4542366974610774625, Nether 218, -67, dig down to about 19 and look south east.)
History
This bug has been around for at least since summer 2011. Back then I found it, fixed it, reported it, and provided screenshots for "before and after". I estimated very roughly that in the overworld, about 1/4th of straight wall glitches in tunnels were caused by this bug, the rest by the other bug (MC-7196 when it was still effective for overworld, too), based on observed differences while enabling either fix separately.
Related issues
is duplicated by
Attachments
Comments


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

Since this bug pretty much requires current source code (or the decompiled one) to be proven, and I seem to be unable to find recent enough MCP version, I can not confirm the status either way for now. However, I attached screenshots (and locations) for some very suspicious looking cuts in tunnels at coordinate divisible by 16 (the hallmark of this bug and couple already fixed ones), which should indicate that either this or some other unknown bug is still affecting.
cut1.png and cut2.png are from 1.7.5 as seen in the debug data of the screenshots. Same tunnels and cuts in same places in 14w11b.

This may be a problem of an invalid terrain generator but it also might be a cause of swap of MC versions that included a different terrain generator which usual happens after a terrain generator update (as for example seen here: http://fc07.deviantart.net/fs70/f/2011/144/d/2/minecraft_chunk_error_by_punkboi102-d3h5hdb.png). which is usual
Way of determaning if this is really a bug or not is to launch a new world and see if the problem remains or if it ocoures only on your older worlds.

The screenshots were taken in a world that were generated after the recent world generator changes (in fact in the latest versions, 1.7.5 or 14w11b). The cuts in those tunnels are only in the tunnel, and the terrain above those areas is completely ok/normal. Do note that I have actually dug this issue down into the source code level, and I've also debugged some of the actual chunk-error issues, so I do take care with trying to ensure I do not accidentally mix other issues to be the cause.
However, by now and in this case it is impossible to be 100% certain that no other cave/tunnel generation bug is doing those just by looking at the symptoms. In fact, to be certain, I'd need to do about 2 days of coding work (and have MCP for either 1.7.5 or 14w11b). I've done it once, but not going to do again, when fixing this would take about few minutes from Mojang. However, the odds are good enough on the side that Mojang hasn't fixed the code I've shown in the report, so I added the versions to affected list on the basis of those cuts I found. (There are more similar cave/tunnel cuts in the same seed and overall area, those just were first ones clear enough to take screenshots of.)
(EDIT: clarification, it takes few hours to make a new decompile and check the code whether it is fixed or not, but it takes that couple days of work to ensure that the exact piece of code is indeed responsible for the particular cuts. This is because the random number generator used needs to be switched to a tweaked one, or otherwise the cave/tunnel generation will change in general and makes confirmation impossible. If I could find my older version of this, I could do it faster... but its been almost 3 years, so finding the archived codes might take that saved time 😛 )

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. If this has been done, we can reopen the issue.
Keep in mind that the "Resolved"-Status on this ticket just means "Answered", and that we are waiting for further information on whether this issue still exists or not. It will be reopened as soon as the requested information has been delivered.

If this is indeed the cause of several cut ravines and caves as well, then this does still exist in 1.14.4 van. on Win10/i7/16GB
Example:
Demo seed "North Carolina" or -343522682, F3-n, F3-g
/tp @s -48.42 18.94 0.10 -463.95 55.80

Can someone please check, if this still applies to 1.15.2 or the latest 1.16 development snapshot (currently that is 20w07a)?

Confirming code analysis on 20w07a. Obviously things are structured slightly differently today, but the check works the same way.

MC-167213 - related bug (water caves don’t generate through land biomes)
Can confirm in 21w14a.


The 1479112774635546442 examples had at least one case in orientation and distance from water that makes it unlikely to be caused of the water related bugs.
However, it seems that in 1.17 those seed examples are no longer valid or the bug has been fixed. One example cave/something in the above seed has completely vanished...
At least something related to cave carving has been fixed. Trying to check what exactly.

In the latest snapshot, I could not find the cuts described in the post. Is this still an issue?

I have been trying to find more examples of this particular bug (not near water), and I have only found so few "cuts" that they may very well be just random chance of cave shape matching chunk border, and nothing as obvious as they used to be.
Of course, the final confirmation is to look at the code, if it still has similar optimization; if it still subtracts squared distances or not...
In any case, this is no longer affecting the playing experience the way it used to. (At this point, I would not cry about resolving this as "fixed".)

The straight walls at chunk borders were last generated in version 21w17a. The next 21w18a produced current nicer caves.