Move giant sequoia, jungle temple, mineral waters tower, fix fixlight in queue

This commit is contained in:
Juraj Vajda 2024-02-07 14:45:09 -05:00
parent 466cfd4258
commit aadd829ae2
10 changed files with 2452 additions and 2366 deletions

36
api.lua
View File

@ -1142,24 +1142,28 @@ function Everness.set_loot_chest_items()
Everness.loot_chest.default = table.copy(loot_items) Everness.loot_chest.default = table.copy(loot_items)
end end
function Everness.populate_loot_chests(self, positions, loot_chest_items_group) function Everness.populate_loot_chests(self, positions, params)
local _loot_chest_items_group = loot_chest_items_group or 'default' local _params = params or {}
local _loot_chest_items_group = _params.loot_chest_items_group or 'default'
-- Get inventories -- Get inventories
local string_positions = ''; local string_positions = '';
local inventories = {} local inventories = {}
for i, pos in ipairs(positions) do for i, pos in ipairs(positions) do
local inv = minetest.get_inventory({ type = 'node', pos = pos })
if not inv then
local chest_def = minetest.registered_nodes['everness:chest'] local chest_def = minetest.registered_nodes['everness:chest']
chest_def.on_construct(pos) chest_def.on_construct(pos)
inv = minetest.get_inventory({ type = 'node', pos = pos })
local inv = minetest.get_inventory({ type = 'node', pos = pos }) end
if inv then if inv then
table.insert(inventories, inv) table.insert(inventories, inv)
string_positions = string_positions .. ' ' .. pos:to_string() string_positions = string_positions .. ' ' .. pos:to_string()
else else
minetest.log('action', '[Everness] FAILED to populate loot chests inventory at ' .. pos:to_string()) minetest.log('warning', '[Everness] FAILED to populate loot chests inventory at ' .. pos:to_string())
end end
end end
@ -2119,6 +2123,28 @@ function Everness.find_content_in_vm_area(minp, maxp, contentIds, data, area)
return indexes, id_count return indexes, id_count
end end
function Everness.find_content_under_air_in_vm_area(minp, maxp, contentIds, data, area)
local indexes = {}
local id_count = {}
for y = minp.y, maxp.y do
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local ai = area:index(x, y, z)
if table.indexof(contentIds, data[ai]) ~= -1
and data[ai + area.ystride] == minetest.CONTENT_AIR
then
id_count[data[ai]] = (id_count[data[ai]] or 0) + 1
table.insert(indexes, ai)
end
end
end
end
return indexes, id_count
end
function Everness.add_to_queue_on_generated(self, def) function Everness.add_to_queue_on_generated(self, def)
if type(def) ~= 'table' then if type(def) ~= 'table' then

File diff suppressed because it is too large Load Diff

View File

@ -16,15 +16,10 @@
-- Get the content IDs for the nodes used. -- Get the content IDs for the nodes used.
local c_water_source = minetest.get_content_id('mapgen_water_source') local c_water_source = minetest.get_content_id('mapgen_water_source')
local c_dirt_with_rainforest_litter = minetest.get_content_id('default:dirt_with_rainforest_litter')
local c_dirt_with_snow = minetest.get_content_id('default:dirt_with_snow')
local c_dirt_with_coniferous_litter = minetest.get_content_id('default:dirt_with_coniferous_litter')
local c_forsaken_desert_sand = minetest.get_content_id('everness:forsaken_desert_sand') 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_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_brick = minetest.get_content_id('everness:forsaken_desert_brick')
local c_forsaken_desert_engraved_stone = minetest.get_content_id('everness:forsaken_desert_engraved_stone') local c_forsaken_desert_engraved_stone = minetest.get_content_id('everness:forsaken_desert_engraved_stone')
local c_everness_mineral_water_source = minetest.get_content_id('everness:mineral_water_source')
local c_everness_mineral_sand = minetest.get_content_id('everness:mineral_sand')
-- Biome IDs -- Biome IDs
local biome_id_everness_cursed_lands_dunes = minetest.get_biome_id('everness:cursed_lands_dunes') 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_swamp = minetest.get_biome_id('everness:cursed_lands_swamp')
@ -34,131 +29,9 @@ local biome_id_everness_crystal_forest_shore = minetest.get_biome_id('everness:c
local biome_id_everness_crystal_forest_ocean = minetest.get_biome_id('everness:crystal_forest_ocean') 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 water_level = tonumber(minetest.settings:get('water_level')) or 1
-- MTG
local chance = 20 local chance = 20
local chance_sea_level = 10 local chance_sea_level = 10
local disp = 16 local disp = 16
local schem_jungle_temple = minetest.get_modpath('everness') .. '/schematics/everness_jungle_temple.mts'
local size_jungle_temple = { x = 12, y = 14, z = 15 }
local size_jungle_temple_x = math.round(size_jungle_temple.x / 2)
local size_jungle_temple_z = math.round(size_jungle_temple.z / 2)
local y_dis_jungle_temple = 3
local biome_id_rainforest = minetest.get_biome_id('rainforest')
local biome_id_rainforest_swamp = minetest.get_biome_id('rainforest_swamp')
Everness:add_to_queue_on_generated({
name = 'default:rainforest_and_rainforest_swamp',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_rainforest) ~= -1
or table.indexof(biomemap, biome_id_rainforest_swamp) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
local sidelength = maxp.x - minp.x + 1
local x_disp = rand:next(0, disp)
local z_disp = rand:next(0, disp)
shared_args.schem_positions = {}
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_dirt_with_rainforest_litter
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)
--
-- Jungle Temple
--
-- add Y displacement
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis_jungle_temple, s_pos.z)
-- find floor big enough
local positions = minetest.find_nodes_in_area_under_air(
vector.new(s_pos.x - size_jungle_temple_x, s_pos.y - 1, s_pos.z - size_jungle_temple_z),
vector.new(s_pos.x + size_jungle_temple_x, s_pos.y + 1, s_pos.z + size_jungle_temple_z),
{
'default:dirt_with_rainforest_litter'
}
)
-- Can force over these blocks
local force_positions = minetest.find_nodes_in_area(
vector.new(s_pos.x - size_jungle_temple_x, s_pos.y - 1, s_pos.z - size_jungle_temple_z),
vector.new(s_pos.x + size_jungle_temple_x, s_pos.y + 1, s_pos.z + size_jungle_temple_z),
{
'group:tree',
'group:flower',
'group:flora',
'group:leaves',
'fireflies:firefly',
'fireflies:hidden_firefly',
}
)
if #positions + #force_positions < size_jungle_temple.x * size_jungle_temple.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_jungle_temple_x, s_pos.y, s_pos.z - size_jungle_temple_z),
vector.new(s_pos.x + size_jungle_temple_x, s_pos.y + size_jungle_temple.y, s_pos.z + size_jungle_temple_z),
{
'air',
'group:tree',
'group:flora',
'group:leaves'
}
)
if #air_positions > (size_jungle_temple.x * size_jungle_temple.y * size_jungle_temple.z) / 2 then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
schem_jungle_temple,
'random',
nil,
true,
'place_center_x, place_center_z'
)
shared_args.schem_positions.everness_jungle_temple = shared_args.schem_positions.everness_jungle_temple or {}
table.insert(shared_args.schem_positions.everness_jungle_temple, {
pos = schem_pos,
minp = vector.new(s_pos.x - size_jungle_temple_x, s_pos.y - y_dis_jungle_temple, s_pos.z - size_jungle_temple_z),
maxp = vector.new(s_pos.x + size_jungle_temple_x, s_pos.y - y_dis_jungle_temple + size_jungle_temple.y, s_pos.z + size_jungle_temple_z)
})
minetest.log('action', '[Everness] Jungle Temple was placed at ' .. schem_pos:to_string())
end
end
end
end,
after_write_to_map = function(shared_args)
local schem_positions = shared_args.schem_positions or {}
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions > 0 then
Everness:populate_loot_chests(chest_positions)
end
end
end
end
end
})
-- Localize data buffer table outside the loop, to be re-used for all -- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use. -- mapchunks, therefore minimising memory use.
@ -220,121 +93,6 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
if maxp.y >= water_level then if maxp.y >= water_level then
-- Above sea level or at water level -- Above sea level or at water level
if if
(
data[vi] == c_dirt_with_snow
or data[vi] == c_dirt_with_coniferous_litter
)
and rand:next(0, 100) < 100
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_giant_sequoia_tree.mts'
--
-- Giant Sequoia
--
local size = { x = 25, y = 75, z = 25 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
minetest.emerge_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),
function(blockpos, action, calls_remaining, param)
Everness:emerge_area(blockpos, action, calls_remaining, param)
end,
{
callback = function()
-- 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),
{
'default:dirt_with_snow',
'default:dirt_with_coniferous_litter',
'default:snow'
})
if #positions < size.x * size.z then
-- not enough space
return
end
minetest.place_schematic(
schem_pos,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
minetest.log('action', '[Everness] Giant Sequoia was placed at ' .. schem_pos:to_string())
end
}
)
elseif
(
data[vi] == c_everness_mineral_water_source
or data[vi] == c_everness_mineral_sand
)
and rand:next(0, 100) < chance
then
local schem = minetest.get_modpath('everness') .. '/schematics/everness_mineral_waters_tower.mts'
--
-- Mineral Waters Tower
--
local size = { x = 7, y = 16, z = 9 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local schem_pos = vector.new(s_pos)
-- 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:mineral_sand',
'everness:mineral_water_source'
}
)
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'
)
schem_positions.everness_mineral_waters_tower = schem_positions.everness_mineral_waters_tower or {}
table.insert(schem_positions.everness_mineral_waters_tower, {
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] Mineral Waters Tower was placed at ' .. schem_pos:to_string())
end
elseif
water_level >= minp.y water_level >= minp.y
and water_level <= maxp.y and water_level <= maxp.y
and data[vi] == c_water_source and data[vi] == c_water_source
@ -594,7 +352,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
if def.can_run(biomemap) and def.after_write_to_map then if def.can_run(biomemap) and def.after_write_to_map then
shared_args[def.name] = shared_args[def.name] or {} shared_args[def.name] = shared_args[def.name] or {}
-- print('after_write_to_map', def.name, minp:to_string(), maxp:to_string()) -- print('after_write_to_map', def.name, minp:to_string(), maxp:to_string())
def.after_write_to_map(shared_args[def.name]) def.after_write_to_map(shared_args[def.name], gennotify)
end end
end end

View File

@ -172,6 +172,24 @@ register_dry_grass_decoration(0.07, -0.01, 1)
-- On Generated -- On Generated
-- --
local disp = 16
local chance = 100
local schem = minetest.get_modpath('everness') .. '/schematics/everness_giant_sequoia_tree.mts'
local size = { x = 25, y = 75, z = 25 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local baobab_tree_size = { x = 24, y = 39, z = 24 }
local baobab_tree_size_x = math.round(size.x / 2)
local baobab_tree_size_z = math.round(size.z / 2)
local c_everness_dry_dirt_with_dry_grass = minetest.get_content_id('everness:dry_dirt_with_dry_grass')
local c_everness_dry_dirt = minetest.get_content_id('everness:dry_dirt')
local c_everness_dry_grass_1 = minetest.get_content_id('everness:dry_grass_1')
local c_everness_dry_grass_2 = minetest.get_content_id('everness:dry_grass_2')
local c_everness_dry_grass_3 = minetest.get_content_id('everness:dry_grass_3')
local c_everness_dry_grass_4 = minetest.get_content_id('everness:dry_grass_4')
local biome_id_baobab_savanna = minetest.get_biome_id('everness:baobab_savanna') local biome_id_baobab_savanna = minetest.get_biome_id('everness:baobab_savanna')
local deco_ids_baobab = { local deco_ids_baobab = {
@ -188,13 +206,83 @@ Everness:add_to_queue_on_generated({
can_run = function(biomemap) can_run = function(biomemap)
return table.indexof(biomemap, biome_id_baobab_savanna) ~= -1 return table.indexof(biomemap, biome_id_baobab_savanna) ~= -1
end, end,
on_data = function(minp, maxp, area, data, p2data, gennotify, rand) after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
local sidelength = maxp.x - minp.x + 1
local x_disp = rand:next(0, disp)
local z_disp = rand:next(0, disp)
shared_args.schem_positions = {}
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
or data[vi + area.ystride] == c_everness_dry_grass_1
or data[vi + area.ystride] == c_everness_dry_grass_2
or data[vi + area.ystride] == c_everness_dry_grass_3
or data[vi + area.ystride] == c_everness_dry_grass_4
)
and (
data[vi] == c_everness_dry_dirt_with_dry_grass
or data[vi] == c_everness_dry_dirt
)
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)
--
-- Giant Sequoia
--
minetest.emerge_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),
function(blockpos, action, calls_remaining, param)
Everness:emerge_area(blockpos, action, calls_remaining, param)
end,
{
callback = function()
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:dry_dirt_with_dry_grass',
'everness:dry_dirt',
'group:flora',
'group:flower'
})
if #positions < size.x * size.z then
-- not enough space
return
end
minetest.place_schematic(
s_pos,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
minetest.log('action', '[Everness] Giant Sequoia was placed at ' .. s_pos:to_string())
end
}
)
end
end
end,
after_write_to_map = function(shared_args, gennotify)
-- --
-- Baobab Tree - fix light -- Baobab Tree - fix light
-- --
for _, deco_id in ipairs(deco_ids_baobab) do for _, deco_id in ipairs(deco_ids_baobab) do
for _, pos in ipairs(gennotify['decoration#' .. (deco_id or '')] or {}) do for _, pos in ipairs(gennotify['decoration#' .. (deco_id or '')] or {}) do
minetest.fix_light(vector.offset(pos, -1, -1, -1), vector.offset(pos, 24, 39, 24)) minetest.fix_light(
vector.new(pos.x - baobab_tree_size_x, pos.y - 1, pos.z - baobab_tree_size_z),
vector.new(pos.x + baobab_tree_size_x, pos.y + baobab_tree_size.y, pos.z + baobab_tree_size_z)
)
end end
end end
end end

View File

@ -269,7 +269,7 @@ Everness:add_to_queue_on_generated({
can_run = function(biomemap) can_run = function(biomemap)
return table.indexof(biomemap, biome_id_coral_forest) ~= -1 return table.indexof(biomemap, biome_id_coral_forest) ~= -1
end, end,
on_data = function(minp, maxp, area, data, p2data, gennotify, rand, shared_args) after_write_to_map = function(shared_args, gennotify)
-- --
-- Coral bone tree - fix light -- Coral bone tree - fix light
-- --

View File

@ -152,7 +152,7 @@ local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2) local size_z = math.round(size.z / 2)
local y_dis = 1 local y_dis = 1
local c_crystal_sand = minetest.get_content_id('everness:crystal_sand') local c_everness_crystal_sand = minetest.get_content_id('everness:crystal_sand')
local biome_id_everness_crystal_forest_dunes = minetest.get_biome_id('everness:crystal_forest_dunes') local biome_id_everness_crystal_forest_dunes = minetest.get_biome_id('everness:crystal_forest_dunes')
@ -171,7 +171,7 @@ Everness:add_to_queue_on_generated({
local vi = area:index(minp.x + sidelength / 2 + x_disp, y, minp.z + sidelength / 2 + z_disp) 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 if data[vi + area.ystride] == minetest.CONTENT_AIR
and data[vi] == c_crystal_sand and data[vi] == c_everness_crystal_sand
and rand:next(0, 100) < chance and rand:next(0, 100) < chance
then then
local s_pos = area:position(vi) local s_pos = area:position(vi)

View File

@ -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 -- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use. -- mapchunks, therefore minimising memory use.
local data = {} local data = {}
local chance = 25 local chance = 30
local schem = minetest.get_modpath('everness') .. '/schematics/everness_cursed_lands_deep_ocean_skull.mts' 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 = 10, y = 11, z = 11 }
local size_x = math.round(size.x / 2) local size_x = math.round(size.x / 2)

View File

@ -246,3 +246,123 @@ Everness:register_decoration({
decoration = 'everness:bloodspore_plant', decoration = 'everness:bloodspore_plant',
param2 = 8, param2 = 8,
}) })
--
-- On Generated
--
local chance = 20
local disp = 16
local schem = minetest.read_schematic(minetest.get_modpath('everness') .. '/schematics/everness_jungle_temple.mts', {})
local size = { x = 12, y = 14, z = 15 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local y_dis = 3
local c_everness_forsaken_tundra_dirt = minetest.get_content_id('everness:forsaken_tundra_dirt')
local c_everness_forsaken_tundra_dirt_with_grass = minetest.get_content_id('everness:forsaken_tundra_dirt_with_grass')
local c_everness_volcanic_sulfur = minetest.get_content_id('everness:volcanic_sulfur')
local biome_id_everness_forsaken_tundra = minetest.get_biome_id('everness:forsaken_tundra')
Everness:add_to_queue_on_generated({
name = 'everness:forsaken_tundra',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_forsaken_tundra) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
local sidelength = maxp.x - minp.x + 1
local x_disp = rand:next(0, disp)
local z_disp = rand:next(0, disp)
shared_args.schem_positions = {}
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_forsaken_tundra_dirt
or data[vi] == c_everness_forsaken_tundra_dirt_with_grass
or data[vi] == c_everness_volcanic_sulfur
)
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)
--
-- Jungle Temple
--
-- 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:forsaken_tundra_dirt',
'everness:forsaken_tundra_dirt_with_grass',
'everness:volcanic_sulfur'
}
)
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'
)
shared_args.schem_positions.everness_jungle_temple = shared_args.schem_positions.everness_jungle_temple or {}
table.insert(shared_args.schem_positions.everness_jungle_temple, {
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] Jungle Temple was placed at ' .. schem_pos:to_string())
end
end
end
end,
after_write_to_map = function(shared_args)
local schem_positions = shared_args.schem_positions or {}
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions > 0 then
Everness:populate_loot_chests(chest_positions)
end
end
end
end
end
})

View File

@ -239,6 +239,13 @@ local c_water_weeds = {
c_everness_mineral_water_weed_2 c_everness_mineral_water_weed_2
} }
local chance = 20
local disp = 16
local schem = minetest.get_modpath('everness') .. '/schematics/everness_mineral_waters_tower.mts'
local size = { x = 7, y = 16, z = 9 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local function find_irecursive(table, c_id) local function find_irecursive(table, c_id)
local found = false local found = false
@ -587,14 +594,14 @@ Everness:add_to_queue_on_generated({
for j = -radius, radius do for j = -radius, radius do
local idx = ai + i + (area.zstride * j) + area.ystride local idx = ai + i + (area.zstride * j) + area.ystride
local distance = math.round(vector.distance(area:position(ai), area:position(idx))) local distance = math.round(vector.distance(area:position(ai), area:position(idx)))
local chance = math.round(chance_max / distance) local chance_lotus_leaf = math.round(chance_max / distance)
if chance > chance_max then if chance_lotus_leaf > chance_max then
chance = chance_max chance_lotus_leaf = chance_max
end end
if if
rand:next(0, 100) < chance rand:next(0, 100) < chance_lotus_leaf
and data[idx] == minetest.CONTENT_AIR and data[idx] == minetest.CONTENT_AIR
and data[idx - area.ystride] == c_everness_mineral_water_source and data[idx - area.ystride] == c_everness_mineral_water_source
then then
@ -708,6 +715,75 @@ Everness:add_to_queue_on_generated({
shared_args.pot_pos = pot_pos shared_args.pot_pos = pot_pos
end, end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args) after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
local sidelength = maxp.x - minp.x + 1
local x_disp = rand:next(0, disp)
local z_disp = rand:next(0, disp)
shared_args.schem_positions = {}
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_mineral_water_source
or data[vi] == c_everness_mineral_sand
)
and rand:next(0, 100) < chance
then
local s_pos = area:position(vi)
--
-- Mineral Waters Tower
--
-- 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:mineral_sand',
'everness:mineral_water_source'
}
)
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,
s_pos,
schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
shared_args.schem_positions.everness_mineral_waters_tower = shared_args.schem_positions.everness_mineral_waters_tower or {}
table.insert(shared_args.schem_positions.everness_mineral_waters_tower, {
pos = s_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] Mineral Waters Tower was placed at ' .. s_pos:to_string())
end
end
end
-- --
-- Place Decorations -- Place Decorations
-- --
@ -809,10 +885,28 @@ Everness:add_to_queue_on_generated({
after_write_to_map = function(shared_args) after_write_to_map = function(shared_args)
-- Populate loot chest inventory -- Populate loot chest inventory
local chest_positions = shared_args.chest_positions or {} local chest_positions = shared_args.chest_positions or {}
local chest_def = minetest.registered_nodes['everness:chest']
if chest_def and next(chest_positions) then if next(chest_positions) then
Everness:populate_loot_chests(chest_positions) Everness:populate_loot_chests(chest_positions)
end end
-- Populate loot chest inventory for schematics
local schem_positions = shared_args.schem_positions or {}
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
local chest_positions2 = minetest.find_nodes_in_area(
v.minp,
v.maxp,
{ 'everness:chest' }
)
if #chest_positions2 > 0 then
Everness:populate_loot_chests(chest_positions2)
end
end
end
end
end end
}) })