From e28f213f9aff61e51ff5fa9d7932d540d8a90d3f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 9 Feb 2019 05:58:40 +0100 Subject: [PATCH] Add workaround to fix broken double plants in v6 --- mods/MAPGEN/mcl_mapgen_core/init.lua | 35 +++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index eb9caa6322..9a979d4367 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -1729,12 +1729,13 @@ minetest.register_on_generated(function(minp, maxp, seed) ----- The section to perform basic block overrides of the core mapgen generated world. ----- -- Snow and sand fixes. This code implements snow consistency - -- and fixes floating sand. + -- and fixes floating sand and cut plants. -- A snowy grass block must be below a top snow or snow block at all times. - if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + if emin.y <= mcl_vars.mg_overworld_max and emax.y >= mcl_vars.mg_overworld_min then -- v6 mapgen: -- Put top snow on snowy grass blocks. The mapgen does not generate the top snow on its own. if mg_name == "v6" then + -- FIXME: Cavegen and mudflow might screw this up and cause floating top snow to appear local snowdirt = minetest.find_nodes_in_area_under_air(minp, maxp, "mcl_core:dirt_with_grass_snow") for n = 1, #snowdirt do -- CHECKME: What happens at chunk borders? @@ -1743,10 +1744,38 @@ minetest.register_on_generated(function(minp, maxp, seed) data[p_pos] = c_top_snow end end - if #snowdirt > 1 then + if #snowdirt > 0 then lvm_used = true end + --[[ Remove broken double plants caused by v6 weirdness. + v6 might break the bottom part of double plants because of how it works. + There are 3 possibilities: + 1) Jungle: Top part is placed on top of a jungle tree or fern (=v6 jungle grass). + This is because the schematic might be placed even if some nodes of it + could not be placed because the destination was already occupied. + TODO: A better fix for this would be if schematics could abort placement + altogether if ANY of their nodes could not be placed. + 2) Cavegen: Removes the bottom part, the upper part floats + 3) Mudflow: Same as 2) ]] + local plants = minetest.find_nodes_in_area(emin, emax, "group:double_plant") + for n = 1, #plants do + local node = vm:get_node_at(plants[n]) + local is_top = minetest.get_item_group(node.name, "double_plant") == 2 + if is_top then + local p_pos = area:index(plants[n].x, plants[n].y-1, plants[n].z) + if p_pos then + node = vm:get_node_at({x=plants[n].x, y=plants[n].y-1, z=plants[n].z}) + local is_bottom = minetest.get_item_group(node.name, "double_plant") == 1 + if not is_bottom then + p_pos = area:index(plants[n].x, plants[n].y, plants[n].z) + data[p_pos] = c_air + lvm_used = true + end + end + end + end + -- Non-v6 mapgens: -- Clear snowy grass blocks without snow above to ensure consistency.