Add workaround to fix broken double plants in v6

This commit is contained in:
Wuzzy 2019-02-09 05:58:40 +01:00
parent e89a01630b
commit e28f213f9a

View File

@ -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. ----- ----- The section to perform basic block overrides of the core mapgen generated world. -----
-- Snow and sand fixes. This code implements snow consistency -- 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. -- 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: -- v6 mapgen:
-- Put top snow on snowy grass blocks. The mapgen does not generate the top snow on its own. -- Put top snow on snowy grass blocks. The mapgen does not generate the top snow on its own.
if mg_name == "v6" then 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") local snowdirt = minetest.find_nodes_in_area_under_air(minp, maxp, "mcl_core:dirt_with_grass_snow")
for n = 1, #snowdirt do for n = 1, #snowdirt do
-- CHECKME: What happens at chunk borders? -- CHECKME: What happens at chunk borders?
@ -1743,10 +1744,38 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[p_pos] = c_top_snow data[p_pos] = c_top_snow
end end
end end
if #snowdirt > 1 then if #snowdirt > 0 then
lvm_used = true lvm_used = true
end 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: -- Non-v6 mapgens:
-- Clear snowy grass blocks without snow above to ensure consistency. -- Clear snowy grass blocks without snow above to ensure consistency.