From 01ac9ad685685666a87cda4cab6466dc97ef364a Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 16 Apr 2023 09:55:05 +0000 Subject: [PATCH] Add old method back for foliage This commit adds back the old `set_node` method for the foliage, since the foliage is much more difficult to work with via the VoxelManip method due to them being part of schematics that could span across mapblocks in some cases. The old method will complement the new one by running after the VoxelManip has done its job, and fixes any foliage that the VoxelManip had missed. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index a6930bc2e..8154bb66b 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -577,3 +577,25 @@ minetest.register_lbm({ end end }) + +minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of missed foliage. + local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) + local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) + for _, fpos in pairs(foliage) do + local fnode = minetest.get_node(fpos) + local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(fpos).foliage_palette_index + if fnode.param2 ~= foliage_palette_index and fnode.name ~= "mcl_core:vine" then + fnode.param2 = foliage_palette_index + minetest.set_node(fpos, fnode) + elseif fnode.name == "mcl_core:vine" then + local biome_param2 = foliage_palette_index + local rotation_param2 = mcl_util.get_colorwallmounted_rotation(fpos) + local final_param2 = (biome_param2 * 8) + rotation_param2 + if fnode.param2 ~= final_param2 then + fnode.param2 = final_param2 + minetest.set_node(fpos, fnode) + end + end + end +end +)