From 6d33368858634d5b619cca77e24e00627c2e3683 Mon Sep 17 00:00:00 2001 From: WillConker Date: Mon, 10 Jun 2024 14:57:48 +0100 Subject: [PATCH] Made nausea effect applicable to mobs (with no effect on the mob) --- mods/ITEMS/mcl_potions/functions.lua | 42 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 96028bb60..39c717913 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -858,30 +858,38 @@ mcl_potions.register_effect({ return S("not feeling very well...").."\n"..S("frequency: @1 / 1 s", factor) end, res_condition = function(object) - return (not object:is_player()) -- TODO what should it do for mobs? + -- Currently no-op for mobs, just displays particles + -- TODO what should it do for mobs? + return not object:is_player() and not object:get_luaentity().is_mob end, on_start = function(object, factor) - object:set_lighting({ - saturation = -1.0, - }) + if object:is_player() then + object:set_lighting({ + saturation = -1.0, + }) + end end, on_hit_timer = function(object, factor, duration) - if EF.nausea[object].high then - mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_high", factor) - mcl_fovapi.apply_modifier(object, "mcl_potions:nausea_low", factor) - EF.nausea[object].high = false - else - mcl_fovapi.apply_modifier(object, "mcl_potions:nausea_high", factor) - mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_low", factor) - EF.nausea[object].high = true + if object:is_player() then + if EF.nausea[object].high then + mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_high", factor) + mcl_fovapi.apply_modifier(object, "mcl_potions:nausea_low", factor) + EF.nausea[object].high = false + else + mcl_fovapi.apply_modifier(object, "mcl_potions:nausea_high", factor) + mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_low", factor) + EF.nausea[object].high = true + end end end, on_end = function(object) - object:set_lighting({ - saturation = 1.0, - }) - mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_high") - mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_low") + if object:is_player() then + object:set_lighting({ + saturation = 1.0, + }) + mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_high") + mcl_fovapi.remove_modifier(object, "mcl_potions:nausea_low") + end end, particle_color = "#60AA30", uses_factor = true,