mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01:00
structure-api: add check for solid ground
This commit is contained in:
parent
8e976d9191
commit
0b3a4c18d7
@ -14,16 +14,8 @@ mcl_structures.register_structure("nether_outpost",{
|
|||||||
},
|
},
|
||||||
flags = "all_floors",
|
flags = "all_floors",
|
||||||
biomes = {"Nether","SoulsandValley","WarpedForest","CrimsonForest","BasaltDelta"},
|
biomes = {"Nether","SoulsandValley","WarpedForest","CrimsonForest","BasaltDelta"},
|
||||||
on_place = function(pos,def,pr)
|
sidelen = 15,
|
||||||
local sidelen = 15
|
solid_ground = true,
|
||||||
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,
|
|
||||||
y_min = mcl_vars.mg_lava_nether_max,
|
y_min = mcl_vars.mg_lava_nether_max,
|
||||||
y_max = mcl_vars.mg_nether_max - 30,
|
y_max = mcl_vars.mg_nether_max - 30,
|
||||||
filenames = { modpath.."/schematics/nether_outpost.mts" },
|
filenames = { modpath.."/schematics/nether_outpost.mts" },
|
||||||
|
@ -9,6 +9,19 @@ function mcl_structures.place_structure(pos, def, pr)
|
|||||||
elseif def.y_offset then
|
elseif def.y_offset then
|
||||||
y_offset = def.y_offset
|
y_offset = def.y_offset
|
||||||
end
|
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 def.on_place and not def.on_place(pos,def,pr) then
|
||||||
if logging then
|
if logging then
|
||||||
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pos).." not placed. Conditions not satisfied.")
|
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pos).." not placed. Conditions not satisfied.")
|
||||||
|
Loading…
Reference in New Issue
Block a user