2021-05-05 22:41:20 +02:00
|
|
|
|
2021-05-06 00:42:06 +02:00
|
|
|
-- Check it:
|
|
|
|
-- seed 1, v7 mapgen
|
|
|
|
-- /teleport 14958,8,11370
|
2021-05-05 22:41:20 +02:00
|
|
|
|
2021-05-03 03:24:53 +02:00
|
|
|
local mcl_mapgen_get_far_node = mcl_mapgen.get_far_node
|
|
|
|
local minetest_log = minetest.log
|
|
|
|
local minetest_place_schematic = minetest.place_schematic
|
|
|
|
local minetest_pos_to_string = minetest.pos_to_string
|
2021-05-06 00:42:06 +02:00
|
|
|
local minetest_swap_node = minetest.swap_node
|
2021-05-03 03:24:53 +02:00
|
|
|
|
|
|
|
local path = minetest.get_modpath("mcl_ocean_monument") .. "/schematics/ocean_monument.mts"
|
2021-05-06 00:42:06 +02:00
|
|
|
|
|
|
|
local water = "mcl_core:water_source"
|
|
|
|
local air = "air"
|
|
|
|
local ice = "mcl_core:ice"
|
|
|
|
|
|
|
|
local leg_materials = {
|
|
|
|
"mcl_ocean:prismarine_brick",
|
|
|
|
"mcl_ocean:prismarine",
|
|
|
|
}
|
|
|
|
local what_we_can_replace_by_legs = {
|
|
|
|
water,
|
|
|
|
air,
|
2021-05-06 00:58:49 +02:00
|
|
|
"mcl_core:water_flowing",
|
2021-05-06 00:42:06 +02:00
|
|
|
"mcl_core:stone",
|
|
|
|
}
|
|
|
|
|
|
|
|
local leg_search_quick_index = {}
|
|
|
|
for _, v in pairs(leg_materials) do
|
|
|
|
leg_search_quick_index[v] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
local leg_replace_quick_index = {}
|
|
|
|
for _, v in pairs(what_we_can_replace_by_legs) do
|
|
|
|
leg_replace_quick_index[v] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
local y_wanted = mcl_mapgen.OFFSET_NODES -- supposed to be -32
|
|
|
|
local y_bottom = mcl_mapgen.overworld.min -- -62
|
2021-05-03 03:24:53 +02:00
|
|
|
|
2021-08-05 02:01:07 +02:00
|
|
|
mcl_mapgen.register_mapgen(function(minp, maxp, seed)
|
2021-05-03 03:24:53 +02:00
|
|
|
local minp = minp
|
|
|
|
local y = minp.y
|
2021-05-06 00:42:06 +02:00
|
|
|
if y ~= y_wanted then return end
|
2021-05-03 03:24:53 +02:00
|
|
|
|
|
|
|
local x, z = minp.x, minp.z
|
|
|
|
local pr = PseudoRandom(seed)
|
2021-05-06 00:42:06 +02:00
|
|
|
|
|
|
|
-- scan the ocean - it should be the ocean:
|
|
|
|
for i = 1, pr:next(10, 100) do
|
|
|
|
local pos = {x = pr:next(15, 64) + x, y = pr:next(0, 25) - 25, z = pr:next(15, 64) + z}
|
2021-05-04 01:27:35 +02:00
|
|
|
local node_name = mcl_mapgen_get_far_node(pos).name
|
2021-05-05 22:41:20 +02:00
|
|
|
if node_name ~= water then return end
|
2021-05-03 03:24:53 +02:00
|
|
|
end
|
2021-05-06 00:42:06 +02:00
|
|
|
|
|
|
|
-- scan nodes above water level - there should be the air:
|
|
|
|
for i = 1, pr:next(10, 100) do
|
|
|
|
local pos = {x = pr:next(0, 79) + x, y = 2, z = pr:next(0,79) + z}
|
2021-05-04 01:27:35 +02:00
|
|
|
local node_name = mcl_mapgen_get_far_node(pos).name
|
|
|
|
if node_name ~= air then return end
|
2021-05-03 03:24:53 +02:00
|
|
|
end
|
2021-05-06 00:42:06 +02:00
|
|
|
|
|
|
|
-- scan ocean surface - allow only water and ice:
|
2021-05-03 03:24:53 +02:00
|
|
|
for i = 1, pr:next(10,100) do
|
2021-05-06 00:42:06 +02:00
|
|
|
local pos = {x=pr:next(0, 79)+x, y=1, z=pr:next(0,79)+z}
|
2021-05-04 01:27:35 +02:00
|
|
|
local node_name = mcl_mapgen_get_far_node(pos).name
|
2021-05-05 22:41:20 +02:00
|
|
|
if node_name ~= water and node_name ~= ice then return end
|
2021-05-03 03:24:53 +02:00
|
|
|
end
|
|
|
|
|
2021-05-06 00:42:06 +02:00
|
|
|
-- random rotation:
|
|
|
|
local rotation = pr:next(0, 3)
|
|
|
|
local rotation_str = tostring(rotation * 90)
|
|
|
|
minetest_place_schematic(minp, path, rotation_str, nil, true)
|
2021-05-03 03:24:53 +02:00
|
|
|
|
2021-05-06 00:42:06 +02:00
|
|
|
-- search prismarine legs at base level and continue them up to the bottom:
|
|
|
|
for x = x, maxp.x do
|
|
|
|
for z = z, maxp.z do
|
|
|
|
local pos = {x = x, y = y, z = z}
|
|
|
|
local node_name = mcl_mapgen_get_far_node(pos).name
|
|
|
|
if leg_search_quick_index[node_name] then
|
|
|
|
local node_leg = {name = node_name}
|
|
|
|
for y = y - 1, y_bottom, -1 do
|
|
|
|
pos.y = y
|
|
|
|
local next_name = mcl_mapgen_get_far_node(pos).name
|
|
|
|
if not leg_replace_quick_index[next_name] then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
minetest_swap_node(pos, node_leg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-05-03 03:24:53 +02:00
|
|
|
|
2021-05-06 00:42:06 +02:00
|
|
|
minetest_log("action", "[mcl_ocean_monument] Placed at " .. minetest_pos_to_string(minp) .. ", " .. rotation_str .. " deg.")
|
2021-05-03 03:24:53 +02:00
|
|
|
|
2021-08-05 02:01:07 +02:00
|
|
|
end, mcl_mapgen.order.OCEAN_MONUMENT)
|