2022-06-09 23:49:33 +00:00
|
|
|
local adjacents = {
|
2022-11-11 09:35:25 +00:00
|
|
|
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-09 23:49:33 +00:00
|
|
|
}
|
|
|
|
|
2022-11-11 09:35:25 +00:00
|
|
|
---@param pos Vector
|
|
|
|
---@param node node
|
|
|
|
local function set_node_no_bedrock(pos, node)
|
|
|
|
if minetest.get_node(pos).name == "mcl_core:bedrock" then return end
|
|
|
|
minetest.set_node(pos, node)
|
2022-06-11 10:29:53 +00:00
|
|
|
end
|
|
|
|
|
2022-11-11 09:35:25 +00:00
|
|
|
local function makegeode(pos, def, pr)
|
|
|
|
local size = pr:next(5, 7)
|
|
|
|
local p1 = vector.offset(pos, -size, -size, -size)
|
|
|
|
local p2 = vector.offset(pos, size, size, size)
|
2022-07-01 12:43:03 +00:00
|
|
|
minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param)
|
|
|
|
if calls_remaining ~= 0 then return end
|
|
|
|
local calcite = {}
|
2022-11-11 09:35:25 +00:00
|
|
|
local nn = minetest.find_nodes_in_area(p1, p2, { "group:material_stone", "group:dirt", "mcl_core:gravel" })
|
|
|
|
table.sort(nn, function(a, b)
|
|
|
|
return vector.distance(pos, a) < vector.distance(pos, b)
|
2022-07-01 12:43:03 +00:00
|
|
|
end)
|
|
|
|
if not nn[1] then return end
|
2022-06-11 10:24:06 +00:00
|
|
|
|
2022-11-11 09:35:25 +00:00
|
|
|
for i = 1, pr:next(1, math.max(2, #nn - math.ceil(#nn / 5))) do
|
|
|
|
set_node_no_bedrock(nn[i], { name = "mcl_amethyst:amethyst_block" })
|
2022-07-01 12:43:03 +00:00
|
|
|
end
|
2022-06-11 10:24:06 +00:00
|
|
|
|
2022-11-11 09:35:25 +00:00
|
|
|
for k, v in pairs(minetest.find_nodes_in_area(p1, p2, { "mcl_amethyst:amethyst_block" })) do
|
2022-07-01 12:43:03 +00:00
|
|
|
local all_amethyst = true
|
2022-11-11 09:35:25 +00:00
|
|
|
for kk, vv in pairs(adjacents) do
|
|
|
|
local pp = vector.add(v, vv)
|
2022-07-01 12:43:03 +00:00
|
|
|
local an = minetest.get_node(pp)
|
|
|
|
if an.name ~= "mcl_amethyst:amethyst_block" then
|
2022-11-11 09:35:25 +00:00
|
|
|
if minetest.get_item_group(an.name, "material_stone") > 0 then
|
|
|
|
set_node_no_bedrock(pp, { name = "mcl_amethyst:calcite" })
|
|
|
|
table.insert(calcite, pp)
|
|
|
|
if pr:next(1, 5) == 1 then
|
|
|
|
set_node_no_bedrock(v, { name = "mcl_amethyst:budding_amethyst_block" })
|
2022-07-01 12:43:03 +00:00
|
|
|
end
|
|
|
|
all_amethyst = false
|
2022-11-11 09:35:25 +00:00
|
|
|
elseif an.name ~= "mcl_amethyst:amethyst_block" and an.name ~= "air" and
|
|
|
|
an.name ~= "mcl_amethyst:budding_amethyst_block" then
|
2022-07-01 12:43:03 +00:00
|
|
|
all_amethyst = false
|
2022-06-09 23:49:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-11-11 09:35:25 +00:00
|
|
|
if all_amethyst then set_node_no_bedrock(v, { name = "air" }) end
|
2022-06-09 23:49:33 +00:00
|
|
|
end
|
|
|
|
|
2022-11-11 09:35:25 +00: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
|
|
|
|
set_node_no_bedrock(vv, { name = "mcl_blackstone:basalt_smooth" })
|
2022-07-01 12:43:03 +00:00
|
|
|
end
|
2022-06-11 10:24:06 +00:00
|
|
|
end
|
|
|
|
|
2022-11-11 09:35:25 +00:00
|
|
|
for k, v in pairs(minetest.find_nodes_in_area_under_air(p1, p2,
|
|
|
|
{ "mcl_amethyst:amethyst_block", "mcl_amethyst:budding_amethyst_block" })) do
|
|
|
|
local r = pr:next(1, 50)
|
2022-07-01 12:43:03 +00:00
|
|
|
if r < 10 then
|
2022-11-11 09:35:25 +00:00
|
|
|
set_node_no_bedrock(vector.offset(v, 0, 1, 0), { name = "mcl_amethyst:amethyst_cluster", param2 = 1 })
|
2022-07-01 12:43:03 +00:00
|
|
|
end
|
2022-06-09 23:49:33 +00:00
|
|
|
end
|
2022-07-01 12:43:03 +00:00
|
|
|
end)
|
2022-06-10 02:34:58 +00:00
|
|
|
return true
|
2022-06-09 23:49:33 +00:00
|
|
|
end
|
|
|
|
|
2022-11-11 09:35:25 +00:00
|
|
|
mcl_structures.register_structure("geode", {
|
|
|
|
place_on = { "group:material_stone" },
|
2022-06-13 09:59:15 +00:00
|
|
|
noise_params = {
|
|
|
|
offset = 0,
|
|
|
|
scale = 0.00022,
|
2022-11-11 09:35:25 +00:00
|
|
|
spread = { x = 250, y = 250, z = 250 },
|
2022-06-13 09:59:15 +00:00
|
|
|
seed = 7894353,
|
|
|
|
octaves = 3,
|
|
|
|
persist = 0.001,
|
|
|
|
flags = "absvalue",
|
|
|
|
},
|
2022-06-24 21:24:51 +00:00
|
|
|
flags = "force_placement",
|
2022-06-24 19:10:52 +00:00
|
|
|
terrain_feature = true,
|
2022-06-10 02:34:58 +00:00
|
|
|
y_max = -24,
|
2022-06-09 23:49:33 +00:00
|
|
|
y_min = mcl_vars.mg_overworld_min,
|
2022-11-11 09:35:25 +00:00
|
|
|
y_offset = function(pr) return pr:next(-4, -2) end,
|
2022-06-24 16:24:41 +00:00
|
|
|
place_func = makegeode,
|
2022-06-09 23:49:33 +00:00
|
|
|
})
|