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.
This commit is contained in:
trans_soup 2023-10-19 15:08:53 +02:00
parent dd796c549e
commit 68e005814f
3 changed files with 7 additions and 3 deletions

View file

@ -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)

View file

@ -19,6 +19,7 @@ blockgame.register_node("root_alive", {
description = "Growing Root",
groups = {
woody = 1,
supports_sapling = 1,
},
drop = modname .. ":root",
})

View file

@ -28,6 +28,7 @@ reg_log("log", {
reg_log("log_alive", {
groups = {
planty = 1,
supports_sapling = 1,
},
texture = "log",
drop = modname .. ":log",