From 0b3a4c18d713faefaedd3d54d14e65448c9232f8 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 22 Jun 2022 16:47:43 +0200 Subject: [PATCH] structure-api: add check for solid ground --- mods/MAPGEN/mcl_nether_fortresses/init.lua | 12 ++---------- mods/MAPGEN/mcl_structures/api.lua | 13 +++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mods/MAPGEN/mcl_nether_fortresses/init.lua b/mods/MAPGEN/mcl_nether_fortresses/init.lua index 8910669cd..a82d3f4c7 100644 --- a/mods/MAPGEN/mcl_nether_fortresses/init.lua +++ b/mods/MAPGEN/mcl_nether_fortresses/init.lua @@ -14,16 +14,8 @@ mcl_structures.register_structure("nether_outpost",{ }, flags = "all_floors", biomes = {"Nether","SoulsandValley","WarpedForest","CrimsonForest","BasaltDelta"}, - on_place = function(pos,def,pr) - local sidelen = 15 - local node = minetest.get_node(vector.offset(pos,1,1,0)) - local solid = minetest.find_nodes_in_area(vector.offset(pos,-sidelen/2,-1,-sidelen/2),vector.offset(pos,sidelen/2,-1,sidelen/2),{"group:solid"}) - local air = minetest.find_nodes_in_area(vector.offset(pos,-sidelen/2,1,-sidelen/2),vector.offset(pos,sidelen/2,4,sidelen/2),{"air"}) - if #solid < ( sidelen * sidelen ) or - #air < (sidelen * sidelen ) then return false end - minetest.bulk_set_node(solid,node) - return true - end, + sidelen = 15, + solid_ground = true, y_min = mcl_vars.mg_lava_nether_max, y_max = mcl_vars.mg_nether_max - 30, filenames = { modpath.."/schematics/nether_outpost.mts" }, diff --git a/mods/MAPGEN/mcl_structures/api.lua b/mods/MAPGEN/mcl_structures/api.lua index 5bcee086a..5153e85f9 100644 --- a/mods/MAPGEN/mcl_structures/api.lua +++ b/mods/MAPGEN/mcl_structures/api.lua @@ -9,6 +9,19 @@ function mcl_structures.place_structure(pos, def, pr) elseif def.y_offset then y_offset = def.y_offset end + if def.solid_ground and def.sidelen then + local node = minetest.get_node(vector.offset(pos,1,1,0)) + local solid = minetest.find_nodes_in_area(vector.offset(pos,-def.sidelen/2,-1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,-1,def.sidelen/2),{"group:solid"}) + local air = minetest.find_nodes_in_area(vector.offset(pos,-def.sidelen/2,1,-def.sidelen/2),vector.offset(pos,def.sidelen/2,4,def.sidelen/2),{"air"}) + if #solid < ( def.sidelen * def.sidelen ) or + #air < (def.sidelen * def.sidelen ) then + if logging then + minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pos).." not placed. No solid ground.") + end + return false + end + --minetest.bulk_set_node(solid,node) + end if def.on_place and not def.on_place(pos,def,pr) then if logging then minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pos).." not placed. Conditions not satisfied.")