diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 2c29e1939..cf06e48c9 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -1,10 +1,23 @@ --local S = minetest.get_translator(minetest.get_current_modname()) +local function is_fake_player(player) + -- Simple checks + if not player then return true end + if player:is_player() == false then return true end + if not player.get_player_name then return true end + + -- Check if the player is logged in + local objref = minetest.get_player_by_name( player:get_player_name() ) + if not objref then return true end + if objref ~= player then return true end + + return false +end + -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) function minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing) - if not user or user:is_player() == false then - return itemstack - end + -- Fake players can't eat food + if is_fake_player(user) then return itemstack end -- Call on_rightclick if the pointed node defines it if pointed_thing.type == "node" then