I did an experiment to see just how the "spawn size" slider for ores affects the actual vein size, since I've known that the size is NOT a linear function of this setting, as seen by the relative abundances of coal and iron, the former of which is more common despite having half the vein density (20 veins of each but coal has twice the range), which would appear to be just offset by a larger vein size (twice as big for coal per the numbers), not made more common (about 2/3 more common below sea level; for example, see this chart). Here is a table I made of the "spawn size", actual vein size, and percentage of "spawn size" across 529 chunks (excludes outermost chunks (only partially populated) around a new world, 400x400/25x25 chunks in size), made by analyzing worlds (same seed) with only one ore and no other ores, caves, or ravines, with the min/max set to 10/50 so bedrock and near surface dirt don't affect the averages. The default size for pre-1.8 were taken from the source code while the default sizes for 1.8 are from the customized world default settings, which match with a default non-customized world when analyzed in MCEdit:
Besides a very obvious nonlinear relationship between the "spawn size" and actual vein size, another finding is that setting the size to less than 3 results in no ore being generated. Also, the maximum vein size can be larger than the size set even for smaller veins; it is very rare but possible to have lapis veins with as many as 10 ore even before 1.8 (I found one before while caving, it was clearly one vein, a 2x2x2 cube with two extra bits at opposite corners on the top and bottom, a common configuration), with a "spawn size" of 6 and average size of about 4, which, along with the findings above, flat-out contradicts what the Wiki claims:
Spawn Size: The maximum number of blocks in a single vein.
You can also see why coal is more common than iron, with an average vein size that is more than three times bigger, and even larger than the "spawn size" set, matching my findings from analyzing a normal world and what I find in-game (which is also biased by the fact that coal veins are bigger and more likely to be hit when mining or be exposed in a cave, resulting in 2.5-3 times more coal being found relative to iron, despite the lower density).
Also, note that in a real world there is considerably less of some ores, such as diamond, because they can only replace stone; a lot of diamond ore is lost in bedrock, as I've seen when comparing default and Superflat worlds, plus anything else (caves, other ores), that generate beforehand; similarly, a lot of coal attempts to generate above sea level. Plus, since ore veins only generate down from their maximum height (actually, one less because of how the random number generator works, so diamond ore is normally found up to y=15, not 16) veins that generate at y=0 never generate any ore unless you make a Superflat world without bedrock at that layer.
As for an explanation of this behavior, and possibly why the Wiki claims that the "spawn size" is the maximum number of blocks in a vein, a look at the code (WorldGenMinable) shows that there are four loops; the outermost one goes from 0 to the "spawn size" (which means when it is 10 the loop actually iterates 11 times), which might seem to only generate that many blocks, but there are three more nested loops (four total) which appear to iterate over x-y-z dimensions, using randomized start/stop values, to generate a cubical region of blocks (blocks actually placed depend on a noise value being less than one), multiple regions of which overlap.
Incidentally, some of those "spawn size 50" veins had as many as 600 ore in a single vein - a dozen times larger than the "maximum" size they supposedly have! Here's an amazing sight, after removing stone with the maximum vein size; it is also interesting that the veins all seem to be elongated in various directions in the x/z directions but not in the y direction:
Also of note, I was able to significantly optimize the code (for a 1.6.4 mod, not 1.8) myself by making the outermost loop increment in steps of two instead of one for larger veins, with a minor (about 10-15%) reduction in average vein size for dirt/gravel/stones (an even more significant improvement occurred when I had the stones only change metadata instead of the whole block, possible because they have the same ID as stone - world generation time was nearly halved when generating 10 times the normal number of veins, amounting to a couple seconds less at normal rates).
Wow this is very interesting. What mod did you use to see all those diamond veins?
I used MCEdit to delete all stone (I only had diamond ore generate so as to not influence results) and a Night Vision potion (you can also see water pouring down from sand collapsing). And yes, MCEdit still works with 1.8 despite the changes as the save files still use numeric IDs for blocks, exactly the same IDs as always (so why were item IDs in the save changed, causing all sorts of trouble? Presumably items still have numeric IDs somewhere since the game uses arrays to hold them; array index 1 = "stone", index 2 = "grass", etc).
Also, I thought to note that you can actually set the "min" height to be higher than the "max" height, which will generate ore in a single layer at the "min" height (extending across several layers); the game doesn't try to prevent you from doing this.
Thanks I was just about to start running this test for myself. We were making a customized survival world that generated significantly different than normal worlds (doubled underground size, ores much rarer but larger, gems a little more common but much smaller vein sizes). For some reason we were getting no generation at small vein sizes, now I know why! Is that because of the variance then? It rounds down to zero too often? I'm surprised it generated none at all for 1&2. I guess we'll pick size 3 then as our min.
Rollback Post to RevisionRollBack
Download and play my new Survival Map!
Space Expedition to EPIC 204:Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!