Move the rest

This commit is contained in:
Juraj Vajda 2024-02-08 14:14:39 -05:00
parent b18e746ead
commit 70a9617c8e
12 changed files with 38666 additions and 38625 deletions

File diff suppressed because it is too large Load Diff

View File

@ -321,121 +321,115 @@ local c_everness_coral_forest_deep_ocean_coral_4 = minetest.get_content_id('ever
-- Biome IDs
local biome_id_everness_coral_forest_deep_ocean = minetest.get_biome_id('everness:coral_forest_deep_ocean')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 25
local chance = 30
local schem = minetest.get_modpath('everness') .. '/schematics/everness_coral_forest_deep_ocean_house.mts'
local size = { x = 11, y = 17, z = 12 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
local schem_positions = {}
local schem_placed = false
Everness:add_to_queue_on_generated({
name = 'everness:coral_forest_deep_ocean',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_coral_forest_deep_ocean) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
shared_args.schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_coral_forest_deep_ocean) ~= -1 and rand:next(0, 100) < chance then
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- 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)
if rand:next(0, 100) < chance then
for y = maxp.y, minp.y, -1 do
if schem_placed then
break
end
for y = maxp.y, minp.y, -1 do
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local vi = area:index(x, y, z)
for z = minp.z, maxp.z do
if schem_placed then
break
end
if
data[vi] == c_everness_coral_forest_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
and not schem_placed
then
local s_pos = area:position(vi)
for x = minp.x, maxp.x do
local vi = area:index(x, y, z)
--
-- Coral Forest Deep Ocean House
--
if
data[vi] == c_everness_coral_forest_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
then
local s_pos = area:position(vi)
local schem_pos = vector.new(s_pos)
--
-- Coral Forest Deep Ocean House
--
-- 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_everness_coral_forest_deep_ocean_sand,
c_everness_coral_forest_deep_ocean_coral_plant_1,
c_everness_coral_forest_deep_ocean_coral_plant_2,
c_everness_coral_forest_deep_ocean_coral_plant_3,
c_everness_coral_forest_deep_ocean_coral_1,
c_everness_coral_forest_deep_ocean_coral_2,
c_everness_coral_forest_deep_ocean_coral_3,
c_everness_coral_forest_deep_ocean_coral_4
},
data,
area
)
local schem_pos = vector.new(s_pos)
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough water to place structure ?
local water_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
},
data,
area
)
if #water_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'
-- 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_everness_coral_forest_deep_ocean_sand,
c_everness_coral_forest_deep_ocean_coral_plant_1,
c_everness_coral_forest_deep_ocean_coral_plant_2,
c_everness_coral_forest_deep_ocean_coral_plant_3,
c_everness_coral_forest_deep_ocean_coral_1,
c_everness_coral_forest_deep_ocean_coral_2,
c_everness_coral_forest_deep_ocean_coral_3,
c_everness_coral_forest_deep_ocean_coral_4
},
data,
area
)
schem_placed = true
if #indexes < size.x * size.z then
-- not enough space
return
end
schem_positions.everness_coral_forest_deep_ocean_house = schem_positions.everness_coral_forest_deep_ocean_house or {}
-- enough water to place structure ?
local water_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
},
data,
area
)
table.insert(schem_positions.everness_coral_forest_deep_ocean_house, {
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)
})
if #water_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'
)
minetest.log('action', '[Everness] Coral Forest Deep Ocean House was placed at ' .. schem_pos:to_string())
schem_placed = true
shared_args.schem_positions.everness_coral_forest_deep_ocean_house = shared_args.schem_positions.everness_coral_forest_deep_ocean_house or {}
table.insert(shared_args.schem_positions.everness_coral_forest_deep_ocean_house, {
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] Coral Forest Deep Ocean House was placed at ' .. schem_pos:to_string())
break
end
end
end
end
end
end
end,
after_write_to_map = function(shared_args)
local schem_positions = shared_args.schem_positions or {}
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
@ -452,4 +446,4 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
end
end
end)
})

View File

@ -184,7 +184,7 @@ Everness:register_decoration({
--
local disp = 16
local chance = 10
local chance = 5
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 }
@ -207,73 +207,76 @@ Everness:add_to_queue_on_generated({
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 rand:next(0, 100) < chance then
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_water_source
and rand:next(0, 100) < chance
-- Water Level
and water_level >= minp.y
and water_level <= maxp.y
then
local s_pos = area:position(vi)
if data[vi + area.ystride] == minetest.CONTENT_AIR
and data[vi] == c_water_source
-- Water Level
and water_level >= minp.y
and water_level <= maxp.y
then
local s_pos = area:position(vi)
--
-- Coral Forest Ocean Fishing Dock
--
--
-- Coral Forest Ocean Fishing Dock
--
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z)
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'
-- 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
)
shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock = shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock or {}
if #indexes < size.x * size.z then
-- not enough space
return
end
table.insert(shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock, {
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 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
)
minetest.log('action', '[Everness] Coral Forest Ocean Fishing Dock was placed at ' .. schem_pos:to_string())
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'
)
shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock = shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock or {}
table.insert(shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock, {
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] Coral Forest Ocean Fishing Dock was placed at ' .. schem_pos:to_string())
break
end
end
end
end

View File

@ -165,7 +165,7 @@ Everness:register_decoration({
--
local disp = 16
local chance = 10
local chance = 5
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 }
@ -188,73 +188,76 @@ Everness:add_to_queue_on_generated({
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 rand:next(0, 100) < chance then
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_water_source
and rand:next(0, 100) < chance
-- Water Level
and water_level >= minp.y
and water_level <= maxp.y
then
local s_pos = area:position(vi)
if data[vi + area.ystride] == minetest.CONTENT_AIR
and data[vi] == c_water_source
-- Water Level
and water_level >= minp.y
and water_level <= maxp.y
then
local s_pos = area:position(vi)
--
-- Coral Forest Ocean Fishing Dock
--
--
-- Coral Forest Ocean Fishing Dock
--
local schem_pos = vector.new(s_pos.x, s_pos.y - y_dis, s_pos.z)
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'
-- 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
)
shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock = shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock or {}
if #indexes < size.x * size.z then
-- not enough space
return
end
table.insert(shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock, {
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 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
)
minetest.log('action', '[Everness] Coral Forest Ocean Fishing Dock was placed at ' .. schem_pos:to_string())
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'
)
shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock = shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock or {}
table.insert(shared_args.schem_positions.everness_coral_forest_ocean_fishing_dock, {
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] Coral Forest Ocean Fishing Dock was placed at ' .. schem_pos:to_string())
break
end
end
end
end

View File

@ -213,6 +213,8 @@ Everness:register_decoration({
-- On Generated
--
local biome_id_everness_coral_forest_under = minetest.get_biome_id('everness:coral_forest_under')
local deco_id_coral_forest_under_coral_tree_bioluminescent = minetest.get_decoration_id('everness:coral_forest_under_coral_tree_bioluminescent')
local schem_bioluminescent_tree = minetest.get_modpath('everness') .. '/schematics/everness_coral_tree_bioluminescent.mts'
@ -226,78 +228,79 @@ bioluminescent_tree_place_on = type(bioluminescent_tree_place_on) == 'string' an
minetest.set_gen_notify({ decoration = true }, { deco_id_coral_forest_under_coral_tree_bioluminescent })
minetest.register_on_generated(function(minp, maxp, blockseed)
-- Load the voxelmanip with the result of engine mapgen
local vm = minetest.get_mapgen_object('voxelmanip')
-- Returns a 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')
Everness:add_to_queue_on_generated({
name = 'everness:coral_forest_under',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_coral_forest_under) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
--
-- Coral Tree Bioluminescent
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_coral_forest_under_coral_tree_bioluminescent or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
--
-- Coral Tree Bioluminescent
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_coral_forest_under_coral_tree_bioluminescent or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if not marker_node then
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos)
minetest.remove_node(marker_pos)
if table.indexof(bioluminescent_tree_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(bioluminescent_tree_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis,
pos.z - bioluminescent_tree_size_z
),
vector.new(
pos.x + bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis + coral_bioluminescent_tree_size.y,
pos.z + bioluminescent_tree_size_z
),
{
'air',
'everness:coral_tree'
},
true
)
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > bioluminescent_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - bioluminescent_tree_y_dis, marker_pos.z),
schem_bioluminescent_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis,
pos.z - bioluminescent_tree_size_z
),
vector.new(
pos.x + bioluminescent_tree_size_x,
pos.y - bioluminescent_tree_y_dis + coral_bioluminescent_tree_size.y,
pos.z + bioluminescent_tree_size_z
),
{
'air',
'everness:coral_tree'
},
true
)
-- minetest.log('action', '[Everness] Coral Tree Bioluminescent was placed at ' .. pos:to_string())
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > bioluminescent_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - bioluminescent_tree_y_dis, marker_pos.z),
schem_bioluminescent_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Coral Tree Bioluminescent was placed at ' .. pos:to_string())
end
end
end
end)
})

View File

@ -190,120 +190,114 @@ local c_everness_crystal_forest_deep_ocean_coral_3 = minetest.get_content_id('ev
-- Biome IDs
local biome_id_everness_crystal_forest_deep_ocean = minetest.get_biome_id('everness:crystal_forest_deep_ocean')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 25
local chance = 30
local schem = minetest.get_modpath('everness') .. '/schematics/everness_crystal_forest_deep_ocean_ruins.mts'
local size = { x = 14, y = 12, z = 9 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
local schem_positions = {}
local schem_placed = false
Everness:add_to_queue_on_generated({
name = 'everness:crystal_forest_deep_ocean',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_crystal_forest_deep_ocean) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
shared_args.schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_crystal_forest_deep_ocean) ~= -1 and rand:next(0, 100) < chance then
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- 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)
if rand:next(0, 100) < chance then
for y = maxp.y, minp.y, -1 do
if schem_placed then
break
end
for y = maxp.y, minp.y, -1 do
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local vi = area:index(x, y, z)
for z = minp.z, maxp.z do
if schem_placed then
break
end
if
data[vi] == c_everness_crystal_forest_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
and not schem_placed
then
local s_pos = area:position(vi)
for x = minp.x, maxp.x do
local vi = area:index(x, y, z)
--
-- Crystal Forest Deep Ocean Ruins
--
if
data[vi] == c_everness_crystal_forest_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
then
local s_pos = area:position(vi)
local schem_pos = vector.new(s_pos)
--
-- Crystal Forest Deep Ocean Ruins
--
-- 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_everness_crystal_forest_deep_ocean_sand,
c_everness_crystal_forest_deep_ocean_coral_plant_1,
c_everness_crystal_forest_deep_ocean_coral_plant_2,
c_everness_crystal_forest_deep_ocean_coral_plant_3,
c_everness_crystal_forest_deep_ocean_coral_1,
c_everness_crystal_forest_deep_ocean_coral_2,
c_everness_crystal_forest_deep_ocean_coral_3
},
data,
area
)
local schem_pos = vector.new(s_pos)
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough water to place structure ?
local water_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
},
data,
area
)
if #water_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'
-- 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_everness_crystal_forest_deep_ocean_sand,
c_everness_crystal_forest_deep_ocean_coral_plant_1,
c_everness_crystal_forest_deep_ocean_coral_plant_2,
c_everness_crystal_forest_deep_ocean_coral_plant_3,
c_everness_crystal_forest_deep_ocean_coral_1,
c_everness_crystal_forest_deep_ocean_coral_2,
c_everness_crystal_forest_deep_ocean_coral_3
},
data,
area
)
schem_placed = true
if #indexes < size.x * size.z then
-- not enough space
return
end
schem_positions.everness_crystal_forest_deep_ocean_ruins = schem_positions.everness_crystal_forest_deep_ocean_ruins or {}
-- enough water to place structure ?
local water_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
},
data,
area
)
table.insert(schem_positions.everness_crystal_forest_deep_ocean_ruins, {
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)
})
if #water_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'
)
minetest.log('action', '[Everness] Crystal Forest Deep Ocean Ruins was placed at ' .. schem_pos:to_string())
schem_placed = true
shared_args.schem_positions.everness_crystal_forest_deep_ocean_ruins = shared_args.schem_positions.everness_crystal_forest_deep_ocean_ruins or {}
table.insert(shared_args.schem_positions.everness_crystal_forest_deep_ocean_ruins, {
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] Crystal Forest Deep Ocean Ruins was placed at ' .. schem_pos:to_string())
break
end
end
end
end
end
end
end,
after_write_to_map = function(shared_args)
local schem_positions = shared_args.schem_positions or {}
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
@ -320,4 +314,4 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
end
end
end)
})

View File

@ -222,6 +222,8 @@ Everness:register_decoration({
-- On Generated
--
local biome_id_everness_crystal_forest_under = minetest.get_biome_id('everness:crystal_forest_under')
local deco_id_crystal_forest_under_crystal_cluster = minetest.get_decoration_id('everness:crystal_forest_under_crystal_cluster')
local deco_id_crystal_forest_under_crystal_sphere_cluster = minetest.get_decoration_id('everness:crystal_forest_under_crystal_sphere_cluster')
@ -248,174 +250,174 @@ minetest.set_gen_notify({ decoration = true }, {
deco_id_crystal_forest_under_crystal_sphere_cluster
})
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
-- Load the voxelmanip with the result of engine mapgen
local vm = minetest.get_mapgen_object('voxelmanip')
-- Returns a 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')
Everness:add_to_queue_on_generated({
name = 'everness:crystal_forest_under',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_crystal_forest_under) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
--
-- Crystal Cluster
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_crystal_forest_under_crystal_cluster or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
--
-- Crystal Cluster
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_crystal_forest_under_crystal_cluster or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos)
if table.indexof(crystal_cluster_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_cluster_size_x,
pos.y,
pos.z - crystal_cluster_size_z
),
vector.new(
pos.x + crystal_cluster_size_x,
pos.y + crystal_cluster_size.y,
pos.z + crystal_cluster_size_z
),
{
'air'
},
true
)
local air = positions.air or {}
if #air > crystal_cluster_safe_volume then
local replacements
local rand_color
if rand:next(0, 100) < 25 then
local colors = { 'purple', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
replacements = {
['everness:crystal_block_orange'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_orange'] = 'everness:crystal_' .. rand_color
}
if not marker_node then
return
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y, marker_pos.z),
schem_crystal_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
--
-- Crystal Sphere Cluster
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_crystal_forest_under_crystal_sphere_cluster or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
local crystal_sphere_cluster_y_dis = rand:next(5, 9)
if not marker_node then
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos)
if table.indexof(crystal_sphere_cluster_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis,
pos.z - crystal_sphere_cluster_size_z
),
vector.new(
pos.x + crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis + crystal_sphere_cluster_size.y,
pos.z + crystal_sphere_cluster_size_z
),
{
'air',
'everness:coral_tree',
'everness:crystal_block_orange',
'everness:crystal_block_purple',
'everness:crystal_block_cyan',
},
true
)
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
local block_orange = positions['everness:crystal_block_orange'] or {}
local block_purple = positions['everness:crystal_block_purple'] or {}
local block_cyan = positions['everness:crystal_block_cyan'] or {}
if #tree > 0
or #block_orange > 0
or #block_purple > 0
or #block_cyan > 0
then
-- will overlap
return
end
if #air > crystal_sphere_cluster_safe_volume then
local replacements
local rand_color
if rand:next(0, 100) < 25 then
local colors = { 'orange', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
replacements = {
['everness:crystal_block_purple'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_purple'] = 'everness:crystal_' .. rand_color
}
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - crystal_sphere_cluster_y_dis, marker_pos.z),
schem_crystal_sphere_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
minetest.remove_node(marker_pos)
if table.indexof(crystal_cluster_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_cluster_size_x,
pos.y,
pos.z - crystal_cluster_size_z
),
vector.new(
pos.x + crystal_cluster_size_x,
pos.y + crystal_cluster_size.y,
pos.z + crystal_cluster_size_z
),
{
'air'
},
true
)
-- minetest.log('action', '[Everness] Crystal Sphere Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
local air = positions.air or {}
if #air > crystal_cluster_safe_volume then
local replacements
local rand_color
if rand:next(0, 100) < 25 then
local colors = { 'purple', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
replacements = {
['everness:crystal_block_orange'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_orange'] = 'everness:crystal_' .. rand_color
}
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y, marker_pos.z),
schem_crystal_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
--
-- Crystal Sphere Cluster
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_crystal_forest_under_crystal_sphere_cluster or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
local crystal_sphere_cluster_y_dis = rand:next(5, 9)
if not marker_node then
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos)
if table.indexof(crystal_sphere_cluster_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis,
pos.z - crystal_sphere_cluster_size_z
),
vector.new(
pos.x + crystal_sphere_cluster_size_x,
pos.y - crystal_sphere_cluster_y_dis + crystal_sphere_cluster_size.y,
pos.z + crystal_sphere_cluster_size_z
),
{
'air',
'everness:coral_tree',
'everness:crystal_block_orange',
'everness:crystal_block_purple',
'everness:crystal_block_cyan',
},
true
)
local air = positions.air or {}
local tree = positions['everness:coral_tree'] or {}
local block_orange = positions['everness:crystal_block_orange'] or {}
local block_purple = positions['everness:crystal_block_purple'] or {}
local block_cyan = positions['everness:crystal_block_cyan'] or {}
if #tree > 0
or #block_orange > 0
or #block_purple > 0
or #block_cyan > 0
then
-- will overlap
return
end
if #air > crystal_sphere_cluster_safe_volume then
local replacements
local rand_color
if rand:next(0, 100) < 25 then
local colors = { 'orange', 'cyan' }
rand_color = colors[rand:next(1, #colors)]
replacements = {
['everness:crystal_block_purple'] = 'everness:crystal_block_' .. rand_color,
['everness:crystal_purple'] = 'everness:crystal_' .. rand_color
}
end
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - crystal_sphere_cluster_y_dis, marker_pos.z),
schem_crystal_sphere_cluster,
'random',
replacements,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Crystal Sphere Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
end
end)
})

View File

@ -190,120 +190,114 @@ local c_everness_cursed_lands_deep_ocean_coral_octocurse = minetest.get_content_
-- Biome IDs
local biome_id_everness_cursed_lands_deep_ocean = minetest.get_biome_id('everness:cursed_lands_deep_ocean')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 20
local chance = 30
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)
local size_z = math.round(size.z / 2)
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
local biomemap = minetest.get_mapgen_object('biomemap')
local schem_positions = {}
local schem_placed = false
Everness:add_to_queue_on_generated({
name = 'everness:cursed_lands_deep_ocean',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_cursed_lands_deep_ocean) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
shared_args.schem_positions = {}
local schem_placed = false
if table.indexof(biomemap, biome_id_everness_cursed_lands_deep_ocean) ~= -1 and rand:next(0, 100) < chance then
-- Load the voxelmanip with the result of engine mapgen
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
-- 'area' is used later to get the voxelmanip indexes for positions
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- 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)
if rand:next(0, 100) < chance then
for y = maxp.y, minp.y, -1 do
if schem_placed then
break
end
for y = maxp.y, minp.y, -1 do
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local vi = area:index(x, y, z)
for z = minp.z, maxp.z do
if schem_placed then
break
end
if
data[vi] == c_everness_cursed_lands_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
and not schem_placed
then
local s_pos = area:position(vi)
for x = minp.x, maxp.x do
local vi = area:index(x, y, z)
--
-- Cursed Lands Deep Ocean Skull
--
if
data[vi] == c_everness_cursed_lands_deep_ocean_sand
and data[vi + area.ystride] == c_water_source
then
local s_pos = area:position(vi)
local schem_pos = vector.new(s_pos)
--
-- Cursed Lands Deep Ocean Skull
--
-- 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_everness_cursed_lands_deep_ocean_sand,
c_everness_cursed_lands_deep_ocean_coral_plant_anemone,
c_everness_cursed_lands_deep_ocean_coral_plant_darkilluma,
c_everness_cursed_lands_deep_ocean_coral_plant_demon,
c_everness_cursed_lands_deep_ocean_coral_alcyonacea,
c_everness_cursed_lands_deep_ocean_coral_ostracod,
c_everness_cursed_lands_deep_ocean_coral_octocurse
},
data,
area
)
local schem_pos = vector.new(s_pos)
if #indexes < size.x * size.z then
-- not enough space
return
end
-- enough water to place structure ?
local water_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
},
data,
area
)
if #water_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'
-- 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_everness_cursed_lands_deep_ocean_sand,
c_everness_cursed_lands_deep_ocean_coral_plant_anemone,
c_everness_cursed_lands_deep_ocean_coral_plant_darkilluma,
c_everness_cursed_lands_deep_ocean_coral_plant_demon,
c_everness_cursed_lands_deep_ocean_coral_alcyonacea,
c_everness_cursed_lands_deep_ocean_coral_ostracod,
c_everness_cursed_lands_deep_ocean_coral_octocurse
},
data,
area
)
schem_placed = true
if #indexes < size.x * size.z then
-- not enough space
return
end
schem_positions.everness_cursed_lands_deep_ocean_skull = schem_positions.everness_cursed_lands_deep_ocean_skull or {}
-- enough water to place structure ?
local water_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
},
data,
area
)
table.insert(schem_positions.everness_cursed_lands_deep_ocean_skull, {
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)
})
if #water_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'
)
minetest.log('action', '[Everness] Cursed Lands Deep Ocean Skull was placed at ' .. schem_pos:to_string())
schem_placed = true
shared_args.schem_positions.everness_cursed_lands_deep_ocean_skull = shared_args.schem_positions.everness_cursed_lands_deep_ocean_skull or {}
table.insert(shared_args.schem_positions.everness_cursed_lands_deep_ocean_skull, {
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 Lands Deep Ocean Skull was placed at ' .. schem_pos:to_string())
break
end
end
end
end
end
end
end,
after_write_to_map = function(shared_args)
local schem_positions = shared_args.schem_positions or {}
-- Set the lighting within the `VoxelManip` to a uniform value
vm:set_lighting({ day = 0, night = 0 }, minp, maxp)
-- Calculate lighting for what has been created.
vm:calc_lighting()
-- Liquid nodes were placed so set them flowing.
vm:update_liquids()
-- Write what has been created to the world.
vm:write_to_map()
minetest.fix_light(minp, maxp)
-- Populate loot chests
for name, tbl in pairs(schem_positions) do
if next(tbl) then
for i, v in ipairs(tbl) do
@ -320,4 +314,4 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
end
end
end)
})

View File

@ -219,6 +219,8 @@ Everness:register_decoration({
-- On Generated
--
local biome_id_everness_cursed_lands_under = minetest.get_biome_id('everness:cursed_lands_under')
local deco_id_cursed_lands_under_cursed_dream_tree = minetest.get_decoration_id('everness:cursed_lands_under_cursed_dream_tree')
local schem_cursed_dream_tree = minetest.get_modpath('everness') .. '/schematics/everness_cursed_dream_tree.mts'
@ -232,78 +234,79 @@ cursed_dream_tree_place_on = type(cursed_dream_tree_place_on) == 'string' and {
minetest.set_gen_notify({ decoration = true }, { deco_id_cursed_lands_under_cursed_dream_tree })
minetest.register_on_generated(function(minp, maxp, blockseed)
-- Load the voxelmanip with the result of engine mapgen
local vm = minetest.get_mapgen_object('voxelmanip')
-- Returns a 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')
Everness:add_to_queue_on_generated({
name = 'everness:cursed_lands_under',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_cursed_lands_under) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
--
-- Cursed Dream Tree
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_cursed_lands_under_cursed_dream_tree or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
--
-- Cursed Dream Tree
--
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_cursed_lands_under_cursed_dream_tree or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if not marker_node then
return
end
if not marker_node then
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
minetest.remove_node(marker_pos)
minetest.remove_node(marker_pos)
if table.indexof(cursed_dream_tree_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if table.indexof(cursed_dream_tree_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis,
pos.z - cursed_dream_tree_size_z
),
vector.new(
pos.x + cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis + cursed_dream_tree_size.y,
pos.z + cursed_dream_tree_size_z
),
{
'air',
'everness:dry_tree'
},
true
)
local air = positions.air or {}
local tree = positions['everness:dry_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > cursed_dream_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z),
schem_cursed_dream_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis,
pos.z - cursed_dream_tree_size_z
),
vector.new(
pos.x + cursed_dream_tree_size_x,
pos.y - cursed_dream_tree_y_dis + cursed_dream_tree_size.y,
pos.z + cursed_dream_tree_size_z
),
{
'air',
'everness:dry_tree'
},
true
)
-- minetest.log('action', '[Everness] Cursed Dream Tree was placed at ' .. pos:to_string())
local air = positions.air or {}
local tree = positions['everness:dry_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > cursed_dream_tree_safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z),
schem_cursed_dream_tree,
'random',
nil,
true,
'place_center_x, place_center_z'
)
-- minetest.log('action', '[Everness] Cursed Dream Tree was placed at ' .. pos:to_string())
end
end
end
end)
})

View File

@ -155,6 +155,33 @@ Everness:register_decoration({
flags = 'all_floors'
})
Everness:register_decoration({
name = 'everness:forsaken_tundra_under_willow_tree',
deco_type = 'simple',
place_on = {
'everness:mold_stone_with_moss',
'everness:blue_crying_obsidian',
'everness:blue_weeping_obsidian',
'everness:weeping_obsidian'
},
sidelen = 16,
noise_params = {
offset = 0,
scale = 0.002,
spread = { x = 250, y = 250, z = 250 },
seed = 2,
octaves = 3,
persist = 0.66
},
biomes = { 'everness:forsaken_tundra_under' },
y_max = y_max - 1500 > y_min and y_max - 1500 or y_max,
y_min = y_min,
flags = 'all_floors',
decoration = {
'everness:marker'
},
})
Everness:register_decoration({
name = 'everness:forsaken_tundra_under_bloodspore_plant_small',
deco_type = 'simple',
@ -250,84 +277,95 @@ register_agave_leaf_decoration(0, 0.06, 1)
-- On Generated
--
local c_air = minetest.get_content_id('air')
local c_mold_stone_with_moss = minetest.get_content_id('everness:mold_stone_with_moss')
local biome_id_everness_forsaken_tundra_under = minetest.get_biome_id('everness:forsaken_tundra_under')
-- Localize data buffer table outside the loop, to be re-used for all
-- mapchunks, therefore minimising memory use.
local data = {}
local chance = 50
local disp = 16
local rotations = { '0', '90', '180', '270' }
local everness_forsaken_tundra_under_y_max = y_max - 1500 > y_min and y_max - 1500 or y_max
local everness_forsaken_tundra_under_y_min = y_min
local deco_id_everness_forsaken_tundra_under_willow_tree = minetest.get_decoration_id('everness:forsaken_tundra_under_willow_tree')
-- size = { x = 39, y = 28, z = 39 }
local willow_tree_volume = 39 * 39 * 28
local willow_tree_schem = minetest.get_modpath('everness') .. '/schematics/everness_willow_tree.mts'
local size = { x = 39, y = 28, z = 39 }
local size_x = math.round(size.x / 2)
local size_z = math.round(size.z / 2)
local safe_volume = (size.x * size.y * size.z) / 1.5
local y_dis = 1
local willow_tree_place_on = minetest.registered_decorations['everness:forsaken_tundra_under_willow_tree'].place_on
willow_tree_place_on = type(willow_tree_place_on) == 'string' and { willow_tree_place_on } or willow_tree_place_on
minetest.register_on_generated(function(minp, maxp, blockseed)
local rand = PcgRandom(blockseed)
minetest.set_gen_notify({ decoration = true }, { deco_id_everness_forsaken_tundra_under_willow_tree })
local vm, emin, emax = minetest.get_mapgen_object('voxelmanip')
local area = VoxelArea:new({ MinEdge = emin, MaxEdge = emax })
-- 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)
local sidelength = maxp.x - minp.x + 1
Everness:add_to_queue_on_generated({
name = 'everness:forsaken_tundra_under',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_forsaken_tundra_under) ~= -1
end,
after_set_data = function(minp, maxp, vm, area, data, p2data, gennotify, rand, shared_args)
--
-- Willow Tree
--
local x_disp = rand:next(0, disp)
local z_disp = rand:next(0, disp)
for _, pos in ipairs(gennotify['decoration#' .. (deco_id_everness_forsaken_tundra_under_willow_tree or '')] or {}) do
-- `pos` is position of the 'place_on' node
local marker_pos = vector.new(pos.x, pos.y + 1, pos.z)
local marker_node = minetest.get_node(marker_pos)
local place_on_node = minetest.get_node(pos)
if everness_forsaken_tundra_under_y_min < maxp.y
and maxp.y < everness_forsaken_tundra_under_y_max
then
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 not marker_node then
return
end
if data[vi + area.ystride] == c_air and data[vi] == c_mold_stone_with_moss then
local rotation = rotations[rand:next(1, #rotations)]
local s_pos = area:position(vi)
local biome_data = minetest.get_biome_data(s_pos)
if marker_node.name ~= 'everness:marker' then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if not biome_data then
return
end
minetest.remove_node(marker_pos)
local biome_name = minetest.get_biome_name(biome_data.biome)
if table.indexof(willow_tree_place_on, place_on_node.name) == -1 then
-- not a valid "place_on" position (e.g. something else was placed there)
return
end
if not biome_name then
return
end
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
if biome_name == 'everness:forsaken_tundra_under' and rand:next(0, 100) < chance then
--
-- Willow Tree
--
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
pos.x - size_x,
pos.y - y_dis,
pos.z - size_z
),
vector.new(
pos.x + size_x,
pos.y - y_dis + size.y,
pos.z + size_z
),
{
'air',
'everness:willow_tree'
},
true
)
local schem_pos = vector.new(s_pos.x, s_pos.y, s_pos.z)
local air_positions = minetest.find_nodes_in_area(
vector.new(s_pos.x - 19, s_pos.y, s_pos.z - 19),
vector.new(s_pos.x + 19, s_pos.y + 28, s_pos.z + 19),
{'air'},
true
)
local air = positions.air or {}
local tree = positions['everness:willow_tree'] or {}
if air_positions.air and #air_positions.air > (willow_tree_volume / 2) then
minetest.place_schematic_on_vmanip(
vm,
schem_pos,
willow_tree_schem,
rotation,
nil,
true,
'place_center_x, place_center_z'
)
if #tree > 1 then
-- will overlap another tree
return
end
minetest.log('action', '[Everness] Willow Tree was placed at ' .. schem_pos:to_string())
end
end
if #air > safe_volume then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - y_dis, marker_pos.z),
willow_tree_schem,
'random',
nil,
true,
'place_center_x, place_center_z'
)
minetest.log('action', '[Everness] Willow Tree was placed at ' .. pos:to_string())
end
end
end
end)
})

View File

@ -313,9 +313,18 @@ Everness:register_decoration({
-- On Generated
--
local size_ceiling = { x = 2, y = 19, z = 2 }
local size_ceiling_x = math.round(size_ceiling.x / 2)
local size_ceiling_z = math.round(size_ceiling.z / 2)
local size_floor = { x = 2, y = 20, z = 2 }
local size_floor_x = math.round(size_floor.x / 2)
local size_floor_z = math.round(size_floor.z / 2)
local deco_id_frosted_icicle_large_ceiling = minetest.get_decoration_id('everness:frosted_icicle_large_ceiling')
local deco_id_frosted_icicle_large_floor = minetest.get_decoration_id('everness:frosted_icicle_large_floor')
local biome_id_everness_frosted_icesheet_under = minetest.get_biome_id('everness:frosted_icesheet_under')
minetest.set_gen_notify(
{ decoration = true },
{
@ -324,75 +333,73 @@ minetest.set_gen_notify(
}
)
minetest.register_on_generated(function(minp, maxp, blockseed)
local gennotify = minetest.get_mapgen_object('gennotify')
local size_ceiling = { x = 2, y = 19, z = 2 }
local size_ceiling_x = math.round(size_ceiling.x / 2)
local size_ceiling_z = math.round(size_ceiling.z / 2)
local size_floor = { x = 2, y = 20, z = 2 }
local size_floor_x = math.round(size_floor.x / 2)
local size_floor_z = math.round(size_floor.z / 2)
--
-- Frosted Large Icicle Ceiling
--
for _, pos in ipairs(gennotify['decoration#' .. deco_id_frosted_icicle_large_ceiling] or {}) do
local markers = minetest.find_nodes_in_area(
vector.new(pos.x - size_ceiling_x, pos.y - size_ceiling.y + 2, pos.z - size_ceiling_z),
vector.new(pos.x + size_ceiling_x, pos.y - size_ceiling.y, pos.z + size_ceiling_z),
{ 'everness:marker' }
)
if #markers > 0 then
local pos_marker = markers[1]
local air_below = minetest.find_nodes_in_area(
vector.new(pos_marker.x, pos_marker.y, pos_marker.z),
vector.new(pos_marker.x, pos_marker.y - 7, pos_marker.z),
{'air'}
Everness:add_to_queue_on_generated({
name = 'everness:frosted_icesheet_under',
can_run = function(biomemap)
return table.indexof(biomemap, biome_id_everness_frosted_icesheet_under) ~= -1
end,
after_write_to_map = function(shared_args, gennotify)
--
-- Frosted Large Icicle Ceiling
--
for _, pos in ipairs(gennotify['decoration#' .. deco_id_frosted_icicle_large_ceiling] or {}) do
local markers = minetest.find_nodes_in_area(
vector.new(pos.x - size_ceiling_x, pos.y - size_ceiling.y + 2, pos.z - size_ceiling_z),
vector.new(pos.x + size_ceiling_x, pos.y - size_ceiling.y, pos.z + size_ceiling_z),
{ 'everness:marker' }
)
-- Replace marker
minetest.set_node(pos_marker, { name = 'everness:frosted_cave_ice_illuminating' })
if #markers > 0 then
local pos_marker = markers[1]
local air_below = minetest.find_nodes_in_area(
vector.new(pos_marker.x, pos_marker.y, pos_marker.z),
vector.new(pos_marker.x, pos_marker.y - 7, pos_marker.z),
{'air'}
)
if #air_below == 7 then
local incrementer = 1
local pos_below = vector.new(pos_marker.x, pos_marker.y - incrementer, pos_marker.z)
local node_below = minetest.get_node(pos_below)
-- Replace marker
minetest.set_node(pos_marker, { name = 'everness:frosted_cave_ice_illuminating' })
Everness.stack_icicle_recursive(node_below, pos_below, incrementer, pos_marker, 'down')
if #air_below == 7 then
local incrementer = 1
local pos_below = vector.new(pos_marker.x, pos_marker.y - incrementer, pos_marker.z)
local node_below = minetest.get_node(pos_below)
Everness.stack_icicle_recursive(node_below, pos_below, incrementer, pos_marker, 'down')
end
end
end
--
-- Frosted Large Icicle Floor
--
for _, pos in ipairs(gennotify['decoration#' .. deco_id_frosted_icicle_large_floor] or {}) do
local markers = minetest.find_nodes_in_area(
vector.new(pos.x - size_floor_x, pos.y + size_floor.y - 2, pos.z - size_floor_z),
vector.new(pos.x + size_floor_x, pos.y + size_floor.y, pos.z + size_floor_z),
{ 'everness:marker' }
)
if #markers > 0 then
local pos_marker = markers[1]
local air_above = minetest.find_nodes_in_area(
vector.new(pos_marker.x, pos_marker.y, pos_marker.z),
vector.new(pos_marker.x, pos_marker.y + 7, pos_marker.z),
{'air'}
)
-- Replace marker
minetest.set_node(pos_marker, { name = 'everness:frosted_cave_ice_illuminating' })
-- Make sure we have some space
if #air_above == 7 then
local incrementer = 1
local pos_above = vector.new(pos_marker.x, pos_marker.y + incrementer, pos_marker.z)
local node_above = minetest.get_node(pos_above)
Everness.stack_icicle_recursive(node_above, pos_above, incrementer, pos_marker, 'up')
end
end
end
end
--
-- Frosted Large Icicle Floor
--
for _, pos in ipairs(gennotify['decoration#' .. deco_id_frosted_icicle_large_floor] or {}) do
local markers = minetest.find_nodes_in_area(
vector.new(pos.x - size_floor_x, pos.y + size_floor.y - 2, pos.z - size_floor_z),
vector.new(pos.x + size_floor_x, pos.y + size_floor.y, pos.z + size_floor_z),
{ 'everness:marker' }
)
if #markers > 0 then
local pos_marker = markers[1]
local air_above = minetest.find_nodes_in_area(
vector.new(pos_marker.x, pos_marker.y, pos_marker.z),
vector.new(pos_marker.x, pos_marker.y + 7, pos_marker.z),
{'air'}
)
-- Replace marker
minetest.set_node(pos_marker, { name = 'everness:frosted_cave_ice_illuminating' })
-- Make sure we have some space
if #air_above == 7 then
local incrementer = 1
local pos_above = vector.new(pos_marker.x, pos_marker.y + incrementer, pos_marker.z)
local node_above = minetest.get_node(pos_above)
Everness.stack_icicle_recursive(node_above, pos_above, incrementer, pos_marker, 'up')
end
end
end
end)
})

Binary file not shown.