From 77c878f6093fdef7bf001619766dd73db77f1f4c Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 29 Jul 2022 12:48:37 +0200 Subject: [PATCH] make waterlogged roots work with river water --- mods/ITEMS/mcl_mangrove/init.lua | 27 +++++++++++++++++++++------ mods/MAPGEN/mcl_biomes/init.lua | 19 +++++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index 697abef64a..b4ba10142d 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -583,7 +583,7 @@ end local water_tex = "default_water_source_animated.png^[verticalframe:16:0" -minetest.register_node("mcl_mangrove:water_logged_roots", { +local wlroots = { description = ("water_logged_mangrove_roots"), _doc_items_entry_name = S("water_logged_roots"), _doc_items_longdesc = @@ -618,7 +618,16 @@ minetest.register_node("mcl_mangrove:water_logged_roots", { minetest.set_node(pos, {name="mcl_core:water_source"}) end end, -}) +} +minetest.register_node("mcl_mangrove:water_logged_roots", wlroots) +local rwlroots = table.copy(wlroots) +water_tex = "default_river_water_source_animated.png^[verticalframe:16:0" +rwlroots.tiles = { + "("..water_tex..")^mcl_mangrove_roots_top.png", "("..water_tex..")^mcl_mangrove_roots_top.png", + "("..water_tex..")^mcl_mangrove_roots_side.png", "("..water_tex..")^mcl_mangrove_roots_side.png", + "("..water_tex..")^mcl_mangrove_roots_side.png", "("..water_tex..")^mcl_mangrove_roots_side.png" +} +minetest.register_node("mcl_mangrove:river_water_logged_roots",rwlroots) ------------------------ if minetest.get_modpath("mcl_mud") then @@ -690,14 +699,20 @@ local adjacents = { minetest.register_abm({ label = "Waterlog mangrove roots", nodenames = {"mcl_mangrove:mangrove_roots"}, - neighbors = {"mcl_core:water_source"}, + neighbors = {"group:water"}, interval = 5, chance = 5, action = function(pos,value) for _,v in pairs(adjacents) do - if minetest.get_node(vector.add(pos,v)).name == "mcl_core:water_source" then - minetest.swap_node(pos,{name="mcl_mangrove:water_logged_roots"}) - return + local n = minetest.get_node(vector.add(pos,v)).name + if minetest.get_item_group(n,"water") > 0 then + if n:find("river") then + minetest.swap_node(pos,{name="mcl_mangrove:river_water_logged_roots"}) + return + else + minetest.swap_node(pos,{name="mcl_mangrove:water_logged_roots"}) + return + end end end end diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 43cc367de5..d0c6f753e4 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3082,7 +3082,7 @@ local function register_decorations() minetest.register_decoration({ deco_type = "simple", place_on = {"mcl_mangrove:mangrove_roots"}, - spawn_by = {"mcl_core:water_source"}, + spawn_by = {"group:water"}, num_spawn_by = 2, sidelen = 80, fill_ratio = 10, @@ -4886,16 +4886,19 @@ if mg_name ~= "singlenode" then local pr = PseudoRandom(blockseed + 14) for _,f in pairs(deco_ids_trees) do for _, pos in ipairs(gennotify["decoration#"..f] or {}) do - local nn=minetest.find_nodes_in_area(vector.offset(pos,-8,-1,-8),vector.offset(pos,8,2,8),{"mcl_mangrove:mangrove_roots"}) + local nn=minetest.find_nodes_in_area(vector.offset(pos,-8,-1,-8),vector.offset(pos,8,0,8),{"mcl_mangrove:mangrove_roots"}) for _,v in pairs(nn) do local l = pr:next(2,16) - if minetest.get_node(vector.offset(v,0,-1,0)).name == "mcl_core:water_source" then - minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v,0,0,0),vector.offset(v,0,-l,0),{"mcl_core:water_source"}),{name="mcl_mangrove:water_logged_roots"}) - end - if minetest.get_node(vector.offset(v,0,-1,0)).name == "mcl_mud:mud" then + local n = minetest.get_node(vector.offset(v,0,-1,0)).name + if minetest.get_item_group(n,"water") > 0 then + local wl = "mcl_mangrove:water_logged_roots" + if n:find("river") then + wl = "mcl_mangrove:river_water_logged_roots" + end + minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v,0,0,0),vector.offset(v,0,-l,0),{"group:water"}),{name=wl}) + elseif n == "mcl_mud:mud" then minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v,0,0,0),vector.offset(v,0,-l,0),{"mcl_mud:mud"}),{name="mcl_mangrove:mangrove_mud_roots"}) - end - if minetest.get_node(vector.offset(v,0,-1,0)).name == "air" then + elseif n == "air" then minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(v,0,0,0),vector.offset(v,0,-l,0),{"air"}),{name="mcl_mangrove:mangrove_roots"}) end end