M BUZZ CRAZE NEWS
// updates

How do I make a boss bar for a mob and have command blocks execute when it gets to a certain health

By Emma Martinez

I'm building a boss fight for a game I'm making, I want the boss to have a health bar at the top of the screen like the Ender Dragon/wither, but the boss bar will not connect with the boss's health. The Boss has 150 health if that helps.

Also, I want to know how if the boss gets to a certain health a command block with trigger an event.

1 Answer

First, set up the bossbar and make it visible to the player:

/bossbar add health "Bossbar Name"
/bossbar set health max 150
/bossbar set health players <player>

Then, in a repeating command block, run the below command to update the bossbar:

/execute store result bossbar minecraft:health value run data get entity <boss> Health

See How to detect a mobs health, on Java 1.17 for the "Also" question.