From fdc95a2ab12afe255259bf54c0607d2e991f1257 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Wed, 7 Feb 2024 23:54:52 -0500 Subject: [PATCH] Move coral, cursed, crystal, forsaken schems from mapgen_after --- mapgen_after.lua | 187 +++------------------------- mapgen_coral_forest_dunes.lua | 4 +- mapgen_coral_forest_ocean.lua | 4 +- mapgen_crystal_forest_dunes.lua | 189 ++++++++++++++++++++--------- mapgen_cursed_lands_deep_ocean.lua | 2 +- mapgen_cursed_lands_dunes.lua | 173 ++++++++++++++++++-------- mapgen_forsaken_desert_ocean.lua | 1 - 7 files changed, 279 insertions(+), 281 deletions(-) diff --git a/mapgen_after.lua b/mapgen_after.lua index 7f90603..59c459e 100644 --- a/mapgen_after.lua +++ b/mapgen_after.lua @@ -15,23 +15,14 @@ --]] -- Get the content IDs for the nodes used. -local c_water_source = minetest.get_content_id('mapgen_water_source') local c_forsaken_desert_sand = minetest.get_content_id('everness:forsaken_desert_sand') local c_forsaken_desert_chiseled_stone = minetest.get_content_id('everness:forsaken_desert_chiseled_stone') local c_forsaken_desert_brick = minetest.get_content_id('everness:forsaken_desert_brick') local c_forsaken_desert_engraved_stone = minetest.get_content_id('everness:forsaken_desert_engraved_stone') --- Biome IDs -local biome_id_everness_cursed_lands_dunes = minetest.get_biome_id('everness:cursed_lands_dunes') -local biome_id_everness_cursed_lands_swamp = minetest.get_biome_id('everness:cursed_lands_swamp') -local biome_id_everness_cursed_lands_ocean = minetest.get_biome_id('everness:cursed_lands_ocean') -local biome_id_everness_crystal_forest_dunes = minetest.get_biome_id('everness:crystal_forest_dunes') -local biome_id_everness_crystal_forest_shore = minetest.get_biome_id('everness:crystal_forest_shore') -local biome_id_everness_crystal_forest_ocean = minetest.get_biome_id('everness:crystal_forest_ocean') -local water_level = tonumber(minetest.settings:get('water_level')) or 1 local chance = 20 -local chance_sea_level = 10 local disp = 16 +local water_level = tonumber(minetest.settings:get('water_level')) or 1 -- Localize data buffer table outside the loop, to be re-used for all -- mapchunks, therefore minimising memory use. @@ -40,7 +31,9 @@ local p2data = {} minetest.register_on_generated(function(minp, maxp, blockseed) local rand = PcgRandom(blockseed) + -- Array containing the biome IDs of nodes in the most recently generated chunk by the current mapgen local biomemap = minetest.get_mapgen_object('biomemap') + -- Table mapping requested generation notification types to arrays of positions at which the corresponding generated structures are located within the current chunk local gennotify = minetest.get_mapgen_object('gennotify') -- Load the voxelmanip with the result of engine mapgen local vm, emin, emax = minetest.get_mapgen_object('voxelmanip') @@ -49,6 +42,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed) -- Get the content ID data from the voxelmanip in the form of a flat array. -- Set the buffer parameter to use and reuse 'data' for this. vm:get_data(data) + -- Raw `param2` data read into the `VoxelManip` object vm:get_param2_data(p2data) -- Side length of mapchunk local sidelength = maxp.x - minp.x + 1 @@ -57,7 +51,9 @@ minetest.register_on_generated(function(minp, maxp, blockseed) local schem_positions = {} local shared_args = {} + -- -- on_data + -- -- read/write to `data` what will be eventually saved (set_data) -- used for voxelmanip `data` manipulation for _, def in ipairs(Everness.on_generated_queue) do @@ -69,13 +65,16 @@ minetest.register_on_generated(function(minp, maxp, blockseed) end end - -- set data after they have been manipulated (above) + -- set data after they have been manipulated (from above) vm:set_data(data) vm:set_param2_data(p2data) + -- -- after_set_data + -- -- can read (but cant and should not manipulate) voxelmanip `data` - -- used for `place_schematic_on_vmanip` which will invalidate `data` therefore we are doing it after we set the data + -- used for `place_schematic_on_vmanip` which will invalidate `data` + -- therefore we are doing it after we set the data for _, def in ipairs(Everness.on_generated_queue) do if def.can_run(biomemap) and def.after_set_data then shared_args[def.name] = shared_args[def.name] or {} @@ -90,161 +89,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed) if data[vi + area.ystride] == minetest.CONTENT_AIR then local s_pos = area:position(vi) - if maxp.y >= water_level then - -- Above sea level or at water level - if - water_level >= minp.y - and water_level <= maxp.y - and data[vi] == c_water_source - then - -- - -- Water Level - -- - if - ( - table.indexof(biomemap, biome_id_everness_cursed_lands_dunes) ~= -1 - or table.indexof(biomemap, biome_id_everness_cursed_lands_swamp) ~= -1 - or table.indexof(biomemap, biome_id_everness_cursed_lands_ocean) ~= -1 - ) - and rand:next(0, 100) < chance_sea_level - then - local schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_island.mts' - - -- - -- Cursed Lands Deep Ocean Island - -- - - local size = { x = 25, y = 23, z = 23 } - local size_x = math.round(size.x / 2) - local size_z = math.round(size.z / 2) - -- add Y displacement - local y_dis = 7 - local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z) - - -- find floor big enough - local indexes = Everness.find_content_in_vm_area( - vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z), - { - c_water_source, - minetest.CONTENT_AIR - }, - data, - area - ) - - if #indexes < size.x * size.z then - -- not enough space - return - end - - -- enough space to place structure ? - local space_indexes = Everness.find_content_in_vm_area( - vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z), - { - c_water_source, - minetest.CONTENT_AIR - }, - data, - area - ) - - if #space_indexes > (size.x * size.y * size.z) / 2 then - minetest.place_schematic_on_vmanip( - vm, - schem_pos, - schem, - 'random', - nil, - true, - 'place_center_x, place_center_z' - ) - - schem_positions.everness_cursed_lands_deep_ocean_island = schem_positions.everness_cursed_lands_deep_ocean_island or {} - - table.insert(schem_positions.everness_cursed_lands_deep_ocean_island, { - pos = schem_pos, - minp = vector.new(s_pos.x - size_x, s_pos.y - y_dis, s_pos.z - size_z), - maxp = vector.new(s_pos.x + size_x, s_pos.y - y_dis + size.y, s_pos.z + size_z) - }) - - minetest.log('action', '[Everness] Cursed Lands Deep Ocean Island was placed at ' .. schem_pos:to_string()) - end - elseif - ( - table.indexof(biomemap, biome_id_everness_crystal_forest_dunes) ~= -1 - or table.indexof(biomemap, biome_id_everness_crystal_forest_shore) ~= -1 - or table.indexof(biomemap, biome_id_everness_crystal_forest_ocean) ~= -1 - ) - and rand:next(0, 100) < chance_sea_level - then - local schem = minetest.get_modpath('everness') .. '/schematics/everness_crystal_forest_ocean_shrine.mts' - - -- - -- Crystal Forest Ocean Shrine - -- - - local size = { x = 13, y = 16, z = 13 } - local size_x = math.round(size.x / 2) - local size_z = math.round(size.z / 2) - -- add Y displacement - local y_dis = 8 - local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z) - - -- find floor big enough - local indexes = Everness.find_content_in_vm_area( - vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z), - { - c_water_source, - minetest.CONTENT_AIR - }, - data, - area - ) - - if #indexes < size.x * size.z then - -- not enough space - return - end - - -- enough space to place structure ? - local space_indexes = Everness.find_content_in_vm_area( - vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z), - { - c_water_source, - minetest.CONTENT_AIR - }, - data, - area - ) - - if #space_indexes > (size.x * size.y * size.z) / 2 then - minetest.place_schematic_on_vmanip( - vm, - schem_pos, - schem, - 'random', - nil, - true, - 'place_center_x, place_center_z' - ) - - schem_positions.everness_crystal_forest_ocean_shrine = schem_positions.everness_crystal_forest_ocean_shrine or {} - - table.insert(schem_positions.everness_crystal_forest_ocean_shrine, { - pos = schem_pos, - minp = vector.new(s_pos.x - size_x, s_pos.y - y_dis, s_pos.z - size_z), - maxp = vector.new(s_pos.x + size_x, s_pos.y - y_dis + size.y, s_pos.z + size_z) - }) - - minetest.log('action', '[Everness] Crystal Forest Ocean Shrine was placed at ' .. schem_pos:to_string()) - end - end - end - else + if maxp.y < water_level then -- Under sea level (Caves) if ( @@ -342,11 +187,13 @@ minetest.register_on_generated(function(minp, maxp, blockseed) -- Write what has been created to the world. vm:write_to_map() + -- -- after_write_to_map + -- -- Cannot read/write voxelmanip or its data - -- Used for direct manipulation of the world chunk nodes where the definitions of nodes are available and node callback can be executed - - -- minetest.fix_light(minp, maxp) + -- Used for direct manipulation of the world chunk nodes where the + -- definitions of nodes are available and node callback can be executed + -- or e.g. for `minetest.fix_light` for _, def in ipairs(Everness.on_generated_queue) do if def.can_run(biomemap) and def.after_write_to_map then diff --git a/mapgen_coral_forest_dunes.lua b/mapgen_coral_forest_dunes.lua index 741fd87..35518de 100644 --- a/mapgen_coral_forest_dunes.lua +++ b/mapgen_coral_forest_dunes.lua @@ -184,7 +184,7 @@ Everness:register_decoration({ -- local disp = 16 -local chance_sea_level = 10 +local chance = 10 local water_level = tonumber(minetest.settings:get('water_level')) or 1 local schem = minetest.get_modpath('everness') .. '/schematics/everness_coral_forest_ocean_fishing_dock.mts' local size = { x = 26, y = 10, z = 23 } @@ -212,7 +212,7 @@ Everness:add_to_queue_on_generated({ if data[vi + area.ystride] == minetest.CONTENT_AIR and data[vi] == c_water_source - and rand:next(0, 100) < chance_sea_level + and rand:next(0, 100) < chance -- Water Level and water_level >= minp.y and water_level <= maxp.y diff --git a/mapgen_coral_forest_ocean.lua b/mapgen_coral_forest_ocean.lua index da59fcb..68de409 100644 --- a/mapgen_coral_forest_ocean.lua +++ b/mapgen_coral_forest_ocean.lua @@ -165,7 +165,7 @@ Everness:register_decoration({ -- local disp = 16 -local chance_sea_level = 10 +local chance = 10 local water_level = tonumber(minetest.settings:get('water_level')) or 1 local schem = minetest.get_modpath('everness') .. '/schematics/everness_coral_forest_ocean_fishing_dock.mts' local size = { x = 26, y = 10, z = 23 } @@ -193,7 +193,7 @@ Everness:add_to_queue_on_generated({ if data[vi + area.ystride] == minetest.CONTENT_AIR and data[vi] == c_water_source - and rand:next(0, 100) < chance_sea_level + and rand:next(0, 100) < chance -- Water Level and water_level >= minp.y and water_level <= maxp.y diff --git a/mapgen_crystal_forest_dunes.lua b/mapgen_crystal_forest_dunes.lua index ae42a99..eefd776 100644 --- a/mapgen_crystal_forest_dunes.lua +++ b/mapgen_crystal_forest_dunes.lua @@ -145,14 +145,24 @@ Everness:register_decoration({ -- local chance = 20 +local chance_water = 10 local disp = 16 +local water_level = tonumber(minetest.settings:get('water_level')) or 1 + local schem = minetest.read_schematic(minetest.get_modpath('everness') .. '/schematics/everness_quartz_fountain.mts', {}) local size = { x = 11, y = 10, z = 11 } local size_x = math.round(size.x / 2) local size_z = math.round(size.z / 2) local y_dis = 1 +local schem_shrine = minetest.read_schematic(minetest.get_modpath('everness') .. '/schematics/everness_crystal_forest_ocean_shrine.mts', {}) +local size_shrine = { x = 13, y = 16, z = 13 } +local size_x_shrine = math.round(size.x / 2) +local size_z_shrine = math.round(size.z / 2) +local y_dis_shrine = 8 + local c_everness_crystal_sand = minetest.get_content_id('everness:crystal_sand') +local c_water_source = minetest.get_content_id('mapgen_water_source') local biome_id_everness_crystal_forest_dunes = minetest.get_biome_id('everness:crystal_forest_dunes') @@ -170,70 +180,137 @@ Everness:add_to_queue_on_generated({ for y = minp.y, maxp.y do local vi = area:index(minp.x + sidelength / 2 + x_disp, y, minp.z + sidelength / 2 + z_disp) - if data[vi + area.ystride] == minetest.CONTENT_AIR - and data[vi] == c_everness_crystal_sand - and rand:next(0, 100) < chance - then + if data[vi + area.ystride] == minetest.CONTENT_AIR then local s_pos = area:position(vi) - -- - -- Quartz Fountain - -- + if + data[vi] == c_everness_crystal_sand + and rand:next(0, 100) < chance + then + -- + -- Quartz Fountain + -- - -- add Y displacement - local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z) + -- add Y displacement + local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z) - -- find floor big enough - local positions = minetest.find_nodes_in_area_under_air( - vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z), - { - 'everness:crystal_sand' - } - ) - - if #positions < size.x * size.z then - -- not enough space - return - end - - -- enough air to place structure ? - local air_positions = minetest.find_nodes_in_area( - vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z), - { - 'air' - } - ) - - local replacements - - if rand:next(0, 100) < 50 then - replacements = { - ['everness:chest'] = 'everness:quartz_pillar' - } - end - - if #air_positions > (size.x * size.y * size.z) / 2 then - minetest.place_schematic_on_vmanip( - vm, - schem_pos, - schem, - 'random', - replacements, - true, - 'place_center_x, place_center_z' + -- find floor big enough + local positions = minetest.find_nodes_in_area_under_air( + vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z), + vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z), + { + 'everness:crystal_sand' + } ) - shared_args.schem_positions.everness_quartz_fountain = shared_args.schem_positions.everness_quartz_fountain or {} + if #positions < size.x * size.z then + -- not enough space + return + end - table.insert(shared_args.schem_positions.everness_quartz_fountain, { - pos = schem_pos, - minp = vector.new(s_pos.x - size_x, s_pos.y - y_dis, s_pos.z - size_z), - maxp = vector.new(s_pos.x + size_x, s_pos.y - y_dis + size.y, s_pos.z + size_z) - }) + -- enough air to place structure ? + local air_positions = minetest.find_nodes_in_area( + vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), + vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z), + { + 'air' + } + ) - minetest.log('action', '[Everness] Quartz Fountain was placed at ' .. schem_pos:to_string()) + local replacements + + if rand:next(0, 100) < 50 then + replacements = { + ['everness:chest'] = 'everness:quartz_pillar' + } + end + + if #air_positions > (size.x * size.y * size.z) / 2 then + minetest.place_schematic_on_vmanip( + vm, + schem_pos, + schem, + 'random', + replacements, + true, + 'place_center_x, place_center_z' + ) + + shared_args.schem_positions.everness_quartz_fountain = shared_args.schem_positions.everness_quartz_fountain or {} + + table.insert(shared_args.schem_positions.everness_quartz_fountain, { + pos = schem_pos, + minp = vector.new(s_pos.x - size_x, s_pos.y - y_dis, s_pos.z - size_z), + maxp = vector.new(s_pos.x + size_x, s_pos.y - y_dis + size.y, s_pos.z + size_z) + }) + + minetest.log('action', '[Everness] Quartz Fountain was placed at ' .. schem_pos:to_string()) + end + end + + if data[vi] == c_water_source + and rand:next(0, 100) < chance_water + -- Water Level + and water_level >= minp.y + and water_level <= maxp.y + then + -- + -- Crystal Forest Ocean Shrine + -- + + -- add Y displacement + local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis_shrine, s_pos.z) + + -- find floor big enough + local indexes = Everness.find_content_in_vm_area( + vector.new(s_pos.x - size_x_shrine, s_pos.y - 1, s_pos.z - size_z_shrine), + vector.new(s_pos.x + size_x_shrine, s_pos.y + 1, s_pos.z + size_z_shrine), + { + c_water_source, + minetest.CONTENT_AIR + }, + data, + area + ) + + if #indexes < size_shrine.x * size_shrine.z then + -- not enough space + return + end + + -- enough space to place structure ? + local space_indexes = Everness.find_content_in_vm_area( + vector.new(s_pos.x - size_x_shrine, s_pos.y, s_pos.z - size_z_shrine), + vector.new(s_pos.x + size_x_shrine, s_pos.y + size_shrine.y, s_pos.z + size_z_shrine), + { + c_water_source, + minetest.CONTENT_AIR + }, + data, + area + ) + + if #space_indexes > (size_shrine.x * size_shrine.y * size_shrine.z) / 2 then + minetest.place_schematic_on_vmanip( + vm, + schem_pos, + schem_shrine, + 'random', + nil, + true, + 'place_center_x, place_center_z' + ) + + shared_args.schem_positions.everness_crystal_forest_ocean_shrine = shared_args.schem_positions.everness_crystal_forest_ocean_shrine or {} + + table.insert(shared_args.schem_positions.everness_crystal_forest_ocean_shrine, { + pos = schem_pos, + minp = vector.new(s_pos.x - size_x_shrine, s_pos.y - y_dis_shrine, s_pos.z - size_z_shrine), + maxp = vector.new(s_pos.x + size_x_shrine, s_pos.y - y_dis_shrine + size_shrine.y, s_pos.z + size_z_shrine) + }) + + minetest.log('action', '[Everness] Crystal Forest Ocean Shrine was placed at ' .. schem_pos:to_string()) + end end end end diff --git a/mapgen_cursed_lands_deep_ocean.lua b/mapgen_cursed_lands_deep_ocean.lua index 75f1704..fbfaea2 100644 --- a/mapgen_cursed_lands_deep_ocean.lua +++ b/mapgen_cursed_lands_deep_ocean.lua @@ -193,7 +193,7 @@ local biome_id_everness_cursed_lands_deep_ocean = minetest.get_biome_id('evernes -- Localize data buffer table outside the loop, to be re-used for all -- mapchunks, therefore minimising memory use. local data = {} -local chance = 30 +local chance = 20 local schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_skull.mts' local size = { x = 10, y = 11, z = 11 } local size_x = math.round(size.x / 2) diff --git a/mapgen_cursed_lands_dunes.lua b/mapgen_cursed_lands_dunes.lua index 6728169..fcfa2fc 100644 --- a/mapgen_cursed_lands_dunes.lua +++ b/mapgen_cursed_lands_dunes.lua @@ -167,13 +167,23 @@ Everness:register_decoration({ -- local chance = 30 +local chance_water = 10 local disp = 16 -local schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_cabin.mts' +local water_level = tonumber(minetest.settings:get('water_level')) or 1 + +local schem_cursed_cabin = minetest.get_modpath('everness') .. '/schematics/everness_cursed_cabin.mts' local size = { x = 7, y = 7, z = 12 } local size_x = math.round(size.x / 2) local size_z = math.round(size.z / 2) +local schem_ocean_island = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_island.mts' +local size_ocean_island = { x = 25, y = 23, z = 23 } +local size_x_ocean_island = math.round(size.x / 2) +local size_z_ocean_island = math.round(size.z / 2) +local y_dis_ocean_island = 7 + local c_cursed_sand = minetest.get_content_id('everness:cursed_sand') +local c_water_source = minetest.get_content_id('mapgen_water_source') local biome_id_everness_cursed_lands_dunes = minetest.get_biome_id('everness:cursed_lands_dunes') @@ -191,62 +201,127 @@ Everness:add_to_queue_on_generated({ for y = minp.y, maxp.y do local vi = area:index(minp.x + sidelength / 2 + x_disp, y, minp.z + sidelength / 2 + z_disp) - if data[vi + area.ystride] == minetest.CONTENT_AIR - and data[vi] == c_cursed_sand - and rand:next(0, 100) < chance - then + if data[vi + area.ystride] == minetest.CONTENT_AIR then local s_pos = area:position(vi) - -- - -- Cursed Cabin - -- + if data[vi] == c_cursed_sand + and rand:next(0, 100) < chance + then + -- + -- Cursed Cabin + -- - -- add Y displacement - local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z) + -- add Y displacement + local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z) - -- find floor big enough - local positions = minetest.find_nodes_in_area_under_air( - vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z), - { - 'everness:cursed_sand' - } - ) - - if #positions < size.x * size.z then - -- not enough space - return - end - - -- enough air to place structure ? - local air_positions = minetest.find_nodes_in_area( - vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), - vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z), - { - 'air' - } - ) - - if #air_positions > (size.x * size.y * size.z) / 2 then - minetest.place_schematic_on_vmanip( - vm, - schem_pos, - schem, - 'random', - nil, - true, - 'place_center_x, place_center_z' + -- find floor big enough + local positions = minetest.find_nodes_in_area_under_air( + vector.new(s_pos.x - size_x, s_pos.y - 1, s_pos.z - size_z), + vector.new(s_pos.x + size_x, s_pos.y + 1, s_pos.z + size_z), + { + 'everness:cursed_sand' + } ) - shared_args.schem_positions.everness_cursed_cabin = shared_args.schem_positions.everness_cursed_cabin or {} + if #positions < size.x * size.z then + -- not enough space + return + end - table.insert(shared_args.schem_positions.everness_cursed_cabin, { - pos = schem_pos, - minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), - maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z) - }) + -- enough air to place structure ? + local air_positions = minetest.find_nodes_in_area( + vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), + vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z), + { + 'air' + } + ) - minetest.log('action', '[Everness] Cursed Cabin was placed at ' .. schem_pos:to_string()) + if #air_positions > (size.x * size.y * size.z) / 2 then + minetest.place_schematic_on_vmanip( + vm, + schem_pos, + schem_cursed_cabin, + 'random', + nil, + true, + 'place_center_x, place_center_z' + ) + + shared_args.schem_positions.everness_cursed_cabin = shared_args.schem_positions.everness_cursed_cabin or {} + + table.insert(shared_args.schem_positions.everness_cursed_cabin, { + pos = schem_pos, + minp = vector.new(s_pos.x - size_x, s_pos.y, s_pos.z - size_z), + maxp = vector.new(s_pos.x + size_x, s_pos.y + size.y, s_pos.z + size_z) + }) + + minetest.log('action', '[Everness] Cursed Cabin was placed at ' .. schem_pos:to_string()) + end + end + + if data[vi] == c_water_source + and rand:next(0, 100) < chance_water + -- Water Level + and water_level >= minp.y + and water_level <= maxp.y + then + -- + -- Cursed Lands Deep Ocean Island + -- + + local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis_ocean_island, s_pos.z) + + -- find floor big enough + local indexes = Everness.find_content_in_vm_area( + vector.new(s_pos.x - size_x_ocean_island, s_pos.y - 1, s_pos.z - size_z), + vector.new(s_pos.x + size_x_ocean_island, s_pos.y + 1, s_pos.z + size_z), + { + c_water_source, + minetest.CONTENT_AIR + }, + data, + area + ) + + if #indexes < size_ocean_island.x * size_ocean_island.z then + -- not enough space + return + end + + -- enough space to place structure ? + local space_indexes = Everness.find_content_in_vm_area( + vector.new(s_pos.x - size_x_ocean_island, s_pos.y, s_pos.z - size_z_ocean_island), + vector.new(s_pos.x + size_x_ocean_island, s_pos.y + size_ocean_island.y, s_pos.z + size_z_ocean_island), + { + c_water_source, + minetest.CONTENT_AIR + }, + data, + area + ) + + if #space_indexes > (size_ocean_island.x * size_ocean_island.y * size_ocean_island.z) / 2 then + minetest.place_schematic_on_vmanip( + vm, + schem_pos, + schem_ocean_island, + 'random', + nil, + true, + 'place_center_x, place_center_z' + ) + + shared_args.schem_positions.everness_cursed_lands_deep_ocean_island = shared_args.schem_positions.everness_cursed_lands_deep_ocean_island or {} + + table.insert(shared_args.schem_positions.everness_cursed_lands_deep_ocean_island, { + pos = schem_pos, + minp = vector.new(s_pos.x - size_x_ocean_island, s_pos.y - y_dis_ocean_island, s_pos.z - size_z_ocean_island), + maxp = vector.new(s_pos.x + size_x_ocean_island, s_pos.y - y_dis_ocean_island + size_ocean_island.y, s_pos.z + size_z_ocean_island) + }) + + minetest.log('action', '[Everness] Cursed Lands Deep Ocean Island was placed at ' .. schem_pos:to_string()) + end end end end diff --git a/mapgen_forsaken_desert_ocean.lua b/mapgen_forsaken_desert_ocean.lua index 9154138..2d9cb2c 100644 --- a/mapgen_forsaken_desert_ocean.lua +++ b/mapgen_forsaken_desert_ocean.lua @@ -44,7 +44,6 @@ Everness:register_biome({ humidity_point = 30, }) - -- -- On Generated --