mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 02:21:06 +01:00
structure-api: add check for solid ground
This commit is contained in:
parent
8e976d9191
commit
0b3a4c18d7
2 changed files with 15 additions and 10 deletions
|
@ -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" },
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in a new issue