[DONE] Upcoming feature: Decoupling of liquid features

Post Reply
User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

[DONE] Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

In the next version (probably 5.5.0), there will (hopefully) be some small but useful improvements to how liquids work. The work on it is not completely finished yet, but I hope they will all appear in the next version.

Currently (5.4.1), liquids combine various features into one: First, liquids have mostly the same visual shape. Also, all liquids require a source and a flowing node. Also, liquids have flowing physics. Finally, a liquid also always means you can swim in it. This means you can move up/down with the Jump and Sneak keys.

All of these features are coupled together and cannot be separated easily. Liquids were basically an all-or-nothing deal. I decided it will be useful to decouple everything into distinct and independent features. With the new changes, every block can now independently define:
  • Liquid drawtype (visual appearance)
  • Liquid viscosity (how fast the liquid flows)
  • Liquid physics yes/no (whether players can "swim" in the block)
  • Move resistance (how fast players move through the block)
Each of those features will be independent from each other, unlike in previous versions where it all was strongly coupled. This allows more flexibility for mods and games.

This opens various neat use cases:
  • Cobwebs (without ugly hackery, all cobwebs from games and mods are technically liquids)
  • Force fields (you move through slowly)
  • Liquid nitrogen (flows and looks like a liquid, but you walk though it like air)
  • Liquids that flow fast but can be moved through slowly
  • Liquids that flow slowly but can be moved through fast
  • "Decorative" liquids that don't do anything
Enjoy!

EDIT: Actually, the liquid drawtypes are already decoupled from liquidtype since 5.4.0. How time flies …
Last edited by Wuzzy on Sat Apr 09, 2022 13:54, edited 2 times in total.

User avatar
Gael de Sailly
Member
Posts: 845
Joined: Sun Jan 26, 2014 17:01
GitHub: gaelysam
IRC: Gael-de-Sailly
In-game: Gael-de-Sailly gaelysam
Location: Voiron, France

Re: Upcoming feature: Decoupling of liquid features

by Gael de Sailly » Post

Cool! That will be useful to create new items, hope it gets merged!
The first thing I'm thinking about is leaves that can be passed through with reduced speed
Just realize how bored we would be if the world was perfect.

User avatar
j0j0n4th4n
Member
Posts: 249
Joined: Tue Jan 26, 2021 06:45

Re: Upcoming feature: Decoupling of liquid features

by j0j0n4th4n » Post

This is a very useful feature =)
By the way, those changes would work on items and mobs too?
cdb_894a100ddd76

User avatar
Linuxdirk
Member
Posts: 3217
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Linuxdirk » Post

This sounds great! I instantly have some creative ideas in mind for that!
Wuzzy wrote:
Mon Sep 20, 2021 19:49
Liquid drawtype (visual appearance)
Liquid viscosity (how fast the liquid flows)
Liquid physics yes/no (whether players can "swim" in the block)
I hope those are not called liquid_* in the node attributes but be more generic. Even though everything that is not a dislocation-free material physically is a liquid (fluid, but hey *g*), configuring a cobweb with liquid-parameters feels wrong :)

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

That's the neat part. For new cobwebs, you only need move_resistance and no liquid* field at all.
Current hacky cobwebs awkwardly set many liquid* fields because this is the only current way to reduce your movement speed. Here's the Mobs Redo cobweb:

Code: Select all

-- cobweb
minetest.register_node(":mobs:cobweb", {
	description = S("Cobweb"),
	drawtype = "plantlike",
	visual_scale = 1.2,
	tiles = {"mobs_cobweb.png"},
	inventory_image = "mobs_cobweb.png",
	paramtype = "light",
	sunlight_propagates = true,
	liquid_viscosity = 11,
	liquidtype = "source",
	liquid_alternative_flowing = "mobs:cobweb",
	liquid_alternative_source = "mobs:cobweb",
	liquid_renewable = false,
	liquid_range = 0,
	walkable = false,
	groups = {snappy = 1, disable_jump = 1},
	drop = "farming:string",
	sounds = default.node_sound_leaves_defaults(),
})
You know, it's pretty ugly. Also note disable_jump = 1, which disallows "swimming" upwards in the "liquid" cobweb.

But you can remove all liquid* fields and replace liquid_viscosity with move_resistance. The disable_jump group can also be removed if you want because you can't swim upwards anyway, and move_resistance also affects the jump height.
Note that move_resistance reduces your movement speed in ALL directions, which is exactly what we want.

It could thus be simplified to:

Code: Select all

-- cobweb
minetest.register_node(":mobs:cobweb", {
	description = S("Cobweb"),
	drawtype = "plantlike",
	visual_scale = 1.2,
	tiles = {"mobs_cobweb.png"},
	inventory_image = "mobs_cobweb.png",
	paramtype = "light",
	sunlight_propagates = true,
	move_resistance = 11,
	walkable = false,
	groups = {snappy = 1},
	drop = "farming:string",
	sounds = default.node_sound_leaves_defaults(),
})

Astrobe
Member
Posts: 570
Joined: Sun Apr 01, 2018 10:46

Re: Upcoming feature: Decoupling of liquid features

by Astrobe » Post

Good move! Would it be possible to allow "weird" values for move_resistance (negative or less than one, depends on the units), so that it can be used to speed up players?

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

That is currently unsupported. Speeding up the player is always something tricky due to anticheat an other things. I'm not saying it's impossible, just tricky.

A value of 0 has no effect at all.

Also, move_resistance only supports integer values from 0-7 to be equivalent to 5.4.1's liquid_viscosity. That's not a lot but might be extended later.

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: Upcoming feature: Decoupling of liquid features

by Hume2 » Post

Were you thinking about walkable liquids, so I can implement mercury or lava properly? Oil can be now implemented by not making the liquid swimmable but keeping its resistance. However, it's not possible to make it impossible to dive in on the other hand. It is possible to make it walkable but the collision box isn't set well for flowing nodes, they always occupy whole the node.
If you lack the reality, go on a trip or find a job.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

Oil can be now implemented by not making the liquid swimmable but keeping its resistance.
You can already do that by adding disable_jump=1 group to the node. You can't swim upwards then.

----

Yeah, I also had an idea of walkable liquids. This would require me to implement a new nodebox type for flowing liquids which automatically changes the nodebox depending on the flowing liquid shape. That's a little challenge since the code must be aware of the liquid neighborhood, etc. I was thinking to make the nodebox to be like stairs so they can be walked on effortlessly.
A workaround I discovered for flowing liquids is by using a fixed collisionbox that is equal to that of a slab. It's not perfect, but it's a good enough approximation for gameplay that works surprisingly well.

That having said, this thread actually has nothing to do with walkable liquids, it's a different idea.
However, it's not possible to make it impossible to dive in on the other hand.
One way is to make it wakable using the workaround from above. Another way is to add a group called "disable_descend" which disables the Sneak key (for sinking) for liquids and climbable nodes. I've written a PR for this: https://github.com/minetest/minetest/pull/11377
It is still waiting for review and approval.
But this is probably not enough, since even then you still automatically sink into the liquid. Probably that's an idea for the future.

Slightly related, I also have a PR that lets you modify more per-player move physics (besides walking, jumping and gravity) here: <https://github.com/minetest/minetest/pull/11465> This includes swimming.


-----
EDIT: Literally 1 minute after this post, the liquid viscosity split was merged! YES! FINALLY! :D :D :D

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

The saga continues!
After the successful decoupling of liquid viscosity, I have already written my next PR. This time, I looked at pointing.
Currently, buckets point at liquid nodes (with liquidtype~="none"). Meaning that buckets are always able to point at liquids. It is not possible to make a liquid node that can't be pointed at all, even buckets. So I've introduced a new property to allow to explicitly handle this.
As a side effect, this will also allow you to make nodes pointable by buckets if they are not liquids themselves. Could be useful for some kind of fake liquid, I guess, or liquids that are only liquids optically, but not physically.

Read the full PR here:
https://github.com/minetest/minetest/pull/11665

User avatar
Mantar
Member
Posts: 584
Joined: Thu Oct 05, 2017 18:46
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Mantar » Post

So you could use buckets to scoop up sand? Neat!
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile

User avatar
freshreplicant
Member
Posts: 224
Joined: Sun Aug 09, 2020 10:37
In-game: freshreplicant

Re: Upcoming feature: Decoupling of liquid features

by freshreplicant » Post

Mantar wrote:
Fri Oct 01, 2021 16:34
So you could use buckets to scoop up sand? Neat!
Nice idea.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

So you could use buckets to scoop up sand? Neat!
Well, that is already be possible and doesn't even require an engine change, just a mod change. Blocks that are pointable by default (like most solid blocks like sand) are also pointable by buckets. That has nothing to do with my changes.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: Upcoming feature: Decoupling of liquid features

by PolySaken » Post

currently, all liquids flow out the same distance. I propose some sort of liquid_radius field, to allow thicker fluids to propagate less easily. Maybe make the max radius the current value.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Mantar
Member
Posts: 584
Joined: Thu Oct 05, 2017 18:46
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Mantar » Post

Wuzzy wrote:
Fri Oct 01, 2021 20:01
Well, that is already be possible and doesn't even require an engine change, just a mod change. Blocks that are pointable by default (like most solid blocks like sand) are also pointable by buckets. That has nothing to do with my changes.
Ah. So I guess the reason I've never seen a Minetest game or mod use buckets for moving sand is "because Minecraft does it."
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile

talamh
Member
Posts: 156
Joined: Sun Nov 12, 2017 18:24

Re: Upcoming feature: Decoupling of liquid features

by talamh » Post

PolySaken wrote:
Sat Oct 02, 2021 10:04
currently, all liquids flow out the same distance. I propose some sort of liquid_radius field, to allow thicker fluids to propagate less easily. Maybe make the max radius the current value.
liquid_radius field sets the flow distance. In Mineclone nether lava liquid_radius = 7; lava liquid_radius = 3
Image

Astrobe
Member
Posts: 570
Joined: Sun Apr 01, 2018 10:46

Re: Upcoming feature: Decoupling of liquid features

by Astrobe » Post

Is it not what liquid_range (node property) does ?

talamh
Member
Posts: 156
Joined: Sun Nov 12, 2017 18:24

Re: Upcoming feature: Decoupling of liquid features

by talamh » Post

Astrobe wrote:
Sun Oct 03, 2021 09:38
Is it not what liquid_range (node property) does ?
I meant liquid_range, somehow managed to type the wrong thing 3 times.

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: Upcoming feature: Decoupling of liquid features

by Festus1965 » Post

Wuzzy wrote:
Mon Sep 20, 2021 19:49
In the next version (probably 5.5.0), there will (hopefully) be some small but useful improvements
...
Enjoy!
Is there a possible overview about how many existing mod will NOT work after that 'small but useful' ...
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

Well, we did extensive testing and it doesn't seem any mod will break.
Also, I made sure to do everything in a backwards-compatible manner. Backwards-compability is very important to me, as I'm a mod and game dev as well.


EDIT: Hmmm … Correction. CLIENT mods might break because I removed get_liquid_viscosity() to replace it with get_move_resistance(). So if any client mod used this function, it needs to update. We considered this to be acceptable because client modding is still officially experimental, so you have to expect breakage anyway.

But no normal mod should break.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Upcoming feature: Decoupling of liquid features

by runs » Post

Cool.

Do you have the approval of the hard wing developers? Make sure you do, if not, because they can throw all your work away in no time.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

What is already done and merged:
- disabling swimming upwards in liquids with disable_jump=1 (since a long time)
- liquidtype decoupled from liquid drawtype (since 5.4.0)
- move_resistance (player swimming physics) being separated from liquid_viscosity (liquid flowing physics) (since 5.5.0-dev)

What is awaiting approval:
- Decoupling liquids_pointable from liquidtype

User avatar
Casimir
Member
Posts: 1206
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Upcoming feature: Decoupling of liquid features

by Casimir » Post

This is great news. An important step towards volume conserving/falling/realistic liquids.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Upcoming feature: Decoupling of liquid features

by Wuzzy » Post

Update: My PR for decoupling liquids_pointable from liquidtype has been rejected. Rubenwardy wants a more generic approach (by using groups). So I leave it at that for now. The pointing stuff isn't as pressing for now, I just worked on it for completeness' sake.

But the previous updates to liquids (like move_resistance) still stand.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests