From 2fed50dbbe1bf687330b48784e6a0bfc5f329f4a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 31 Aug 2017 23:13:51 +0200 Subject: [PATCH] Fix crash when drinking milk when damage disabled --- mods/ITEMS/mcl_mobitems/init.lua | 2 +- mods/PLAYER/mcl_hunger/init.lua | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index b127be4b8..4dcd47307 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -135,7 +135,7 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", { local drink_milk = function(itemstack, player, pointed_thing) local bucket = minetest.do_item_eat(0, "mcl_buckets:bucket_empty", itemstack, player, pointed_thing) -- Check if we were allowed to drink this (eat delay check) - if bucket:get_name() ~= "mcl_mobitems:milk_bucket" then + if bucket:get_name() ~= "mcl_mobitems:milk_bucket" and mcl_hunger.active then mcl_hunger.stop_poison(player) end return bucket diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index a794fb1fa..6fa973f76 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -7,6 +7,13 @@ end mcl_hunger = {} + +-- This variable tells you if the hunger gameplay mechanic is active. +-- IMPORTANT: If damage is disabled on load time, most of the functions are NOT +-- available! Check if mcl_hunger is active before using the API. +mcl_hunger.active = false + + mcl_hunger.exhaust = function() end mcl_hunger.HUD_TICK = 0.1 @@ -24,8 +31,6 @@ mcl_hunger.EXHAUST_LVL = 4000 -- at what exhaustion player saturation gets lower mcl_hunger.SATURATION_INIT = 5 -- Initial saturation for new/respawning players -mcl_hunger.active = false - if minetest.settings:get_bool("enable_damage") then mcl_hunger.active = true