Minecraft – (Java Minecraft 1.14.3) Can a bossbar show different values to different players

minecraft-commandsminecraft-java-edition

I would like to use a bossbar, with value set with execute store result bossbar, to hold the 'mana' value for each player in my datapack (which is held in a scoreboard so it can be manipulated in the background by various functions).

However, I can't find an option for which player's value to set, and can only find a setting for which players the bossbar is visible for. Are bossbar values global or would I need to make one bossbar per player that I want to display a mana amount for?

If bossbar values are global, what alternatives are there for making some type of bar type display? I don't want to use scoreboard numbers because they are ugly. I'm open to particles, resource packs, anything but mods really.

Best Answer

You can make one bossbar per mana level, rather than per player. To make a mana system where you can have between 0 and 4 mana you would have to first create the bossbars, set their values, and set their maximal values. You only need to do this once:

bossbar add mana0 "Mana"
bossbar add mana1 "Mana"
bossbar add mana2 "Mana"
bossbar add mana3 "Mana"
bossbar add mana4 "Mana"

bossbar set minecraft:mana0 max 4
bossbar set minecraft:mana1 max 4
bossbar set minecraft:mana2 max 4
bossbar set minecraft:mana3 max 4
bossbar set minecraft:mana4 max 4

bossbar set minecraft:mana0 value 0
bossbar set minecraft:mana1 value 1
bossbar set minecraft:mana2 value 2
bossbar set minecraft:mana3 value 3
bossbar set minecraft:mana4 value 4

You would then repeatedly (each tick) set the players for each bossbar.
I'm assuming that the mana value is held in a scoreboard objective with the objective name mana. If that is not the case for you, then you may have to modify these commands.

bossbar set minecraft:mana0 players @a[scores={mana=..0}]
bossbar set minecraft:mana1 players @a[scores={mana=1}]
bossbar set minecraft:mana2 players @a[scores={mana=2}]
bossbar set minecraft:mana3 players @a[scores={mana=3}]
bossbar set minecraft:mana4 players @a[scores={mana=4..}]