Fix early return causing loop to break, disable falling vines on willow tree

This commit is contained in:
Juraj Vajda 2024-02-14 16:59:01 -05:00
parent 06c72f7fc2
commit 4a66428998
7 changed files with 255 additions and 285 deletions

26
api.lua
View File

@ -2154,3 +2154,29 @@ function Everness.add_to_queue_on_generated(self, def)
table.insert(self.on_generated_queue, def)
end
function Everness.find_irecursive(table, c_id)
local found = false
for i, v in ipairs(table) do
if type(v) == 'table' then
Everness.find_irecursive(v, c_id)
end
if c_id == v then
found = true
break
end
end
return found
end
---Merge two tables with key/value pair
---@param t1 table
---@param t2 table
---@return table
function Everness.mergeTables(t1, t2)
for k, v in pairs(t2) do t1[k] = v end
return t1
end

View File

@ -243,24 +243,11 @@ Everness:add_to_queue_on_generated({
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
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
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
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
if table.indexof(bioluminescent_tree_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
@ -283,12 +270,8 @@ Everness:add_to_queue_on_generated({
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
-- do not overlap another tree
if #tree == 0 and #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),
@ -303,4 +286,6 @@ Everness:add_to_queue_on_generated({
end
end
end
end
end
})

View File

@ -265,22 +265,11 @@ Everness:add_to_queue_on_generated({
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
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
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
if table.indexof(crystal_cluster_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
@ -328,6 +317,8 @@ Everness:add_to_queue_on_generated({
-- minetest.log('action', '[Everness] Crystal Cluster ' .. (rand_color or 'orange') .. ' was placed at ' .. pos:to_string())
end
end
end
end
--
-- Crystal Sphere Cluster
@ -339,22 +330,11 @@ Everness:add_to_queue_on_generated({
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
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
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
if table.indexof(crystal_sphere_cluster_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
@ -383,16 +363,16 @@ Everness:add_to_queue_on_generated({
local block_purple = positions['everness:crystal_block_purple'] or {}
local block_cyan = positions['everness:crystal_block_cyan'] or {}
if #tree > 0
if
#air > crystal_sphere_cluster_safe_volume
-- do not overlap
and not (
#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
@ -420,4 +400,6 @@ Everness:add_to_queue_on_generated({
end
end
end
end
end
})

View File

@ -249,24 +249,11 @@ Everness:add_to_queue_on_generated({
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
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
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
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
if table.indexof(cursed_dream_tree_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
@ -289,12 +276,7 @@ Everness:add_to_queue_on_generated({
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
if #air > cursed_dream_tree_safe_volume and #tree <= 1 then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - cursed_dream_tree_y_dis, marker_pos.z),
@ -309,4 +291,6 @@ Everness:add_to_queue_on_generated({
end
end
end
end
end
})

View File

@ -67,7 +67,7 @@ Everness:register_ore({
octaves = 1,
persist = 0.0
},
biomes = { 'everness_forsaken_tundra_ocean' }
biomes = { 'everness:forsaken_tundra_ocean' }
})
--
@ -87,7 +87,7 @@ Everness:register_decoration({
octaves = 3,
persist = 0.7,
},
biomes = { 'everness_forsaken_tundra_ocean' },
biomes = { 'everness:forsaken_tundra_ocean' },
y_max = y_max,
y_min = y_min,
place_offset_y = -1,

View File

@ -308,24 +308,11 @@ Everness:add_to_queue_on_generated({
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
if marker_node and marker_node.name == 'everness:marker' then
-- remove marker
minetest.remove_node(marker_pos)
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
-- no need to check for the floor "big enough" size since its a tree and has ~ 1x1 base size
if table.indexof(willow_tree_place_on, place_on_node.name) ~= -1 then
-- enough air to place structure ?
local positions = minetest.find_nodes_in_area(
vector.new(
@ -348,12 +335,7 @@ Everness:add_to_queue_on_generated({
local air = positions.air or {}
local tree = positions['everness:willow_tree'] or {}
if #tree > 1 then
-- will overlap another tree
return
end
if #air > safe_volume then
if #air > safe_volume and #tree == 0 then
minetest.place_schematic_on_vmanip(
vm,
vector.new(marker_pos.x, marker_pos.y - y_dis, marker_pos.z),
@ -368,4 +350,6 @@ Everness:add_to_queue_on_generated({
end
end
end
end
end
})

View File

@ -58,6 +58,11 @@ local function register_vine(name, def, overrides)
-- ALL
flammable = 2,
}
if _overrides.groups then
Everness.mergeTables(_def.groups, _overrides.groups)
end
-- MCL
_def._mcl_shears_drop = true
_def._mcl_blast_resistance = 0.2
@ -66,7 +71,7 @@ local function register_vine(name, def, overrides)
return false
end
_def.sounds = Everness.node_sound_leaves_defaults()
_def.waving = 2
_def.waving = 1
_def.on_destruct = function(pos)
local pos_below = vector.new(pos.x, pos.y - 1, pos.z)
local node_below = minetest.get_node(pos_below)
@ -183,6 +188,10 @@ register_vine('bulb_vine', {
register_vine('willow_vine', {
description = S('Willow Vine')
}, {
groups = {
falling_vines = 0
}
})
-- Eye Vine