mojira.dev
MC-180981

Storing entity health as /bossbar doesn't work at some times

I have made a world to test this and it seems that the Attributes[x].Base is different for every mob and their data, which means a custom zombie with more health and other stats has Attributes.[4].Base as Max Health.

In previous versions, Max Health was fixed for Attributes.[0].Base

 

I made a function that draws a health bar of all mobs, though it seems it doesn't work for some. There is a map in attachments.

execute as @a at @s positioned ^ ^ ^2 as @e[type=!experience_orb,type=!item,type=!player,limit=1,type=!armor_stand,distance=..1.6] at @s store result bossbar healthbar max run data get entity @s Attributes.[1].Base
execute as @a at @s positioned ^ ^ ^2 as @e[type=!experience_orb,type=!item,type=!player,limit=1,type=!armor_stand,distance=..1.6] at @s store result bossbar healthbar value run data get entity @s Health
execute as @a at @s positioned ^ ^ ^2 unless entity @e[type=!experience_orb,type=!item,type=!player,limit=1,type=!armor_stand,distance=..1.6] run bossbar set healthbar visible false
execute as @a at @s positioned ^ ^ ^2 if entity @e[type=!experience_orb,type=!item,type=!player,limit=1,type=!armor_stand,distance=..1.6] run bossbar set healthbar visible true

Attachments

Comments 1

Just do

Attributes[{Name:"minecraft:generic.max_health"}].Base

dave johnson

(Unassigned)

Unconfirmed

(Unassigned)

bossbar, command, function

20w17a

Retrieved