forked from mtcontrib/moretrees
made leaves depend on the trunks they spawn with to avoid decaying
rather than just any trunk being enough to stop just any leaves from decaying. Re-tuned the leaf decay interval/chance values accordingly. Changed a few variables to avoid possible conflicts. Added a setting to allow one to disable the new leaf decay code. Moved sapling growth code into its own file. Minor changes to comments here and there. Got rid of simple trees list (made the code do various checks in realtime instead, since it's just startup code anyway). Fixed messed-up crafting for jungle trees; condensed most of the crafting code into main craft registry loop. Mostly fixed broken aliases of default jungletrees.
This commit is contained in:
@ -1,34 +1,65 @@
|
||||
-- leaf decay
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = moretrees.leaves_list,
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, moretrees.trunks_list) then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:dig_node(pos)
|
||||
if moretrees.enable_leafdecay then
|
||||
for i in ipairs(moretrees.treelist) do
|
||||
local treename = moretrees.treelist[i][1]
|
||||
if treename ~= "jungletree" and treename ~= "fir" then
|
||||
minetest.register_abm({
|
||||
nodenames = "moretrees:"..treename.."_leaves",
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, "moretrees:"..treename.."_trunk") then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:dig_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = "moretrees:palm_leaves",
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, moretrees.trunks_list) then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:dig_node(pos)
|
||||
minetest.register_abm({
|
||||
nodenames = {"moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_green","moretrees:jungletree_leaves_yellow"},
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, {"default:jungletree", "moretrees:jungletree_trunk"}) then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:dig_node(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moretrees:fir_leaves", "moretrees:fir_leaves_bright"},
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, "moretrees:fir_trunk") then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:dig_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = "moretrees:palm_leaves",
|
||||
interval = moretrees.leafdecay_delay,
|
||||
chance = moretrees.leafdecay_chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, "moretrees:palm_trunk") then
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:dig_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if moretrees.enable_replace_default_trees then
|
||||
minetest.register_alias("mapgen_tree", "air")
|
||||
minetest.register_alias("mapgen_leaves", "air")
|
||||
plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model)
|
||||
|
||||
elseif moretrees.enable_default_leafdecay then
|
||||
minetest.register_abm({
|
||||
nodenames = "default:leaves",
|
||||
|
Reference in New Issue
Block a user