From af044e6a96fba49bd573eff01be751067403f0e3 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 11 Apr 2021 11:15:09 +0200 Subject: [PATCH] Bossbars: Add support for non-mob bosses --- mods/HUD/mcl_bossbars/init.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mods/HUD/mcl_bossbars/init.lua b/mods/HUD/mcl_bossbars/init.lua index b5bec1334..209d9a2c1 100644 --- a/mods/HUD/mcl_bossbars/init.lua +++ b/mods/HUD/mcl_bossbars/init.lua @@ -76,16 +76,23 @@ function mcl_bossbars.update_bar(id, def, priority) old.priority = priority or old.priority end -function mcl_bossbars.update_boss(luaentity, name, color) - local object = luaentity.object +function mcl_bossbars.update_boss(object, name, color) + local props = object:get_luaentity() + if not props or not props._cmi_is_mob then + props = object:get_properties() + props.health = object:get_hp() + end + local bardef = { - text = luaentity.nametag, - percentage = math.floor(luaentity.health / luaentity.hp_max * 100), color = color, + text = props.nametag, + percentage = math.floor(props.health / props.hp_max * 100), } + if not bardef.text or bardef.text == "" then bardef.text = name end + local pos = object:get_pos() for _, player in pairs(minetest.get_connected_players()) do local d = vector.distance(pos, player:get_pos())