1

I want to write a datapack which has several different features which use bossbars. I need one of the bossbars to always be at the top of the list onscreen, so the one highest on the screen, while others come and go, possibly quickly or possibly slowly (they will show the health of mobs the player is looking at).

I thought that bossbars were ordered alphabetically, but the wiki doesn't say. I don't want to have to name my bossbar "AAAAAAAAAAAAAAAAAAAAAAAAAAA", so I was wondering if there is a way to use an invisible ASCII character or something else to ensure it is always at the top. I know that you can change the colors of bossbars too (to differentiate it anywhere in the list), but having it in the same position always would be great.

I can't test anything because I haven't had and won't have my computer for a while, so I don't necessarily need commands but just a method to solve this.

  • "A" is sorted alphabetically before "AAAAAAAAAA". – Fabian Röling Jun 24 at 22:30
1

I did some testing in 1.14.3 and the bossbars are in the order that they were added to a player, the first one you add to a player will be the highest for that player.

I haven´t tried this in multiplayer, so a bossbar may move all the way down to the list when you try to add it to @a again, to add more players, other than that it should always stay at the top if it is at the top.

Edit:

This does apparently not survive reloading the world and requires more testing.

Update:

The bossbar with the id 0 seems to always be on top after reloading the map. After that 2, 1, 4, 3, 6, 5,... (+2; -1; +2; -1;...)
This may still require more testing.

  • 2
    This does not survive reloading a world. I just created three bossbars, "a", "c" and "b". I closed and reopened the world and they were in the order "b" "a" "c". – Fabian Röling Jun 27 at 1:41
  • They seem to end up in a random, but determined (always the same) order when restarting the world... This is really weird. It looks like it is determined by the id of the bossbar, but the ordering looks like this: 0, 2, 1, 4, 3,... for some reason. – user232393 Jun 27 at 20:29
  • What do you mean by id '0'? Like, it is named '0' internally ie namespace:0, or it is the first one you created (and 1, 2, 3, 4.. are the next ones you created)? – Nik3141 Jun 28 at 22:27
  • The syntax for adding a bossbar is /bossbar add <id> <name>, I mean the number that you use for id. (Now that I think of it, I'm not sure if it has to be a number, I only ever tried to use numbers) – user232393 Jun 28 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.