Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions crates/minecraft_packets/src/play/boss_bar_packet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
use minecraft_protocol::prelude::*;
use pico_text_component::prelude::Component;

#[derive(PacketOut)]
pub struct BossBarPacket {
#[pvn(735..)]
pub v1_16_uuid: Uuid,
#[pvn(..735)]
pub uuid_most_sig: u64,
#[pvn(..735)]
pub uuid_least_sig: u64,
pub action: BossBarAction,
}

pub enum BossBarAction {
Add {
title: Component,
health: f32,
color: BossBarColor,
division: BossBarDivision,
flags: u8,
},
Remove,
UpdateHealth {
health: f32,
},
UpdateTitle {
title: Component,
},
UpdateStyle {
color: BossBarColor,
division: BossBarDivision,
},
UpdateFlags {
flags: u8,
},
}

#[derive(Debug, Clone, Copy)]
#[repr(i32)]
pub enum BossBarColor {
Pink = 0,
Blue = 1,
Red = 2,
Green = 3,
Yellow = 4,
Purple = 5,
White = 6,
}

#[derive(Debug, Clone, Copy)]
#[repr(i32)]
pub enum BossBarDivision {
NoDivision = 0,
SixNotches = 1,
TenNotches = 2,
TwelveNotches = 3,
TwentyNotches = 4,
}

impl EncodePacket for BossBarAction {
fn encode(
&self,
writer: &mut BinaryWriter,
protocol_version: ProtocolVersion,
) -> Result<(), BinaryWriterError> {
match self {
BossBarAction::Add {
title,
health,
color,
division,
flags,
} => {
VarInt::new(0).encode(writer, protocol_version)?;
title.clone().encode(writer, protocol_version)?;
health.encode(writer, protocol_version)?;
VarInt::new(*color as i32).encode(writer, protocol_version)?;
VarInt::new(*division as i32).encode(writer, protocol_version)?;
flags.encode(writer, protocol_version)?;
}
BossBarAction::Remove => {
VarInt::new(1).encode(writer, protocol_version)?;
}
BossBarAction::UpdateHealth { health } => {
VarInt::new(2).encode(writer, protocol_version)?;
health.encode(writer, protocol_version)?;
}
BossBarAction::UpdateTitle { title } => {
VarInt::new(3).encode(writer, protocol_version)?;
title.clone().encode(writer, protocol_version)?;
}
BossBarAction::UpdateStyle { color, division } => {
VarInt::new(4).encode(writer, protocol_version)?;
VarInt::new(*color as i32).encode(writer, protocol_version)?;
VarInt::new(*division as i32).encode(writer, protocol_version)?;
}
BossBarAction::UpdateFlags { flags } => {
VarInt::new(5).encode(writer, protocol_version)?;
flags.encode(writer, protocol_version)?;
}
}
Ok(())
}
}
1 change: 1 addition & 0 deletions crates/minecraft_packets/src/play/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod boss_bar_packet;
pub mod chunk_data_and_update_light_packet;
pub mod client_bound_keep_alive_packet;
pub mod commands_packet;
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_10/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
},
"minecraft:player_info_update": {
"protocol_id": 45
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_11/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
},
"minecraft:player_info_update": {
"protocol_id": 45
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_12/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
},
"minecraft:player_info_update": {
"protocol_id": 45
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_12_1/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
},
"minecraft:player_info_update": {
"protocol_id": 46
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_13/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 63
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_14/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 67
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_15/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 68
},
"minecraft:boss_event": {
"protocol_id": 13
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_16/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 68
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_16_2/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 68
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_17/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 77
},
"minecraft:boss_event": {
"protocol_id": 13
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_18/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 77
},
"minecraft:boss_event": {
"protocol_id": 13
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_18_2/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 77
},
"minecraft:boss_event": {
"protocol_id": 13
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_19/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 77
},
"minecraft:boss_event": {
"protocol_id": 10
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_19_1/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 80
},
"minecraft:boss_event": {
"protocol_id": 10
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_19_3/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 78
},
"minecraft:boss_event": {
"protocol_id": 10
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_19_4/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 82
},
"minecraft:boss_event": {
"protocol_id": 11
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_20/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 82
},
"minecraft:boss_event": {
"protocol_id": 11
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_20_2/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 84
},
"minecraft:boss_event": {
"protocol_id": 10
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_20_3/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 86
},
"minecraft:boss_event": {
"protocol_id": 10
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_20_5/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
},
"minecraft:set_entity_data": {
"protocol_id": 88
},
"minecraft:boss_event": {
"protocol_id": 10
}
},
"serverbound": {
Expand Down
3 changes: 3 additions & 0 deletions data/generated/V1_9/reports/packets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
},
"minecraft:player_info_update": {
"protocol_id": 45
},
"minecraft:boss_event": {
"protocol_id": 12
}
},
"serverbound": {
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default defineConfig({
{ text: "Proxy Integration", link: "/config/proxy-integration.html" },
{ text: "Server List", link: "/config/server-list.html" },
{ text: "Tab List", link: "/config/tab-list.html" },
{ text: "Boss Bar", link: "/config/boss-bar.html" },
{ text: "Experimental World Features", link: "/config/experimental-world.html" },
{
text: "Default Configuration",
Expand Down
68 changes: 68 additions & 0 deletions docs/config/boss-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Boss Bar Settings

Representing the `[boss_bar]` section in `server.toml`.

## Boss Bar Title

The title text displayed at the top of the player list.
The title supports [MiniMessage formatting](/customization/message-formatting.html) for colors and styling.

:::code-group
```toml [server.toml] {2}
[boss_bar]
title = "<blue><bold>Welcome to PicoLimbo!</bold></blue>"
```
:::

## Boss Bar Health

The health of the boss bar, represented as a float between `0.0` (empty) and `1.0` (full).

:::code-group
```toml [server.toml] {2}
[tab_list]
health = 1.0
```
:::

## Boss Bar Color

The color of the boss bar.

:::code-group
```toml [server.toml] {2}
[boss_bar]
color = "blue"
```
:::

Possible values:
```
pink
blue
red
green
yellow
purple
white
```

## Boss Bar Divisions

The number of divisions in the boss bar, affecting its visual segmentation.

:::code-group
```toml [server.toml] {2}
[boss_bar]
division = 0
```
:::

Possible values:
```
0 - No divisions
6 - 6 segments
10 - 10 segments
12 - 12 segments
20 - 20 segments
```
Loading
Loading