From 77bcf6cff397fc0f49c792270a8a8e55520f2f90 Mon Sep 17 00:00:00 2001 From: William Goodspeed Date: Sun, 18 Aug 2024 10:43:41 +0000 Subject: [PATCH 1/2] Allowing `hb.change_bar' called with hudbar uninitialized Calling `hb.change_bar' with hunger bar on damage disabled server will crash the server. To not overload other functions to check `enable_damage' over and over, simply make `hb.change_bar' able to be called with uninitialized identifiers. #4586 --- mods/HUD/hudbars/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 7f86a959d..543692d51 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -330,9 +330,16 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) + + -- hb.change_hudbar may be called with a non-existing hudbar like hunger. + if hudtable == nil then + return false + end + if not hudtable.hudstate[name] then return false end + local value_changed, max_changed = false, false if new_value then From a6136ad1584d3baa546acb2a829218699c094c7f Mon Sep 17 00:00:00 2001 From: William Goodspeed Date: Sun, 18 Aug 2024 10:48:37 +0000 Subject: [PATCH 2/2] Removing absorption bar on damage disabled servers The absorption effect won't work on damage disabled servers and the health bar and hunger bar is also hidden leaving the absorption bar alone which makes it look not good. So not initializing it on those servers might be a good idea. --- mods/ITEMS/mcl_potions/functions.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index a1c838814..b59749d2a 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -1260,7 +1260,11 @@ local function potions_init_icons(player) }) table.insert(icon_ids[name], id) end - hb.init_hudbar(player, "absorption") + + -- Absorption bar in damage disabled server is unneccessary + if minetest.settings:get_bool("enable_damage") == true then + hb.init_hudbar(player, "absorption") + end end local function potions_set_icons(player)