Merge pull request 'Some structures fixes' (#2541) from structure_fixes into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2541 Reviewed-by: MysticTempest <mystictempest@noreply.git.minetest.land>mobs-redo
commit
0bd0abc327
|
@ -1,5 +1,12 @@
|
|||
mcl_structures.registered_structures = {}
|
||||
|
||||
local disabled_structures = minetest.settings:get("mcl_disabled_structures")
|
||||
if disabled_structures then disabled_structures = disabled_structures:split(",")
|
||||
else disabled_structures = {} end
|
||||
|
||||
function mcl_structures.is_disabled(structname)
|
||||
if table.indexof(disabled_structures,structname) ~= -1 then return true end
|
||||
end
|
||||
|
||||
function mcl_structures.fill_chests(p1,p2,loot,pr)
|
||||
for it,lt in pairs(loot) do
|
||||
|
@ -38,6 +45,88 @@ function mcl_structures.find_highest_y(pp)
|
|||
return y
|
||||
end
|
||||
|
||||
local function smooth_cube(nn,pos,plane,amnt)
|
||||
local r = {}
|
||||
local amnt = amnt or 9
|
||||
table.sort(nn,function(a, b)
|
||||
if false or plane then
|
||||
return vector.distance(vector.new(pos.x,0,pos.z), vector.new(a.x,0,a.z)) < vector.distance(vector.new(pos.x,0,pos.z), vector.new(b.x,0,b.z))
|
||||
else
|
||||
return vector.distance(pos, a) < vector.distance(pos, b)
|
||||
end
|
||||
end)
|
||||
for i=1,math.max(1,#nn-amnt) do table.insert(r,nn[i]) end
|
||||
return r
|
||||
end
|
||||
|
||||
local function find_ground(pos,nn,gn)
|
||||
local r = 0
|
||||
for _,v in pairs(nn) do
|
||||
local p=vector.new(v)
|
||||
repeat
|
||||
local n = minetest.get_node(p).name
|
||||
p = vector.offset(p,0,-1,0)
|
||||
until not n or n == "mcl_core:bedrock" or n == "ignore" or n == gn
|
||||
--minetest.log(tostring(pos.y - p.y))
|
||||
if pos.y - p.y > r then r = pos.y - p.y end
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
local function get_foundation_nodes(ground_p1,ground_p2,pos,sidelen,node_stone)
|
||||
local replace = {"air","group:liquid","mcl_core:snow","group:tree","group:leaves","group:plant","grass_block","group:dirt"}
|
||||
local depth = find_ground(pos,minetest.find_nodes_in_area(ground_p1,ground_p2,replace),node_stone)
|
||||
local nn = smooth_cube(minetest.find_nodes_in_area(vector.offset(ground_p1,0,-1,0),vector.offset(ground_p2,0,-depth,0),replace),vector.offset(pos,0,-depth,0),true,sidelen * 64)
|
||||
local stone = {}
|
||||
local filler = {}
|
||||
local top = {}
|
||||
local dust = {}
|
||||
for l,v in pairs(nn) do
|
||||
if v.y == ground_p1.y - 1 then
|
||||
table.insert(filler,v)
|
||||
table.insert(top,vector.offset(v,0,1,0))
|
||||
table.insert(dust,vector.offset(v,0,2,0))
|
||||
elseif v.y < ground_p1.y -1 and v.y > ground_p2.y -4 then table.insert(filler,v)
|
||||
elseif v.y < ground_p2.y - 3 and v.y > ground_p2.y -5 then
|
||||
if math.random(3) == 1 then
|
||||
table.insert(filler,v)
|
||||
else
|
||||
table.insert(stone,v)
|
||||
end
|
||||
else
|
||||
table.insert(stone,v)
|
||||
end
|
||||
end
|
||||
return stone,filler,top,dust
|
||||
end
|
||||
|
||||
local function foundation(ground_p1,ground_p2,pos,sidelen)
|
||||
local node_stone = "mcl_core:stone"
|
||||
local node_filler = "mcl_core:dirt"
|
||||
local node_top = "mcl_core:dirt_with_grass" or minetest.get_node(ground_p1).name
|
||||
local node_dust = nil
|
||||
|
||||
if minetest.get_mapgen_setting("mg_name") ~= "v6" then
|
||||
local b = minetest.registered_biomes[minetest.get_biome_name(minetest.get_biome_data(pos).biome)]
|
||||
--minetest.log(dump(b.node_top))
|
||||
if b then
|
||||
if b.node_top then node_top = b.node_top end
|
||||
if b.node_filler then node_filler = b.node_filler end
|
||||
if b.node_stone then node_stone = b.node_stone end
|
||||
if b.node_dust then node_dust = b.node_dust end
|
||||
end
|
||||
end
|
||||
|
||||
local stone,filler,top,dust = get_foundation_nodes(ground_p1,ground_p2,pos,sidelen,node_stone)
|
||||
minetest.bulk_set_node(top,{name=node_top},node_stone)
|
||||
|
||||
if node_dust then
|
||||
minetest.bulk_set_node(dust,{name=node_dust})
|
||||
end
|
||||
minetest.bulk_set_node(filler,{name=node_filler})
|
||||
minetest.bulk_set_node(stone,{name=node_stone})
|
||||
end
|
||||
|
||||
function mcl_structures.place_structure(pos, def, pr, blockseed)
|
||||
if not def then return end
|
||||
local logging = not def.terrain_feature
|
||||
|
@ -55,28 +144,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
|
|||
local solid = minetest.find_nodes_in_area(ground_p1,ground_p2,{"group:solid"})
|
||||
if #solid < ( def.sidelen * def.sidelen ) then
|
||||
if def.make_foundation then
|
||||
local node_stone = "mcl_core:stone"
|
||||
local node_filler = "mcl_core:dirt"
|
||||
local node_top = "mcl_core:dirt_with_grass" or minetest.get_node(ground_p1).name
|
||||
local node_dust = nil
|
||||
|
||||
if minetest.get_mapgen_setting("mg_name") ~= "v6" then
|
||||
local b = minetest.registered_biomes[minetest.get_biome_name(minetest.get_biome_data(pos).biome)]
|
||||
--minetest.log(dump(b.node_top))
|
||||
if b then
|
||||
if b.node_top then node_top = b.node_top end
|
||||
if b.node_filler then node_filler = b.node_filler end
|
||||
if b.node_stone then node_stone = b.node_stone end
|
||||
if b.node_dust then node_dust = b.node_dust end
|
||||
end
|
||||
end
|
||||
local replace = {"air","group:liquid","mcl_core:snow","group:tree","group:leaves"}
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(ground_p1,ground_p2,replace),{name=node_top})
|
||||
if node_dust then
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(ground_p1,0,1,0),vector.offset(ground_p2,0,1,0),{"air"}),{name=node_dust})
|
||||
end
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(ground_p1,0,-1,0),vector.offset(ground_p2,0,-4,0),replace),{name=node_filler})
|
||||
minetest.bulk_set_node(minetest.find_nodes_in_area(vector.offset(ground_p1,0,-5,0),vector.offset(ground_p2,0,-30,0),replace),{name=node_stone})
|
||||
foundation(vector.offset(pos,-def.sidelen/2 - 3,-1,-def.sidelen/2 - 3),vector.offset(pos,def.sidelen/2 + 3,-1,def.sidelen/2 + 3),pos,def.sidelen)
|
||||
else
|
||||
if logging then
|
||||
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. No solid ground.")
|
||||
|
@ -122,6 +190,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
|
|||
end
|
||||
|
||||
function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will be placed by another (non-nospawn) structure that contains it's structblock i.e. it will not be placed by mapgen directly
|
||||
if mcl_structures.is_disabled(name) then return end
|
||||
local structblock = "mcl_structures:structblock_"..name
|
||||
local flags = "place_center_x, place_center_z, force_placement"
|
||||
local y_offset = 0
|
||||
|
|
|
@ -16,11 +16,11 @@ local def = {
|
|||
flags = "place_center_x, place_center_z, all_floors",
|
||||
solid_ground = true,
|
||||
make_foundation = true,
|
||||
chunk_probability = 400,
|
||||
chunk_probability = 800,
|
||||
y_max = mcl_vars.mg_overworld_max,
|
||||
y_min = 1,
|
||||
sidelen = 10,
|
||||
y_offset = -4,
|
||||
y_offset = -5,
|
||||
filenames = {
|
||||
modpath.."/schematics/mcl_structures_ruined_portal_1.mts",
|
||||
modpath.."/schematics/mcl_structures_ruined_portal_2.mts",
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -29,7 +29,7 @@ local function airtower(pos,tbl,h)
|
|||
end
|
||||
end
|
||||
|
||||
local function makelake(pos,size,liquid,placein,border,pr)
|
||||
local function makelake(pos,size,liquid,placein,border,pr,noair)
|
||||
local node_under = minetest.get_node(vector.offset(pos,0,-1,0))
|
||||
local p1 = vector.offset(pos,-size,-1,-size)
|
||||
local p2 = vector.offset(pos,size,-1,size)
|
||||
|
@ -70,7 +70,7 @@ local function makelake(pos,size,liquid,placein,border,pr)
|
|||
end
|
||||
if border == nil or border == "mcl_core:dirt" then border = "mcl_core:dirt_with_grass" end
|
||||
end
|
||||
if an.name ~= liquid then
|
||||
if not noair and an.name ~= liquid then
|
||||
table.insert(br,pp)
|
||||
if un.name ~= liquid then
|
||||
airtower(pp,air,55)
|
||||
|
@ -205,7 +205,28 @@ mcl_structures.register_structure("water_lake",{
|
|||
y_max = mcl_vars.mg_overworld_max,
|
||||
y_min = minetest.get_mapgen_setting("water_level"),
|
||||
place_func = function(pos,def,pr)
|
||||
return makelake(pos,5,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block"},nil,pr)
|
||||
return makelake(pos,5,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block"},"mcl_core:dirt_with_grass",pr)
|
||||
end
|
||||
})
|
||||
|
||||
mcl_structures.register_structure("water_lake_mangrove_swamp",{
|
||||
place_on = {"mcl_mud:mud"},
|
||||
biomes = { "MangroveSwamp" },
|
||||
terrain_feature = true,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.0032,
|
||||
spread = {x = 250, y = 250, z = 250},
|
||||
seed = 6343241353,
|
||||
octaves = 3,
|
||||
persist = 0.001,
|
||||
flags = "absvalue",
|
||||
},
|
||||
flags = "place_center_x, place_center_z, force_placement",
|
||||
y_max = mcl_vars.mg_overworld_max,
|
||||
y_min = minetest.get_mapgen_setting("water_level"),
|
||||
place_func = function(pos,def,pr)
|
||||
return makelake(pos,3,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt","group:grass_block","mcl_mud:mud"},"mcl_mud:mud",pr,true)
|
||||
end
|
||||
})
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@ mcl_doTileDrops (Blocks have drops) bool true
|
|||
# If enabled, TNT explosions destroy blocks.
|
||||
mcl_tnt_griefing (TNT destroys blocks) bool true
|
||||
|
||||
# Comma separated list of disabled structure names
|
||||
mcl_disabled_structures (Disabled structures) string
|
||||
|
||||
[Players]
|
||||
# If enabled, players respawn at the bed they last lay on instead of normal
|
||||
# spawn.
|
||||
|
|
Loading…
Reference in New Issue