1
0
mirror of https://github.com/minetest/minetest_game.git synced 2025-06-28 04:40:22 +02:00

Added can_grow function to plant definition (#3131)

This commit is contained in:
ssdaniel24
2024-06-23 19:03:36 +03:00
committed by GitHub
parent f03c992864
commit 061f4e76dd
2 changed files with 9 additions and 3 deletions

View File

@ -189,6 +189,12 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
return itemstack
end
-- check if on wet soil
farming.can_grow = function(pos)
local below = minetest.get_node(pos:offset(0, -1, 0))
return minetest.get_item_group(below.name, "soil") >= 3
end
farming.grow_plant = function(pos, elapsed)
local node = minetest.get_node(pos)
local name = node.name
@ -224,9 +230,7 @@ farming.grow_plant = function(pos, elapsed)
return
end
-- check if on wet soil
local below = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
if minetest.get_item_group(below.name, "soil") < 3 then
if not (def.can_grow or farming.can_grow)(pos) then
tick_again(pos)
return
end