VoxeLibre/mods/MAPGEN/mcl_terrain_features/init.lua

243 lines
7.0 KiB
Lua
Raw Normal View History

2022-06-13 02:32:26 +02:00
local adjacents = {
vector.new(1,0,0),
vector.new(1,0,1),
vector.new(1,0,-1),
vector.new(-1,0,0),
vector.new(-1,0,1),
vector.new(-1,0,-1),
vector.new(0,0,1),
vector.new(0,0,-1),
vector.new(0,-1,0)
}
2022-06-18 16:01:25 +02:00
local plane_adjacents = {
vector.new(1,0,0),
vector.new(-1,0,0),
vector.new(0,0,1),
vector.new(0,0,-1),
}
2022-06-13 02:32:26 +02:00
local function set_node_no_bedrock(pos,node)
local n = minetest.get_node(pos)
if n.name == "mcl_core:bedrock" then return end
return minetest.set_node(pos,node)
end
2022-06-22 13:31:43 +02:00
local function airtower(pos,tbl,h)
for i=0,h do
table.insert(tbl,vector.offset(pos,0,i,0))
2022-06-13 02:32:26 +02:00
end
end
2022-06-17 03:09:40 +02:00
local function makelake(pos,size,liquid,placein,border,pr)
2022-06-13 02:32:26 +02:00
local node_under = minetest.get_node(vector.offset(pos,0,1,0))
local p1 = vector.offset(pos,-size,-size,-size)
local p2 = vector.offset(pos,size,size,size)
2022-06-17 03:09:40 +02:00
local nn = minetest.find_nodes_in_area(p1,p2,placein)
2022-06-13 02:32:26 +02:00
table.sort(nn,function(a, b)
2022-06-17 03:09:40 +02:00
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)
2022-06-13 02:32:26 +02:00
end)
if not nn[1] then return end
2022-06-22 13:14:53 +02:00
local y = pos.y - 1
2022-06-13 02:32:26 +02:00
local lq = {}
2022-06-22 13:31:43 +02:00
local air = {}
2022-06-13 02:32:26 +02:00
for i=1,pr:next(1,#nn) do
if nn[i].y == y then
2022-06-22 13:31:43 +02:00
airtower(vector.offset(nn[i],0,1,0),air,55)
2022-06-13 02:32:26 +02:00
table.insert(lq,nn[i])
end
end
2022-06-22 13:31:43 +02:00
minetest.bulk_set_node(lq,{name=liquid})
local air = {}
local br = {}
2022-06-13 02:32:26 +02:00
for k,v in pairs(lq) do
for kk,vv in pairs(adjacents) do
local pp = vector.add(v,vv)
local an = minetest.get_node(pp)
local un = minetest.get_node(vector.offset(pp,0,1,0))
if not border then
if minetest.get_item_group(an.name,"solid") > 0 then
border = an.name
elseif minetest.get_item_group(minetest.get_node(nn[1]).name,"solid") > 0 then
border = minetest.get_node(nn[1]).name
else
border = "mcl_core:stone"
end
if border == "mcl_core:dirt" then border = "mcl_core:dirt_with_grass" end
end
if an.name ~= liquid then
2022-06-22 13:31:43 +02:00
table.insert(br,pp)
2022-06-13 02:32:26 +02:00
if un.name ~= liquid then
2022-06-22 13:31:43 +02:00
airtower(vector.offset(pp,0,1,0),air,55)
2022-06-13 02:32:26 +02:00
end
end
end
end
2022-06-22 13:31:43 +02:00
minetest.bulk_set_node(air,{name="air"})
minetest.bulk_set_node(br,{name=border})
2022-06-13 02:32:26 +02:00
return true
end
mcl_structures.register_structure("lavapool",{
place_on = {"group:sand", "group:dirt", "group:stone"},
terrain_feature = true,
noise_params = {
offset = 0,
scale = 0.0000022,
spread = {x = 250, y = 250, z = 250},
seed = 78375213,
octaves = 3,
persist = 0.001,
flags = "absvalue",
},
2022-06-13 02:32:26 +02:00
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)
2022-06-17 03:09:40 +02:00
return makelake(pos,5,"mcl_core:lava_source","mcl_core:stone",{"group:material_stone", "group:sand", "group:dirt"},pr)
2022-06-13 02:32:26 +02:00
end
})
mcl_structures.register_structure("water_lake",{
place_on = {"group:dirt","group:stone"},
terrain_feature = true,
noise_params = {
offset = 0,
scale = 0.000032,
spread = {x = 250, y = 250, z = 250},
2022-06-18 16:01:25 +02:00
seed = 756641353,
octaves = 3,
persist = 0.001,
flags = "absvalue",
},
2022-06-13 02:32:26 +02:00
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)
2022-06-17 03:09:40 +02:00
return makelake(pos,5,"mcl_core:water_source",{"group:material_stone", "group:sand", "group:dirt"},nil,pr)
end
})
mcl_structures.register_structure("basalt_column",{
place_on = {"mcl_blackstone:blackstone","mcl_blackstone:basalt"},
terrain_feature = true,
2022-06-17 03:09:40 +02:00
spawn_by = {"air"},
num_spawn_by = 2,
noise_params = {
offset = 0,
2022-06-18 16:01:25 +02:00
scale = 0.02,
2022-06-17 03:09:40 +02:00
spread = {x = 250, y = 250, z = 250},
2022-06-18 16:01:25 +02:00
seed = 7225213,
2022-06-17 03:09:40 +02:00
octaves = 5,
persist = 0.1,
flags = "absvalue",
},
flags = "all_floors",
y_max = mcl_vars.mg_nether_max,
y_min = mcl_vars.mg_lava_nether_max + 1,
biomes = { "BasaltDelta" },
place_func = function(pos,def,pr)
local nn = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,-1,5),{"air","mcl_blackstone:basalt","mcl_blackstone:blackstone"})
table.sort(nn,function(a, b)
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)
end)
if #nn < 1 then return false end
2022-06-22 13:31:43 +02:00
local basalt = {}
2022-06-17 03:09:40 +02:00
for i=1,pr:next(1,#nn) do
2022-06-18 16:01:25 +02:00
if minetest.get_node(vector.offset(nn[i],0,-1,0)).name ~= "air" then
local dst=vector.distance(pos,nn[i])
for ii=0,pr:next(2,14)-dst do
2022-06-22 13:31:43 +02:00
table.insert(basalt,vector.new(nn[i].x,nn[i].y + ii,nn[i].z))
2022-06-18 16:01:25 +02:00
end
end
end
2022-06-22 13:31:43 +02:00
minetest.bulk_set_node(basalt,{name="mcl_blackstone:basalt"})
2022-06-18 16:01:25 +02:00
return true
end
})
mcl_structures.register_structure("basalt_pillar",{
place_on = {"mcl_blackstone:blackstone","mcl_blackstone:basalt"},
terrain_feature = true,
2022-06-18 16:01:25 +02:00
noise_params = {
offset = 0,
scale = 0.001,
spread = {x = 250, y = 250, z = 250},
seed = 783213,
octaves = 5,
persist = 0.1,
flags = "absvalue",
},
flags = "all_floors",
y_max = mcl_vars.mg_nether_max,
y_min = mcl_vars.mg_lava_nether_max + 1,
biomes = { "BasaltDelta" },
place_func = function(pos,def,pr)
local nn = minetest.find_nodes_in_area(vector.offset(pos,-2,-1,-2),vector.offset(pos,2,-1,2),{"air","mcl_blackstone:basalt","mcl_blackstone:blackstone"})
table.sort(nn,function(a, b)
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)
end)
if #nn < 1 then return false end
2022-06-22 13:31:43 +02:00
local basalt = {}
2022-06-18 16:01:25 +02:00
for i=1,pr:next(1,#nn) do
if minetest.get_node(vector.offset(nn[i],0,-1,0)).name ~= "air" then
local dst=vector.distance(pos,nn[i])
for ii=0,pr:next(19,34)-dst do
2022-06-22 13:31:43 +02:00
table.insert(basalt,vector.new(nn[i].x,nn[i].y + ii,nn[i].z))
2022-06-18 16:01:25 +02:00
end
2022-06-17 03:09:40 +02:00
end
end
2022-06-22 13:31:43 +02:00
minetest.bulk_set_node(basalt,{name="mcl_blackstone:basalt"})
2022-06-17 03:09:40 +02:00
return true
end
})
2022-06-18 16:01:25 +02:00
mcl_structures.register_structure("lavadelta",{
2022-06-17 03:09:40 +02:00
place_on = {"mcl_blackstone:blackstone","mcl_blackstone:basalt"},
spawn_by = {"mcl_blackstone:basalt","mcl_blackstone:blackstone"},
num_spawn_by = 2,
terrain_feature = true,
2022-06-17 03:09:40 +02:00
noise_params = {
offset = 0,
scale = 0.01,
spread = {x = 250, y = 250, z = 250},
seed = 78375213,
octaves = 5,
persist = 0.1,
flags = "absvalue",
},
flags = "all_floors",
y_max = mcl_vars.mg_nether_max,
y_min = mcl_vars.mg_lava_nether_max + 1,
biomes = { "BasaltDelta" },
place_func = function(pos,def,pr)
2022-06-18 16:01:25 +02:00
local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-10,-1,-10),vector.offset(pos,10,-1,10),{"mcl_blackstone:basalt","mcl_blackstone:blackstone"})
2022-06-17 03:09:40 +02:00
table.sort(nn,function(a, b)
return vector.distance(vector.new(pos.x,0,pos.z), a) < vector.distance(vector.new(pos.x,0,pos.z), b)
end)
if #nn < 1 then return false end
local lava = {}
for i=1,pr:next(1,#nn) do
table.insert(lava,nn[i])
end
2022-06-22 13:31:43 +02:00
minetest.bulk_set_node(lava,{name="mcl_nether:nether_lava_source"})
local basalt = {}
local magma = {}
2022-06-17 03:09:40 +02:00
for _,v in pairs(lava) do
for _,vv in pairs(adjacents) do
local p = vector.add(v,vv)
if minetest.get_node(p).name ~= "mcl_nether:nether_lava_source" then
2022-06-22 13:31:43 +02:00
table.insert(basalt,p)
2022-06-17 03:09:40 +02:00
end
end
if math.random(3) == 1 then
2022-06-22 13:31:43 +02:00
table.insert(magma,v)
2022-06-17 03:09:40 +02:00
end
end
2022-06-22 13:31:43 +02:00
minetest.bulk_set_node(basalt,{name="mcl_blackstone:basalt"})
minetest.bulk_set_node(magma,{name="mcl_nether:magma"})
2022-06-17 03:09:40 +02:00
return true
2022-06-13 02:32:26 +02:00
end
})