1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 17:50:37 +01:00

[farming] Execute on_rightclick callbacks upon using seeds

- For #406
This commit is contained in:
LeMagnesium 2016-03-05 18:53:02 +01:00
parent a23fc44e6d
commit f9c045edad

View File

@ -437,17 +437,22 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname)
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)
-- check if pointing at the top of the node
if pt.above.y ~= pt.under.y + 1 then
return
end
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name]
or not minetest.registered_nodes[above.name] then
return
end
-- is there an on_rightclick callback?
if minetest.registered_nodes[under.name].on_rightclick and not placer:get_player_control().sneak then
return minetest.registered_nodes[under.name].on_rightclick(pt.under, under, placer, itemstack, pointed_thing)
end
-- check if pointing at the top of the node
if pt.above.y ~= pt.under.y + 1 then
return
end
-- can I replace above node, and am I pointing at soil
if not minetest.registered_nodes[above.name].buildable_to
or minetest.get_item_group(under.name, "soil") < 2
@ -472,6 +477,7 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname)
)
end -- END refill
end
return itemstack
end
end