fix sapling growth replacing certain nodes.

saplings can now replace alive leaves when growing (and other nodes can
easily be added in the future).

previously, instead of saplings, it was accidentally the case that
alive leaves growth worked like this when growing out of sapling,
instead of actual sapling growth.
This commit is contained in:
trans_soup 2023-10-19 15:52:01 +02:00
parent 717cbf91e2
commit 87a88a88a6

View file

@ -38,6 +38,9 @@ end
]]-- ]]--
local sapling_grow_cost = 2000 local sapling_grow_cost = 2000
local sapling_can_replace = {
modname .. ":leaves_alive",
}
blockgame.register_increasing_abm({ blockgame.register_increasing_abm({
id = modname .. ":grow_sapling", id = modname .. ":grow_sapling",
@ -58,7 +61,8 @@ blockgame.register_increasing_abm({
if not supports_sapling(below_name) then return false end if not supports_sapling(below_name) then return false end
local above = pos + blockgame.vector.dirs.up local above = pos + blockgame.vector.dirs.up
if minetest.get_node(above).name ~= "air" then return false end local above_name = minetest.get_node(above).name
if above_name ~= "air" and not blockgame.item_matches(above_name, sapling_can_replace) then return false end
return true return true
end, end,
@ -87,7 +91,7 @@ blockgame.register_increasing_abm({
-- grow out leaves to the sides. -- grow out leaves to the sides.
local sides = blockgame.vector.get_sides_of(above) local sides = blockgame.vector.get_sides_of(above)
for _, side in pairs(sides) do for _, side in pairs(sides) do
blockgame.attempt_place(side, {name = leaves_growing}, {modname .. ":leaves_alive"}) blockgame.attempt_place(side, {name = leaves_growing})
end end
end, end,
}) })