From a0800e1296f643a9dc673f4e14f7b341f7afd65e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 2 Mar 2017 16:28:49 +0100 Subject: [PATCH] Node on_rightclick takes precedence over eating --- mods/PLAYER/mcl_hunger/hunger.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index eb45ae6a0a..5762984171 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -9,6 +9,16 @@ end -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) local org_eat = core.do_item_eat core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + if pointed_thing.type == "node" then + local node = minetest.get_node(pointed_thing.under) + if user and not user:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack + end + end + end + local old_itemstack = itemstack itemstack = mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) for _, callback in pairs(core.registered_on_item_eats) do