mojira.dev
MC-185925

Casting issue: Mineral vein generation uses 32-bit floats, leading to precision loss and potential crashes

Note to anyone creating a snapshot video: the fact that these ore veins repeat is not the bug being reported here. Refer to the screenshots below, specifically the late ones which are divided into quadrants - as you can see, the exact same ore vein ends up looking different when generated in one quadrant than when it is in another. You can see even more extreme precision loss in other screenshots, where the ore veins cluster into visible squares, which eventually happens on all worlds regardless of seed due to this bug. This bug is not dependent on seed! The only reason why the seed in question was used was to show how the exact same ore vein can differ depending on where it generates, this latter thing being the bug this ticket is referring to.

A further explanation as to why this happened, as well as other similar such bugs, can be found on the following wiki page: https://minecraft.gamepedia.com/Distance_effects_in_Java_Edition

The 1.15.2 mod used to demonstrate extreme versions of this effect can be found here (make sure to turn Far Lands generation off in the /farlands command's menu, and do not load any chunks between 67108864 and 134217728): https://www.curseforge.com/minecraft/mc-mods/farlands


Unlike most population features, the generation of mineral lodes uses 32-bit floats for block positions. This causes ore seams in the world to generate in a slightly distorted fashion within the world at high distances, which is very insignificant. However, if the world generation is extended out past 30 million blocks using a mod, this issue can escalate, even causing the world to crash if attempting to load chunks between 67108864 and 134217728 blocks, due to ore veins being positioned in adjacent chunks resulting in runaway chunk loading.

It is possible to clearly reproduce this precision loss within vanilla bounds using the following seed:

102496288339226

which causes ore veins to repeat diagonally (due to a different mechanic), allowing us to compare the exact same ore vein as it would be generated at different positions. (Please don't fix this, though! Focus on the ore precision loss bug.) Couple this with the superflat preset

minecraft:bedrock,2*minecraft:stone;minecraft:mountains;decoration

to get a two thick layer of stone for ores to generate in. (As this functionality was removed in 20w21a, a reasonable alternative would be to just use a normal world with the /fill command to flatten and expose stone, such that the mineral vein generation becomes visible.)

After 16,777,216 blocks, a clear cutoff can be seen where the ore veins start to generate in incorrect, blockier shapes (on the 085151 screenshot, 16777216 on both axes is to the top left).

Further info can be found here: https://www.reddit.com/r/Minecraft/comments/9u9d4i/floats_minecraft_and_the_far_lands/

Emerald ore generation is unaffected by this bug.

Linked issues

Attachments

Comments

MMK21

I doubt this will be fixed, but I guess we can hope...

muzikbike

Can confirm for 20w22a using the fill command but is much harder to notice.

muzikbike

Also some demonstrations of how extreme the effect can get when outside of vanilla's 30 million block limit (probably not useful due to not exactly being a vanilla effect, but still may be worth noting):

[media]

[media]

[media]

[media]

[media]

[media]

user-a4a49

Confirmed in 1.16 Pre-release 8.

muzikbike

Fix confirmed.

muzikbike

Erik Broes

Confirmed

(Unassigned)

precision-loss

1.15.2, 20w22a, 1.16 Pre-release 1, 1.16 Pre-release 2, 1.16 Pre-release 8

20w28a

Retrieved