From f9c045edad296b2d41832f1952a810477642f530 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sat, 5 Mar 2016 18:53:02 +0100 Subject: [PATCH] [farming] Execute on_rightclick callbacks upon using seeds - For #406 --- minetestforfun_game/mods/farming/init.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/minetestforfun_game/mods/farming/init.lua b/minetestforfun_game/mods/farming/init.lua index 8c293051..ed6eae91 100755 --- a/minetestforfun_game/mods/farming/init.lua +++ b/minetestforfun_game/mods/farming/init.lua @@ -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