mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Fix liquid falling if in "float" group (#13789)
* Make falling liquid source nodes replace flowing nodes This makes falling liquid source nodes in group:float replace flowing nodes on the ground instead of being placed above the flowing node. * Make flowing liquids "fall through" for source nodes This makes liquids in float and falling_node groups fall through flowing liquid nodes instead of being supported by them in the air. --------- Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com> Co-authored-by: Lars Mueller <appgurulars@gmx.de>
This commit is contained in:
parent
7901087466
commit
6c8ae2b72a
@ -79,6 +79,9 @@ core.register_entity(":__builtin:falling_node", {
|
|||||||
-- Cache whether we're supposed to float on water
|
-- Cache whether we're supposed to float on water
|
||||||
self.floats = core.get_item_group(node.name, "float") ~= 0
|
self.floats = core.get_item_group(node.name, "float") ~= 0
|
||||||
|
|
||||||
|
-- Save liquidtype for falling water
|
||||||
|
self.liquidtype = def.liquidtype
|
||||||
|
|
||||||
-- Set entity visuals
|
-- Set entity visuals
|
||||||
if def.drawtype == "torchlike" or def.drawtype == "signlike" then
|
if def.drawtype == "torchlike" or def.drawtype == "signlike" then
|
||||||
local textures
|
local textures
|
||||||
@ -294,9 +297,17 @@ core.register_entity(":__builtin:falling_node", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Decide if we're replacing the node or placing on top
|
-- Decide if we're replacing the node or placing on top
|
||||||
|
-- This condition is very similar to the check in core.check_single_for_falling(p)
|
||||||
local np = vector.copy(bcp)
|
local np = vector.copy(bcp)
|
||||||
if bcd and bcd.buildable_to and
|
if bcd and bcd.buildable_to
|
||||||
(not self.floats or bcd.liquidtype == "none") then
|
and -- Take "float" group into consideration:
|
||||||
|
(
|
||||||
|
-- Fall through non-liquids
|
||||||
|
not self.floats or bcd.liquidtype == "none" or
|
||||||
|
-- Only let sources fall through flowing liquids
|
||||||
|
(self.floats and self.liquidtype ~= "none" and bcd.liquidtype ~= "source")
|
||||||
|
) then
|
||||||
|
|
||||||
core.remove_node(bcp)
|
core.remove_node(bcp)
|
||||||
else
|
else
|
||||||
np.y = np.y + 1
|
np.y = np.y + 1
|
||||||
@ -307,7 +318,7 @@ core.register_entity(":__builtin:falling_node", {
|
|||||||
local nd = core.registered_nodes[n2.name]
|
local nd = core.registered_nodes[n2.name]
|
||||||
-- If it's not air or liquid, remove node and replace it with
|
-- If it's not air or liquid, remove node and replace it with
|
||||||
-- it's drops
|
-- it's drops
|
||||||
if n2.name ~= "air" and (not nd or nd.liquidtype == "none") then
|
if n2.name ~= "air" and (not nd or nd.liquidtype ~= "source") then
|
||||||
if nd and nd.buildable_to == false then
|
if nd and nd.buildable_to == false then
|
||||||
nd.on_dig(np, n2, nil)
|
nd.on_dig(np, n2, nil)
|
||||||
-- If it's still there, it might be protected
|
-- If it's still there, it might be protected
|
||||||
@ -555,11 +566,19 @@ function core.check_single_for_falling(p)
|
|||||||
local success, _ = convert_to_falling_node(p, n)
|
local success, _ = convert_to_falling_node(p, n)
|
||||||
return success
|
return success
|
||||||
end
|
end
|
||||||
|
local d_falling = core.registered_nodes[n.name]
|
||||||
|
local do_float = core.get_item_group(n.name, "float") > 0
|
||||||
-- Otherwise only if the bottom node is considered "fall through"
|
-- Otherwise only if the bottom node is considered "fall through"
|
||||||
if not same and
|
if not same and
|
||||||
(not d_bottom.walkable or d_bottom.buildable_to) and
|
(not d_bottom.walkable or d_bottom.buildable_to)
|
||||||
(core.get_item_group(n.name, "float") == 0 or
|
and -- Take "float" group into consideration:
|
||||||
d_bottom.liquidtype == "none") then
|
(
|
||||||
|
-- Fall through non-liquids
|
||||||
|
not do_float or d_bottom.liquidtype == "none" or
|
||||||
|
-- Only let sources fall through flowing liquids
|
||||||
|
(do_float and d_falling.liquidtype == "source" and d_bottom.liquidtype ~= "source")
|
||||||
|
) then
|
||||||
|
|
||||||
local success, _ = convert_to_falling_node(p, n)
|
local success, _ = convert_to_falling_node(p, n)
|
||||||
return success
|
return success
|
||||||
end
|
end
|
||||||
|
@ -2167,6 +2167,8 @@ to games.
|
|||||||
Negative damage values are discarded as no damage.
|
Negative damage values are discarded as no damage.
|
||||||
* `falling_node`: if there is no walkable block under the node it will fall
|
* `falling_node`: if there is no walkable block under the node it will fall
|
||||||
* `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
|
* `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
|
||||||
|
* A liquid source with `groups = {falling_node = 1, float = 1}`
|
||||||
|
will fall through flowing liquids.
|
||||||
* `level`: Can be used to give an additional sense of progression in the game.
|
* `level`: Can be used to give an additional sense of progression in the game.
|
||||||
* A larger level will cause e.g. a weapon of a lower level make much less
|
* A larger level will cause e.g. a weapon of a lower level make much less
|
||||||
damage, and get worn out much faster, or not be able to get drops
|
damage, and get worn out much faster, or not be able to get drops
|
||||||
|
@ -9,7 +9,7 @@ for d=0, 8 do
|
|||||||
end
|
end
|
||||||
minetest.register_node("testnodes:rliquid_"..d, {
|
minetest.register_node("testnodes:rliquid_"..d, {
|
||||||
description = "Test Liquid Source, Range "..d..
|
description = "Test Liquid Source, Range "..d..
|
||||||
tt_normal,
|
tt_normal .. "\n" .. "(falling & floating node)",
|
||||||
drawtype = "liquid",
|
drawtype = "liquid",
|
||||||
tiles = {"testnodes_liquidsource_r"..d..".png"},
|
tiles = {"testnodes_liquidsource_r"..d..".png"},
|
||||||
special_tiles = {
|
special_tiles = {
|
||||||
@ -25,6 +25,8 @@ for d=0, 8 do
|
|||||||
liquid_alternative_flowing = "testnodes:rliquid_flowing_"..d,
|
liquid_alternative_flowing = "testnodes:rliquid_flowing_"..d,
|
||||||
liquid_alternative_source = "testnodes:rliquid_"..d,
|
liquid_alternative_source = "testnodes:rliquid_"..d,
|
||||||
liquid_range = d,
|
liquid_range = d,
|
||||||
|
-- Also use these nodes to test falling, floating liquid source nodes
|
||||||
|
groups = {float = 1, falling_node = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("testnodes:rliquid_flowing_"..d, {
|
minetest.register_node("testnodes:rliquid_flowing_"..d, {
|
||||||
|
Loading…
Reference in New Issue
Block a user