Vanessa's plants/biome library

This library's purpose is to allow other mods to add growing things to the map in a straightforward, simple manner. It contains all the core functions needed by mods and modpacks such as More Trees, Tiny Trees, Plantlife, and others.

Spawning of plants is optionally sensitive to the amount of available light, elevation, nearness to other nodes, plant-to-plant density, water depth, and a whole host of controls.

All objects spawned or generated using this mod use Perlin noise to stay within simple biomes, rather than just letting everything just spread around the map randomly.

This library also features a basic temperature map, which should blend in nicely with SPlizard's Snow Biomes mod (the same Perlin settings are used, with the assumption that the edge of a snow biome is 0° Centigrade).

Both mapgen-based spawning and ABM-based spawning is supported. The active growing code is strictly ABM-based. L-system trees can be spawned at mapgen time via the engine's spawn_tree() function.

It is aimed primarily at mapgen v6, and does not use the biome capabilities supplied by mapgen v7 (that will change some day). As such, if used in a mapgen v7 world, it'll work just fine but the temperature and humidity maps will not match up the way you might expect.

On server-exit, biome_lib will "hang" the server for a bit so that it can play out the rest of its deferred-generation log. This process may take a couple of minutes, and is done to prevent areas being left under-populated.

This mod was formerly known as "plants_lib" and used to be included in the Plantlife Modpack.

Yeah, you can leave it be for now, until you decide you need to update something that depends on the change. In that case you will remove the entire plantlife modpack, download the latest git of it, and add biome_lib as a separate mod.

I have been trying to figure out some way of properly integrating biome_lib with v5 / v7 mapgen. Unfortunately they use different kinds of perlin noise and I can't see any way of directly retrieving temperature / humidity for a specific node. Ultimately this means I will have to deprecate biome_lib.register_generate_plant() in favour of minetest.register_decoration() and put up with the lack of subtlety. Having jungletrees and oranges spawn next to snow / tundra biomes isn't making me happy.

afflatus wrote:I have been trying to figure out some way of properly integrating biome_lib with v5 / v7 mapgen. Unfortunately they use different kinds of perlin noise and I can't see any way of directly retrieving temperature / humidity for a specific node.

You can just use the heat and humidity maps. You access those the same way you would a 2D noise array.

duane wrote:You can just use the heat and humidity maps. You access those the same way you would a 2D noise array.

Surely only inside an on_generate() callback?

I can't immediately see how to pass the maps to biome_lib.perlin_temperature and biome_lib.perlin_humidity. minetest.setting_get("mg_biome_np_heat") or ("mg_biome_np_humidity") returns a noise param string, which seems more useful, but would need parsing and converting - PerlinNoise takes four args: (seed, octaves, persistence, scale), so one of the big questions is how to get the spread / scale right.

Also the noise values need to be * -1 IIUC because mapgen and biome_lib use inverse values.

I am struggling because I don't have a deep enough understanding of Perlin noise, or the mechanics of map generation. So far I have managed to come up with a hacky workaround by trial and error which produces acceptable results. Any help in getting biome_lib and mapgen to sing from the same songsheet is gratefully received!

Edit: should I be looking at the points where noise1 and noise2 are defined?

OK, I don't want to duplicate the noise, I want to read the actual parameters, because as you rightly say, as soon as someone changes the mapgen params it will break. I doubt it is really necessary to include the *_blend noise. So long as the spread of values over the map roughly correlates to the biomes, this will work.

I also think the values fed to temp and humidity in your example would need to be * -1 as biome_lib, like splizzard's snow mod uses inverse values. That is unless you can use negative values for 'scale'.

So I think I just need to bite the bullet and figure out a way of unpacking the values from the noise params string returned by this:

Mapgen testing is very slow and laborious, if anyone else fancies testing this out on a new map (especially mgv6) with default settings running a fairly vanilla Minetest Game (with plantlife / moretrees natch), I'd be really interested in some feedback. :-)

I haven't been working on this mod lately, but I'm open to reasonable pull requests. It DOES work fine on mapgen v7, it just doesn't take advantage of any mgv7-specific features or climate/biome info. There is the issue of moretrees causing shadows on the map, but that's an engine bug.