From 30546a3902d3528cccf6258dc30101664e4a27e2 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 16 Apr 2021 12:17:07 +0200 Subject: [PATCH] Make sure ancient debris is not generated exposed to air --- mods/MAPGEN/mcl_biomes/init.lua | 2 +- mods/MAPGEN/mcl_debrisgen/init.lua | 44 ++++++++++++++++++++++++++++++ mods/MAPGEN/mcl_debrisgen/mod.conf | 4 +++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 mods/MAPGEN/mcl_debrisgen/init.lua create mode 100644 mods/MAPGEN/mcl_debrisgen/mod.conf diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 0725bcb7b..20bb50b64 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3920,7 +3920,7 @@ end -- Decorations in non-Overworld dimensions local function register_dimension_decorations() --[[ NETHER ]] - -- TODO: Nether + -- TODO: Nether --[[ THE END ]] diff --git a/mods/MAPGEN/mcl_debrisgen/init.lua b/mods/MAPGEN/mcl_debrisgen/init.lua new file mode 100644 index 000000000..4e80c2504 --- /dev/null +++ b/mods/MAPGEN/mcl_debrisgen/init.lua @@ -0,0 +1,44 @@ +local c_debris = minetest.get_content_id("mcl_nether:ancient_debris") +local c_netherrack = minetest.get_content_id("mcl_nether:netherrack") +local c_air = minetest.get_content_id("air") + +local facedir = { + vector.new(0, 0, 1), + vector.new(0, 1, 0), + vector.new(1, 0, 0), + vector.new(0, 0, -1), + vector.new(0, -1, 0), + vector.new(-1, 0, 0), +} + +minetest.register_on_generated(function(minp, maxp) + if maxp.y < mcl_vars.mg_nether_min or minp.y > mcl_vars.mg_nether_max then + return + end + + local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") + local data = vm:get_data() + local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) + + for idx in area:iter(minp.x, math.max(minp.y, mcl_vars.mg_nether_min), minp.z, maxp.x, math.min(maxp.y, mcl_vars.mg_nether_max), maxp.z) do + if data[idx] == c_debris then + local pos = area:position(idx) + local exposed = false + for _, dir in pairs(facedir) do + if data[area:indexp(vector.add(pos, dir))] == c_air then + exposed = true + break + end + end + if exposed then + data[idx] = c_netherrack + end + end + end + + vm:set_data(data) + vm:calc_lighting() + vm:update_liquids() + vm:write_to_map() +end) + diff --git a/mods/MAPGEN/mcl_debrisgen/mod.conf b/mods/MAPGEN/mcl_debrisgen/mod.conf new file mode 100644 index 000000000..cc5455208 --- /dev/null +++ b/mods/MAPGEN/mcl_debrisgen/mod.conf @@ -0,0 +1,4 @@ +name = mcl_debrisgen +author = Fleckenstein +description = Make sure ancient debris is not generated exposed to air +depends = mcl_mapgen_core, mcl_nether