Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please document current status of is_ground_content and how to use it safely to place schematics (with it) in register_on_generated callbacks #11125

Open
kay27 opened this issue Mar 26, 2021 · 4 comments
Labels
@ Documentation Feature request Issues that request the addition or enhancement of a feature

Comments

@kay27
Copy link
Contributor

kay27 commented Mar 26, 2021

Problem

First of all, this option not seems to be documented well, currently Lua API contains the text which we can understand differently:

        is_ground_content = true,
        -- If false, the cave generator and dungeon generator will not carve
        -- through this node.
        -- Specifically, this stops mod-added nodes being removed by caves and
        -- dungeons when those generate in a neighbor mapchunk and extend out
        -- beyond the edge of that mapchunk.

If you perceive first sentence as self-consistent, next one means true value stops, which seems to be wrong and false should stop nodes being removed by caves.

Next problem is cavegen.cpp not only carves the blocks but fills nodes with liquids (I mentioned it in issue 8232 with an example), and possible stones - maybe would be nice to document it.

Of course it wouldn't be a problem if register_on_generated callbacks worked as expected. But according to this @paramat 's comment, we have 1 - (3*3*3/5/5/5) = 0.784 probability (extremely high) to meet this kind of problems by placing anything with is_ground_content flag. (3*3*3 is kinda protected cube from neighbor caves, in the middle of 5*5*5 chunk).

There is also a suggestion to use different nodes with correct drops. This suggestion has two problems for me currently:

  • using 'silk touch' game feature we expect to get whatever we dig, so when we dig basenode:sand_but_not_ground_content we must process it as a special case somehow to get just basenode:sand still;
  • air nodes seem to be ground content as well... Do I need a way to implement alternative air? (What...) Otherwise air replaces by liquid, liquid maybe by something else - if we were out of the luck to find ourselves in the corner of mapchunk which has 7 neighbour chunks, and each of them calls mapgen as well.

I stop here, though it's not all the problems but hope enough to get started.

Solutions

We need to document properly what is_ground_content flag does and especially what it does not. Are air, liquids, ignore ground content too or not (by design).
And work out a way to place schematics with ground content like sand, stone, water, lava, air, etc. during register_on_generated callback to let the schematic survive after neighbour chunks further generation.

Additional context

It is related to:

@kay27 kay27 added the Feature request Issues that request the addition or enhancement of a feature label Mar 26, 2021
@kay27 kay27 changed the title Please document currents status of is_ground_content and how to use it safely Please document current status of is_ground_content and how to use it safely Mar 26, 2021
@kay27 kay27 changed the title Please document current status of is_ground_content and how to use it safely Please document current status of is_ground_content and how to use it safely to place schematics (with it) in register_on_generated callbacks Mar 26, 2021
@kay27
Copy link
Contributor Author

kay27 commented Apr 17, 2021

This block should be solid by design, to clarify:
image

I'm updating issue https://git.minetest.land/MineClone2/MineClone2/issues/1395 during experiments.

Not sure if it is a good idea to require writing the same data into map blocks up to 8 times.

Maybe cavegen.cpp needs some node markers, like meta data, which would mean "don't change this node".

@kay27
Copy link
Contributor Author

kay27 commented Apr 28, 2021

Okay, I made Lua API to process every mapblock only once.
Now I need the same for mapchunks. Three problems:

  1. generation distance of 10 mapblocks not so good for that - our new structures appear just in front of the player, I need to increase the distance from 10 up to 13 blocks minimum;
  2. I need to keep chunk seed numbers somewhere, or recalculate them on my own (by the way, why chunk seed number named blockseed?);
  3. new algorithm itself. In short, when on_generated callback is fired for some chunk - we check all adjacent 26 chunks if they're generated with their neighbors entirely, and if yes - instantiate our own callback iterator, but there can't be used special mapgen objects. So we need to keep old callbacks for the objects where it's necessary, and add new callbacks where the first priority is keeping structures undamaged.

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Feb 21, 2023

So what specifically do you need? Is it just that the weird negation that is confusing? Do you want examples to be added (like what to do with air, ignore, stone)? Any other concrete questions?

I think the current way this is written seems correct to me tho, just weirdly worded.

@kay27
Copy link
Contributor Author

kay27 commented May 18, 2023

Hi @Wuzzy2 ! Thanks for paying attention.

So what specifically do you need?

As a developer, I need confidence that all the structures and nodes, be/contain they 'ground content' or not, after placing them in register_on_generated callback entirely appear in the world for players, regardless of cavegen algorithms for adjacent blocks.

For MCL2, maybe this story has started from disappearance of a stronghold: https://forum.minetest.net/viewtopic.php?p=381747#p381747 And I kind of found a fix - skip unfinished blocks until mapgen finishes them: https://git.minetest.land/MineClone5/MineClone5/src/branch/master/mods/CORE/mcl_mapgen/init.lua#L266 (we only lose possibility of using full-chunk mapgen objects.) It works fast and perfect, but for MCL2 people it seemed to be too complicated for accepting: https://git.minetest.land/MineClone2/MineClone2/pulls/1976 So I believe any progress from engine devs means a lot for all the schematics all over the worlds :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Documentation Feature request Issues that request the addition or enhancement of a feature
Projects
None yet
Development

No branches or pull requests

4 participants