2022-06-10 01:49:33 +02:00
|
|
|
local adjacents = {
|
|
|
|
vector.new(1,0,0),
|
|
|
|
vector.new(-1,0,0),
|
|
|
|
vector.new(0,0,1),
|
|
|
|
vector.new(0,0,-1),
|
|
|
|
vector.new(0,1,0),
|
|
|
|
vector.new(0,-1,0)
|
|
|
|
}
|
|
|
|
|
2022-06-11 12:29:53 +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-10 01:49:33 +02:00
|
|
|
local function makegeode(pos,pr)
|
2022-06-10 04:34:58 +02:00
|
|
|
local size = pr:next(4,7)
|
2022-06-10 01:49:33 +02:00
|
|
|
local p1 = vector.offset(pos,-size,-size,-size)
|
|
|
|
local p2 = vector.offset(pos,size,size,size)
|
2022-06-11 12:24:06 +02:00
|
|
|
local calcite = {}
|
2022-06-10 01:49:33 +02:00
|
|
|
local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone"})
|
|
|
|
table.sort(nn,function(a, b)
|
|
|
|
return vector.distance(pos, a) < vector.distance(pos, b)
|
|
|
|
end)
|
|
|
|
if not nn[1] then return end
|
2022-06-11 12:24:06 +02:00
|
|
|
|
2022-06-10 01:49:33 +02:00
|
|
|
for i=1,math.random(#nn) do
|
2022-06-11 12:29:53 +02:00
|
|
|
set_node_no_bedrock(nn[i],{name="mcl_amethyst:amethyst_block"})
|
2022-06-10 01:49:33 +02:00
|
|
|
end
|
2022-06-11 12:24:06 +02:00
|
|
|
|
|
|
|
for k,v in pairs(minetest.find_nodes_in_area(p1,p2,{"mcl_amethyst:amethyst_block"})) do
|
2022-06-10 01:49:33 +02:00
|
|
|
local all_amethyst = true
|
|
|
|
for kk,vv in pairs(adjacents) do
|
|
|
|
local pp = vector.add(v,vv)
|
|
|
|
local an = minetest.get_node(pp)
|
|
|
|
if an.name ~= "mcl_amethyst:amethyst_block" then
|
|
|
|
if minetest.get_item_group(an.name,"material_stone") > 0 then
|
2022-06-11 12:29:53 +02:00
|
|
|
set_node_no_bedrock(pp,{name="mcl_amethyst:calcite"})
|
2022-06-11 12:24:06 +02:00
|
|
|
table.insert(calcite,pp)
|
2022-06-10 01:49:33 +02:00
|
|
|
if pr:next(1,5) == 1 then
|
2022-06-11 12:29:53 +02:00
|
|
|
set_node_no_bedrock(v,{name="mcl_amethyst:budding_amethyst_block"})
|
2022-06-10 01:49:33 +02:00
|
|
|
end
|
|
|
|
all_amethyst = false
|
|
|
|
elseif an.name ~= "mcl_amethyst:amethyst_block" and an.name ~= "air" then
|
|
|
|
all_amethyst = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-06-11 12:29:53 +02:00
|
|
|
if all_amethyst then set_node_no_bedrock(v,{name="air"}) end
|
2022-06-10 01:49:33 +02:00
|
|
|
end
|
|
|
|
|
2022-06-11 12:24:06 +02:00
|
|
|
for _,v in pairs(calcite) do
|
|
|
|
for _,vv in pairs(minetest.find_nodes_in_area(vector.offset(v,-1,-1,-1),vector.offset(v,1,1,1),{"group:material_stone"})) do
|
2022-06-13 02:32:26 +02:00
|
|
|
set_node_no_bedrock(vv,{name="mcl_deepslate:deepslate"}) --Replace with smooth basalt when available
|
2022-06-11 12:24:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for k,v in pairs(minetest.find_nodes_in_area_under_air(p1,p2,{"mcl_amethyst:amethyst_block","mcl_amethyst:budding_amethyst_block"})) do
|
2022-06-10 01:49:33 +02:00
|
|
|
local r = pr:next(1,50)
|
|
|
|
if r < 10 then
|
2022-06-11 12:29:53 +02:00
|
|
|
set_node_no_bedrock(vector.offset(v,0,1,0),{name="mcl_amethyst:amethyst_cluster",param2=1})
|
2022-06-10 01:49:33 +02:00
|
|
|
end
|
|
|
|
end
|
2022-06-10 04:34:58 +02:00
|
|
|
return true
|
2022-06-10 01:49:33 +02:00
|
|
|
end
|
|
|
|
|
2022-06-10 02:40:33 +02:00
|
|
|
mcl_structures.register_structure("geode",{
|
2022-06-10 01:49:33 +02:00
|
|
|
place_on = {"mcl_core:stone"},
|
2022-06-10 04:34:58 +02:00
|
|
|
fill_ratio = 0.0001,
|
2022-06-10 01:49:33 +02:00
|
|
|
flags = "place_center_x, place_center_z, force_placement",
|
|
|
|
biomes = ocean_biomes,
|
2022-06-10 04:34:58 +02:00
|
|
|
y_max = -24,
|
2022-06-10 01:49:33 +02:00
|
|
|
y_min = mcl_vars.mg_overworld_min,
|
|
|
|
filenames = schems,
|
|
|
|
y_offset = function(pr) return pr:next(-4,-2) end,
|
|
|
|
place_func = function(pos,def,pr)
|
|
|
|
local p = vector.new(pos.x + pr:next(-30,30),pos.y,pos.z + pr:next(-30,30))
|
2022-06-10 04:34:58 +02:00
|
|
|
return makegeode(pos,pr)
|
|
|
|
end
|
2022-06-10 01:49:33 +02:00
|
|
|
})
|