generate ore only below specific biomes

Post Reply
User avatar
uwu666
Member
Posts: 45
Joined: Mon May 04, 2020 05:20
Location: Latinoamerica

generate ore only below specific biomes

by uwu666 » Post

is there a way to register ore generation below a specific biome?
for example if i want iron i need to go to the desert biome and find a cave or dig there.
cdb_71b6f99a808c

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: generate ore only below specific biomes

by Festus1965 » Post

yes,
as if the map generator would have to generate new mapblocks down,

first it might have to check the highest open nodes before air about that biome (as of some nodes sure telling it ? dirt with ? or sand ...) and
could then create down as wished ...

but what if the surface is not created yet ?
force double mapgen, as first need to create surface,
and then depending on surface biome, continue create the down area a gamer is forcing to exist ?
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: generate ore only below specific biomes

by Blockhead » Post

Ignore Festus1965's comment*. Yes, you can write a VoxelManip implementation, but that would be really, really slow by comparison. Minetest has this kind of functionality built in via the biome system.

What you want to do is make a mod where you remove most of the ore definitions from the base game and add them back but biome-specific. One option for ore definitions in Minetest is to specify the biomes where the ore spawning will occur: ref.

So, in Minetest Game, every biome actually has three associated biomes: the base one, which goes from y=31k down to around sea level; the ocean version, which goes down to about y=-255, and then the underground one which goes all the way to the bottom at -31k.

So you will have to decide if below a certain depth all the ores should be the same, or if it's all the way to the bottom that you can only find stuff. I would probably do the former, but it's up to you. So you can register the specific ores to the top and ocean biomes, and then register all of the ores to spawn in all of the underground biomes, or just register the specific ones even down deep underground. I f you wanted a different cut-off point for the all-the-ores area to start, you could unregister the underground biomes, then re-register them but with a y_min that is higher up, then register a 'deep underground' biome that goes from that y_min down to -31k.

You should read the definition of default.register_biomes() in minetest_game/mods/default/mapgen.lua (online for 5.6.1 here). You will need unregister those biomes, then run your modified version of the ore definitions from the same file (default.register_ores)

*edited with nicer wording
Last edited by Blockhead on Wed Nov 30, 2022 05:50, edited 1 time in total.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: generate ore only below specific biomes

by Festus1965 » Post

Blockhead wrote:
Wed Nov 30, 2022 03:25
Ignore Festus.
better would have been Ignore Festus1965 comment ... but as you are.
uwu666 wrote:
Tue Nov 29, 2022 22:13
is there a way to register ore generation below a specific biome?
for example if i want iron i need to go to the desert biome and find a cave or dig there.
and I think you (Blockhead) misunderstood him.

I think it is like this :
* under desert biome underground area (dept NOT defind by his request) might only be copper
* but maybe under stone/gras find iron,
* and under swamp maybe get coal
only or most ... depending on the surface biome, you will find underground only specific minerals
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: generate ore only below specific biomes

by Blockhead » Post

Festus1965 wrote: I think it is like this :
* under desert biome underground area (dept NOT defind by his request) might only be copper
* but maybe under stone/gras find iron,
* and under swamp maybe get coal
only or most ... depending on the surface biome, you will find underground only specific minerals
That is what I am trying to help with. The best way is to use the biomes API like I explained, not a map generation callback.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: generate ore only below specific biomes

by Festus1965 » Post

Blockhead wrote:
Wed Nov 30, 2022 05:54
That is what I am trying to help with. The best way is to use the biomes API like I explained, not a map generation callback.
then tell me, what biome it is, when the surface is not generated yet ?
You need to have a surface biome first, before you can generate more down otherwise biome up = nil

If the generating depends on a quick check up there (surface) or make it generally new is fine works.
The answer first on his/her question is yes ...
but depending on the actual mapgen as you told in this areas or whatever,
they can only act with the right mix of minerals when they have an surface biome.

How it is implementation is not my problem at first.
But the question clear intends that you need a ready surface that you can chose the minerals.
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: generate ore only below specific biomes

by Blockhead » Post

Festus1965 wrote:
Wed Nov 30, 2022 06:58
Blockhead wrote:
Wed Nov 30, 2022 05:54
That is what I am trying to help with. The best way is to use the biomes API like I explained, not a map generation callback.
then tell me, what biome it is, when the surface is not generated yet ?
You need to have a surface biome first, before you can generate more down otherwise biome up = nil
You can tell what biome a co-ordinate is is the same way the game can tell what biome it is, which is a result of the humidity and temperature of the voxel which is a Perlin noise sample, and does not require the area to be generated. The API docs are here. This is useful if you wanted to register a function with minetest.register_on_generated and place the ores manually. This is not something you need to do, because Minetest engine will place the ores itself. You just need to register the ores to the biome, like I outlined. Look, I know you want to be helpful, but it seems clear you have never written mapgen code, so while I appreciate your ideas about "this is how I think it could be done", it's not as helpful as knowing how to actually do it.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: generate ore only below specific biomes

by Festus1965 » Post

moment, your telling me that every mapblock down to -31K it is already clear what biome it is / belong or will be on the surface (near 0) area ? even it was not generated yet ?
I thought a map is generated mostly random ? and so a 1.000 nodes deep and 1.000 far mapblock from any ready generated surface might not have any idea (knowledge or data) what will be up over 'it' in the future.
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: generate ore only below specific biomes

by Blockhead » Post

Festus1965 wrote:
Wed Nov 30, 2022 11:16
moment, your telling me that every mapblock down to -31K it is already clear what biome it is / belong or will be on the surface (near 0) area ? even it was not generated yet ?
Minetest biomes are determined by height, heat and humidity. Heat and humidity are 2D (x,z) perlin noises. The height is based on the output of many other perlin noises. For each co-ordinate, the basic calculation you have to do to work out its biome is:
  1. Sample the heat noise perlin at that (x,z) co-ordinate
  2. Sample the humidity noise perlin at that (x,z) co-cordinate.
  3. Check the y-coordinate for biomes and eliminate all the biomes that are too high/low
  4. Find the nearest biome on the Voronoi diagram of biomes. Each biome is a 2D point (heat, humidity) on the diagram.
Perlin Noise is easy to sample at any point in 2D/3D. It uses a seed and some other parameters; look at Noise Parameters information in lua_api.txt The terrain generator will sample many noises to choose what node to place. But to simply work out what biome there is, it is not necessary to do the full terrain calculation. So yes, you can work out the biome for areas that aren't generated.
Festus1965 wrote:
Wed Nov 30, 2022 11:16
I thought a map is generated mostly random ?
A map is generated in a pseudo-random but reliable way. The same seed always generates the same world (or nearly, place of trees is usually an exception). It is all based on pseudo-random number generator takes that take the world seed and produce other outputs. For the terrain it takes the world seed and the perlin noise seed(s) of the terrain noises and adds them together. For just the biome, it is just two perlin noises like I said.
Festus1965 wrote:
Wed Nov 30, 2022 11:16
and so a 1.000 nodes deep and 1.000 far mapblock from any ready generated surface might not have any idea (knowledge or data) what will be up over 'it' in the future.
What is above something is not relevant to the biome calculation. I explained the biome calculation previously. All of what I said applies to the Minetest in-built biome API with no special features like altitude chill which is a feature of Valleys mapgen where higher y co-ordinates are cooler. This is applied on top of the original heat calculation. Each map generator provides a way to sample the heat and humidity it produces, so that Lua and C++ can use those, not just the final terrain. So yes, even in non-generated areas you can tell what the biomes will be.

But all of this is a diversion from what's important, because the ore placement depends on more than just the biome. Ores have to be placed inside other nodes like stone as well, and the bit of code that places ores asks the biome API for the biome information and checks for nodes that are already there before placing inside of them. I hope you understand why OP should use the Biome API now.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: generate ore only below specific biomes

by Festus1965 » Post

thanks
so that explains why during my real long run through maps, I so often find similar even same shapes ... I thought it was my own mistake memory ...
so I feel even better now

and see that the task ask here is more easy possible that thought
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
uwu666
Member
Posts: 45
Joined: Mon May 04, 2020 05:20
Location: Latinoamerica

Re: generate ore only below specific biomes

by uwu666 » Post

Blockhead wrote:
Wed Nov 30, 2022 03:25
Ignore Festus1965's comment*. Yes, you can write a VoxelManip implementation, but that would be really, really slow by comparison. Minetest has this kind of functionality built in via the biome system.

What you want to do is make a mod where you remove most of the ore definitions from the base game and add them back but biome-specific. One option for ore definitions in Minetest is to specify the biomes where the ore spawning will occur: ref.

So, in Minetest Game, every biome actually has three associated biomes: the base one, which goes from y=31k down to around sea level; the ocean version, which goes down to about y=-255, and then the underground one which goes all the way to the bottom at -31k.

So you will have to decide if below a certain depth all the ores should be the same, or if it's all the way to the bottom that you can only find stuff. I would probably do the former, but it's up to you. So you can register the specific ores to the top and ocean biomes, and then register all of the ores to spawn in all of the underground biomes, or just register the specific ones even down deep underground. I f you wanted a different cut-off point for the all-the-ores area to start, you could unregister the underground biomes, then re-register them but with a y_min that is higher up, then register a 'deep underground' biome that goes from that y_min down to -31k.

You should read the definition of default.register_biomes() in minetest_game/mods/default/mapgen.lua (online for 5.6.1 here). You will need unregister those biomes, then run your modified version of the ore definitions from the same file (default.register_ores)

*edited with nicer wording
thanks, this should work! :)
cdb_71b6f99a808c

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests