Minecraft Data Packs / Quality of Life

Setting up a bossbar in Minecraft 1.13

    • 36,194 views, 4 today
    • 0 downloads, 0 today
    • 31
    • 15
    • 16
    ShelLuser avatar ShelLuser
    Level 55 : Grandmaster Engineer
    Hi gang!


    The latest snapshot (18w05a) got released today and I'm really excited about this one because we finally get vanilla access to bossbars. You know: those things you get to see when you're fighting (mini) bosses such as the Ender dragon or the wither. Until now your best shot was to either summon a (renamed) boss somewhere underground (while making sure it was invulnerable so it wouldn't die) and then somehow continue to update/change its health in order to get a somewhat usable bossbar.

    Another option is of course to use plugins, but we're not going to address those here.

    But with the release of 1.13 we have a much better option for this: the /bossbar command!

    Step 1 - Creating a bossbar

    In order to use a bossbar you first need to create it. You'll need to define an id and a name. The id is basically the same as any other in Minecraft; consisting of a namespace and an actual name. The name of the bossbar should be a string ("JSON object") which contains the name as it will be displayed on screen.

    So to make the two bossbars as shown in the blog profile picture I used:
    • /bossbar create catslair:aya "AyaWarrior"
    • /bossbar create catslair:shell "ShellShocker"
    Easy, right? If you don't use a namespace of your own then 'minecraft' will be used. I don't know for sure but I could imagine that this might give us an option to overrule existing bossbars. But... that's a wild guess on my part for now.

    Step 2 - Setting up the bossbar properties

    Now that we have a bossbar we'll need to set it up to make it actually usable. In my example we're going to use the bossbar to display the health of the players. So the first step is to check a players health value. How to do that? Using the new /data command:

    My data collection ;)

    Here I used /data get entity ShelLuser and I marked the section which is interesting for us: my health. By default /data will display everything but you can limit the output to a single property. So: /data get entity ShelLuser Health.

    However, this also creates a bit of a problem. The maximum health value of a player is 20. But a bossbar has a maximum value of 100 by default. But fortunately we can change this, so the next step is to make the bossbar actually usable for displaying a players health:
    • /bossbar set catslair:aya max 20
    • /bossbar set catslair:shell max 20
    So if you're going to set this up then always check the maximum health value for whatever entity you're going to use and then change the bossbar's maximum value accordingly. Otherwise it won't be fully filled out (20 out of 100 would mean that it would only be filled out for 1/5th part).

    Next I wanted to make the bossbars easier to recognize, so I'm using different colors for both Aya and myself. I used blue, Aya insisted on using pink. Easily done:
    • /bossbar set catslair:aya color pink
    • /bossbar set catslair:shell color blue

    Step 3 - Actually using the bossbar(s)

    The arena of death! :)
    You'll need an arena in order to PVP, right? ;)

    So how to build an arena... Ok, that's bad pun :)

    Back to the bossbars! A bossbar isn't automatically visible to all players, you need to set that up yourself. This allows you to customize it in any way you want. For example I could set it up so that Aya only gets to see her own health and I get to see both hers and my own (no, I'm not trying to cheat, whatever gave you that idea? :)).

    This can be extremely useful if you're setting up a boss fight of your own. You could set it up so that only players within a certain range of the boss get to see its bossbar while everyone outside that area sees nothing. In our example above I simply set it up so that both Aya and myself could both see the bossbars. Easily done:
    • /bossbar set catslair:aya players @a[distance=..20]
    • /bossbar set catslair:shell players @a[distance=..20]
    So all players (which is basically only us two) who are within a range of 20 blocks will get to see these bossbars. Keep in mind that these aren't dynamic settings or anything. So all this does is turn the bossbar on for all players within 20 blocks. Once on then this setting stays on. So it doesn't matter if I were to teleport myself 100 blocks away or something like that.

    Now we pretty much have everything in place. But there's one last thing missing. How do we get the players health value into the bossbar?

    Fortunately Mojang also thought about that. We can use the /execute command to run a command and then store its output value somewhere else. Somewhere like a bossbar for example. We already discovered how to get a players health, so all we have to do now is actually store it:
    • /execute store result bossbar catslair:aya value run data get entity AyanamiKun Health
    • /execute store result bossbar catslair:shell value run data get entity ShelLuser Heath
    Boss command blocks!
    Everything gets setup with these command blocks, the repeating on the left updates our bossbars

    To make this easier on us I set up these command blocks which do everything for setting up the fight. First it switches both Aya and myself from Creative into Adventure mode (to prevent us from accidentally destroying the arena). Next it clears out our inventories and gives us one diamond sword and it also sets the bossbars to visible. And finally, the repeating block on the left (and the chain command block behind it) continues to /execute the store commands I mentioned above, but only if it gets a redstone signal.

    When turned off the opposite happens: the repeating command block will stop updating the bossbars, the bossbars are set invisible and both Aya and myself are switched back to Creative mode.

    Bonus: Setting up a real bossfight!

    Uh oh, Herobrine is here, run!
    Who said Herobrine wasn't real? ;)

    Now, using bossbars for players is fun and all but as some of you reminded me: it's called a bossbar for a reason. So let's set up a bossfight with the one and only Herobrine! And all you need is 4 command blocks.

    Step one - Setting up the boss

    Now, I'm not going to pay too much attention to this section (this blog is about bossbars afterall) but I do want to stress out that if you want to learn more about mobs and their properties then /data will become an invaluable command to you. It's only thanks to /data (and not the Minecraft wiki for a change) that I managed to set up the increased follow range for example.

    But let's take this one step at a time. Here I have summoned a zombie which has a lot of special properties:
    • It can break through doors no matter what.
    • It picks up loot and uses it.
    • It doesn't despawn.
    • It wears a player head ("Herobrine") which also prevents it from catching fire.
    • It runs about 8 times faster than a normal zombie (1.5 vs. the normal 0.23).
    • It follows players up to a range of 50 blocks (this is normally 35).
    • It has an increased attack damage (8 vs. 3, so it does 1.5 times more damage).
    • It has four times the amount of health as a normal zombie (80 vs. the normal value of 20).
    • And finally: it drops the same items as a zombie pigman (so you may win a gold nugget, lucky you! (of course Herobrine is trolling you!)).
    How to summon this bad boy? I suggest using a command block because of the command length, and also because this will allow us to ensure that only one Herobrine can be spawned at a time:

    execute unless entity @e[tag=miniboss] run summon minecraft:zombie ~ ~1 ~ {CustomName:"{\"text\":\"Herobrine\",\"color\":\"white\",\"bold\":\"true\",\"italic\":\"true\"}",CustomNameVisible:1,CanBreakDoors:1,CanPickUpLoot:1,PersistenceRequired:1,Tags:["miniboss"],DeathLootTable:"entities/zombie_pigman",Attributes:[{Name:"generic.maxHealth",Base:80b},{Name:"generic.attackDamage",Base:8d},{Name:"generic.movementSpeed",Base:1.50d},{Base:50.0d,Modifiers:{UUIDMost:-1572945825646885237L,UUIDLeast:-5038956045173896349L,Operation:1}],Name: "generic.followRange"}],Health:80f,ArmorItems:[{},{},{},{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:"Herobrine"}}]}

    This is also a demonstration of the 1.13 command improvements: the command to summon Herobrine is only executed as long as there isn't already one around. But as said: I won't be explaining this command in too much detail, you do the math :)

    Step two - Setting up the bossbar

    Basically the same as above, only this time I'm going to make it easier on myself and use the default namespace. So:
    • /bossbar create herobrine {"text":"Herobrine","color":"dark_red"}
    • /bossbar set herobrine color green
    • /bossbar set herobrine max 80
    This should pretty much speak for itself. Remember: a bossbar has a default maximum value of 100. So in order to make sure the bossbar will be completely filled out we need to set that back to 80 (which is Herobrine's maximum health).

    Step three - Setting up the automated updates

    You're going to need three command blocks (as shown in the screenshot above).

    #1: Repeating unconditional command block

    execute if entity @e[tag=miniboss] store result bossbar herobrine value run data get entity @e[tag=miniboss,limit=1] Health

    This command block will only run if the system actually detects an entity with the tag miniboss. This helps us to reduce the load on the system a bit because the system will only need to check if the entity exists. It doesn't have to try and get any properties nor does it have to continue updating the bossbar all the time.

    #2: Chain conditional command block

    execute as @e[tag=miniboss] at @s run bossbar set herobrine players @a[distance=..50]

    This command makes sure that if we come within a 50 blocks range of Herobrine then we'll immediately get to see the bossbar. But there's more: because this command gets repeated all the time it will also ensure that if you move out of range then the bossbar will disappear.

    No bossbar when moving out of range
    When you move 50 blocks away then the bossbar will become invisible to you.

    #3: Chain unconditional command block

    execute unless entity @e[tag=miniboss] run bossbar set herobrine players

    This will run the bossbar command under the condition that there is no entity around which has the miniboss tag. The effect is that the bossbar will disappear for all players as soon as the boss has been defeated.

    Getting your own Herobrine

    In case you're interested in fighting with Herobrine but you don't want to bother with all these difficult commands then you don't have to: you can download my Herobrine datapack and use that instead :)

    And there you have it!

    How to set up the bossbars in Minecraft 1.13 (well, basically snapshot 18w05a at the time of writing) and how to actually use them for a real bossfight.

    Hope you enjoyed this, thanks for reading!
    CreditAyanamiKun (helped with the arena & demonstration), Herobrine (I used his head).
    CompatibilityMinecraft 1.13

    2 Update Logs

    Update #2 : by ShelLuser 10/16/2018 8:14:12 amOct 16th, 2018

    The blog is now fully "1.13 compliant".
    • Removed the warning about the blog describing a snapshot feature; 1.13 has been released a long time ago.
    • Added a reference to my Herobrine datapack; you don't have to mess with commands to fight Herobrine.
    • Fixed a few minor typoes.

    Create an account or sign in to comment.

    03/06/2021 6:15 am
    Level 29 : Expert Warrior
    Hejjo_eggs avatar
    /summon herobrine{HandItems:Bedrock_Sword,ArmorItems:Bedrock_Helmet,Bedrock_Chestplate,Bedrock_leggings,Bedrock_Boots,Invulnerable:1}
    05/10/2021 10:24 am
    Level 49 : Master Hunter
    BrinePlayz avatar
    There Should Be Bedrock Armor And Herobrine First To Summon
    02/21/2021 1:25 am
    Level 35 : Artisan Nerd
    Melygoomba avatar
    this is still working?
    03/11/2021 8:58 pm
    Level 55 : Grandmaster Engineer
    ShelLuser avatar
    Sorry for a late comment, yah, the general jist is still working, there's still /bossbar and it hasn't changed much.
    02/08/2020 5:03 pm
    Level 1 : New Miner
    SandStorm61 avatar
    Hey, I am trying this in 1.16 snapshot, and I have a question.

    Is there a way to create an effect once the boss dies? I know this isn't entirely related to the bossbar command but it might be....? Like is there a way to detect when the bossbar hits 0 to create an effect or anything?
    02/09/2020 7:44 pm
    Level 55 : Grandmaster Engineer
    ShelLuser avatar
    No worries about being directly related, it's a good question IMO and it's sorta related ;)

    What I would do is set up a repeating command block (perhaps triggered by a redstone torch, so that you can turn it off somehow?) and make it check for the disappearance of the boss.

    See my #3 above: "execute unless....", then do your stuff behind it. Make sure that you add checks (either use a tag or as mentioned maybe a redstone torch) so that this whole thing runs only once.

    Hope this can give you some ideas...
    10/20/2019 7:08 pm
    Level 1 : New Explorer
    AyanamiKun avatar
    Progress: 0% complete? ;)

    I think u need to edit this thing again!
    03/29/2019 12:44 pm
    Level 1 : New Miner
    TheCursedStudio avatar
    12/30/2018 5:09 pm
    Level 12 : Journeyman Artist
    LazyWhite avatar
    IDK How to use chain command blocks...
    I'm a basic commander...basic!!
    10/17/2018 8:56 pm
    Level 44 : Master Procrastinator
    Toby Minceraft
    Toby Minceraft avatar
    Would I be able to use this in a custom map I am making? Of course, giving credit where credit is due.

    I would use it as a boss battle for the final stage of my map (it's called Super Mine Bros.). I would go for a Bowser fight, but that would take a bit longer to code than this.
    Planet Minecraft


    © 2010 - 2022