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

Liquids: Flow into and destroy 'floodable' nodes #3501

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
3 participants
@paramat
Copy link
Member

paramat commented Dec 30, 2015

" Liquids: Flow into and destroy 'floodable' nodes
Add new node property 'floodable', default false
Define "air" as floodable = true in C++ and lua"

Derived from PilzAdam's work here PilzAdam@327ed9e
I am enabling core mapgens to place airlike nodes as custom atmosphere or vacuum, liquids need to be able to flow into these and destroy them. This will enable space subgames to use current or future core mapgens to create terrain.
See discussion #828 and #47

Also some code optimisation by adding:

ContentFeatures cf = nodemgr->get(n0);

ContentFeatures cfnb = nodemgr->get(nb.n);

And using 'cf' and 'cfnb' instead of multiple uses of:

nodemgr->get()

No drops for simplicity and speed, and because it's not much needed, this is meant to be similar to 'buildable to' in that the node is destroyed when liquid is 'built to' it.
Drops could be coded later i guess.
This commit is mainly about allowing liquids to flow into 'airlike' nodes, stuff you don't want dropped.

@paramat paramat force-pushed the paramat:waterairlike branch 2 times, most recently Dec 30, 2015

@paramat paramat changed the title Liquids: Flush non walkable and buildable_to nodes away Liquids: Flow into and destroy airlike drawtype nodes Dec 31, 2015

@paramat paramat force-pushed the paramat:waterairlike branch 2 times, most recently Dec 31, 2015

@paramat paramat removed the WIP label Dec 31, 2015

@paramat paramat force-pushed the paramat:waterairlike branch Dec 31, 2015

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Dec 31, 2015

core.register_node(":ignore", {
    description = "Ignore (you hacker you!)",
    inventory_image = "unknown_node.png",
    wield_image = "unknown_node.png",
    drawtype = "airlike",
    paramtype = "none",
    sunlight_propagates = false,
    walkable = false,
    pointable = false,
    diggable = false,
    buildable_to = true, -- A way to remove accidentally placed ignores
    air_equivalent = true,
    drop = "",
    groups = {not_in_creative_inventory=1},
})

So it turns out we can't use 'airlike' or 'walkable' or 'buildable to' to decide whether a node can be flushed away by water because "ignore" would be flushed away. It seems necessary to have a new node property 'floodable', and faster because only 1 parameter to check.

@paramat paramat added the WIP label Dec 31, 2015

@paramat paramat force-pushed the paramat:waterairlike branch Dec 31, 2015

@paramat paramat changed the title Liquids: Flow into and destroy airlike drawtype nodes Liquids: Flow into and destroy 'floodable' nodes Dec 31, 2015

@paramat paramat force-pushed the paramat:waterairlike branch 2 times, most recently Dec 31, 2015

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 1, 2016

Confirmed we can't use 'airlike' or 'walkable' or 'buildable to' to decide whether a node can be flooded, trenches appear in lakes at mapchunk edges where water has penetrated the 'ignore' of neighbour ungenerated mapchunks, it also causes crashes. So as suggested in issue 47 a new node property is needed.

@paramat paramat force-pushed the paramat:waterairlike branch 2 times, most recently Jan 1, 2016

@paramat paramat removed the WIP label Jan 1, 2016

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 1, 2016

Now works and docs updated, ready for review.

@sofar

This comment has been minimized.

Copy link
Member

sofar commented Jan 1, 2016

I don't see this drop nodes as itemstack, which may be desirable for torches, grasses, etc.. Can that be added?

Lava should destroy the items, but water should not.

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 1, 2016

No drops for simplicity and speed, and because it's not much needed, this is meant to be similar to 'buildable to' in that the node is destroyed when liquid is 'built to' it.
Drops could be coded later i guess.
This commit is mainly about allowing liquids to flow into 'airlike' nodes, stuff you don't want dropped.

@sofar

This comment has been minimized.

Copy link
Member

sofar commented Jan 1, 2016

I see, that's fine by me of course.

@kwolekr

This comment has been minimized.

Copy link
Contributor

kwolekr commented Jan 2, 2016

I think you're missing floodable = true in the CONTENT_AIR definitions.

@paramat paramat force-pushed the paramat:waterairlike branch Jan 3, 2016

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 3, 2016

kwolekr, done.
Will add documentation at last moment to avoid conflicts in lua_api.txt. Docs will be:
floodable = false, -- If true, liquids flow into and replace this node

@paramat paramat force-pushed the paramat:waterairlike branch Jan 3, 2016

@paramat paramat added the WIP label Jan 5, 2016

@paramat paramat changed the title Liquids: Flow into and destroy 'floodable' nodes Liquids: Flow into and destroy 'floodable' nodes WIP Jan 5, 2016

@paramat paramat force-pushed the paramat:waterairlike branch Jan 5, 2016

@paramat paramat removed the WIP label Jan 7, 2016

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 7, 2016

Now i have studied the liquid flow code and have a basic understanding i'm fairly confident this implementation is correct. I spotted an error in PilzAdam's code and corrected it.
Ready for review / approval, then i'll add the docs stated above last moment.

@paramat paramat changed the title Liquids: Flow into and destroy 'floodable' nodes WIP Liquids: Flow into and destroy 'floodable' nodes Jan 7, 2016

@sofar

This comment has been minimized.

Copy link
Member

sofar commented Jan 7, 2016

Tested that this doesn't create any weird things in a normal landscape and it seems to behave normal. May not be so much of value for the actual intent, but at least I couldn't find it break anything.

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 7, 2016

@paramat paramat force-pushed the paramat:waterairlike branch Jan 7, 2016

Liquids: Flow into and destroy 'floodable' nodes
Add new node property 'floodable', default false
Define "air" as floodable = true in C++ and lua

@paramat paramat force-pushed the paramat:waterairlike branch to c0c4a5c Jan 7, 2016

@paramat

This comment has been minimized.

Copy link
Member Author

paramat commented Jan 7, 2016

@paramat paramat closed this Jan 7, 2016

@paramat paramat deleted the paramat:waterairlike branch Jan 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.