From 68e005814fa52784ccd598215d5467de2d464826 Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Thu, 19 Oct 2023 15:08:53 +0200 Subject: [PATCH] refactor sapling support checking. saplings now only check for groups, not specific nodes, when determining whether they are supported. the previously checked nodes are now in the new group that's being checked. --- mods/bg_tree/grow_sapling.lua | 8 +++++--- mods/bg_tree/node.lua | 1 + mods/bg_tree/node_log.lua | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/bg_tree/grow_sapling.lua b/mods/bg_tree/grow_sapling.lua index f9e53c5..1d3a948 100644 --- a/mods/bg_tree/grow_sapling.lua +++ b/mods/bg_tree/grow_sapling.lua @@ -9,8 +9,10 @@ local leaves_growing = modname .. ":leaves_growing" local function supports_sapling (name) - if name == log_alive or name == root_alive then return true end - return minetest.get_item_group(name, "dirty") > 0 + return blockgame.item_matches(name, { + "group:supports_sapling", + "group:dirty", + }) end -- this commented-out function will be used when roots start affecting tree growth. @@ -39,7 +41,7 @@ blockgame.register_increasing_abm({ id = modname .. ":grow_sapling", label = "grow sapling", nodenames = {sapling}, - neighbors = {"group:dirty", log_alive}, + neighbors = {"group:supports_sapling", "group:dirty"}, interval = 15, chance = 4, rate = function (pos, node, data) diff --git a/mods/bg_tree/node.lua b/mods/bg_tree/node.lua index c79947e..33ca3f3 100644 --- a/mods/bg_tree/node.lua +++ b/mods/bg_tree/node.lua @@ -19,6 +19,7 @@ blockgame.register_node("root_alive", { description = "Growing Root", groups = { woody = 1, + supports_sapling = 1, }, drop = modname .. ":root", }) diff --git a/mods/bg_tree/node_log.lua b/mods/bg_tree/node_log.lua index 421d947..ba522be 100644 --- a/mods/bg_tree/node_log.lua +++ b/mods/bg_tree/node_log.lua @@ -28,6 +28,7 @@ reg_log("log", { reg_log("log_alive", { groups = { planty = 1, + supports_sapling = 1, }, texture = "log", drop = modname .. ":log",