# BossBarHelper

`com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper`

**Since:** 1.2.1

A wrapper exposing the state of one boss bar known to the client.  
 
 `World.getBossBars()` returns a map keyed by the string from [getUUID()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getUUID-).  
 The boss-bar event's `bossBar` field is `null` when a bar is removed.  
 
 The percentage is the smoothed one the overlay animates towards rather than the
 value the server last sent: the bar eases from the previous percentage to the new
 one over 100 milliseconds, so reads can differ even when the server has sent nothing
 in between.  
 ```js
const bars = World.getBossBars();  
Chat.log(`${bars.size()} boss bar(s) on screen`);  
for (const entry of bars.entrySet()) {
  const bar = entry.getValue();  
  // the percentage is a fraction from 0 to 1, not a number from 0 to 100
  const percent = Math.round(bar.getPercent() * 100);  
  Chat.log(`${bar.getName().getString()} at ${percent}% (${bar.getColor()}, ${bar.getStyle()})`);  
}
 ```

## Constructors

### new BossBarHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_constructor-BossEvent-}

```js
new BossBarHelper(BossEvent b)
```

Wraps the supplied boss-bar event.

**Parameters:**
- `b`: raw boss event to wrap

## Methods

### getColor {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getColor-}

```js
getColor(): String
```

Returns the [BossEvent.BossBarColor](https://mappings.dev/1.21.8/net/minecraft/world/BossEvent$BossBarColor.html) enum name in uppercase,  
 so one of `PINK`, `BLUE`, `RED`, `GREEN`, `YELLOW`,  
 `PURPLE` or `WHITE`. These are the seven the game defines, and the
 string is what the TypeScript typings narrow this to.  
 This name does not uniquely identify the formatting: `PINK` and `RED`
 both use red formatting. Use [getColorFormat()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getColorFormat-) or [getColorValue()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getColorValue-)
 for the formatting or its RGB value.

**Returns:** the uppercase enum name.

**Since:** 1.2.1

### getColorFormat {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getColorFormat-}

```js
getColorFormat(): FormattingHelper
```

Returns the formatting associated with the bar's color.

**Returns:** the bar color's formatting.

**Since:** 1.8.4

### getColorValue {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getColorValue-}

```js
getColorValue(): int
```

Returns the packed RGB value of the bar's formatting, or `-1` if it has no RGB value.

**Returns:** the formatting's RGB value, or `-1` if absent.

**Since:** 1.8.4

### getName {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getName-}

```js
getName(): TextHelper
```

Returns the bar's title as a [TextHelper](../../TextHelper.md), preserving its text styling.

**Returns:** the bar's styled title.

**Since:** 1.2.1

### getPercent {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getPercent-}

```js
getPercent(): float
```

Returns the current smoothed progress as a fraction from `0` to `1`.  
 The client animates this value toward the latest progress received from the server.

**Returns:** current progress fraction; values are not converted to percentages.

**Since:** 1.2.1

### getStyle {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getStyle-}

```js
getStyle(): String
```

Returns the [BossEvent.BossBarOverlay](https://mappings.dev/1.21.8/net/minecraft/world/BossEvent$BossBarOverlay.html) enum name in uppercase,  
 so one of `PROGRESS`, `NOTCHED_6`, `NOTCHED_10`,  
 `NOTCHED_12` or `NOTCHED_20`. The notched ones are the same bar with
 the notches added, and the number is how many segments it is cut into.

**Returns:** the uppercase overlay enum name.

**Since:** 1.2.1

### getUUID {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getUUID-}

```js
getUUID(): String
```

Returns the bar's UUID as a string, matching its key in `World.getBossBars()`.

**Returns:** this bar's UUID.

**Since:** 1.2.1

### toString {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_toString-}

```js
toString(): String
```

Returns a diagnostic string containing the bar's plain name and raw progress value.

**Returns:** a diagnostic representation of the bar
