Skip to content

Commit 408fe79

Browse files
committed
feat(boss): add CREATE_FOG flag
1 parent db0f5e4 commit 408fe79

File tree

8 files changed

+35
-16
lines changed

8 files changed

+35
-16
lines changed

endstone/boss/__init__.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,35 @@ class BarColor(enum.Enum):
2020

2121
class BarFlag(enum.Enum):
2222
DARKEN_SKY = 0
23+
"""
24+
Darkens the sky like during fighting a wither.
25+
"""
26+
CREATE_FOG = 1
27+
"""
28+
Creates fog around the world.
29+
"""
2330

2431
class BarStyle(enum.Enum):
2532
SOLID = 0
33+
"""
34+
Makes the boss bar solid (no segments)
35+
"""
2636
SEGMENTED_6 = 1
37+
"""
38+
Splits the boss bar into 6 segments
39+
"""
2740
SEGMENTED_10 = 2
41+
"""
42+
Splits the boss bar into 10 segments
43+
"""
2844
SEGMENTED_12 = 3
45+
"""
46+
Splits the boss bar into 12 segments
47+
"""
2948
SEGMENTED_20 = 4
49+
"""
50+
Splits the boss bar into 20 segments
51+
"""
3052

3153
class BossBar:
3254
"""

include/endstone/boss/bar_color.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#pragma once
1616

1717
namespace endstone {
18-
1918
enum class BarColor {
2019
Pink = 0,
2120
Blue = 1,
@@ -26,5 +25,4 @@ enum class BarColor {
2625
RebeccaPurple = 6,
2726
White = 7,
2827
};
29-
3028
} // namespace endstone

include/endstone/boss/bar_flag.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
#pragma once
1616

1717
namespace endstone {
18-
1918
enum class BarFlag {
2019
/**
2120
* @brief Darkens the sky like during fighting a wither.
2221
*/
2322
DarkenSky,
24-
Count,
23+
/**
24+
* @brief Creates fog around the world.
25+
*/
26+
CreateFog,
2527
};
26-
2728
} // namespace endstone

include/endstone/boss/bar_style.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#pragma once
1616

1717
namespace endstone {
18-
1918
enum class BarStyle {
2019
/**
2120
* @brief Makes the boss bar solid (no segments)
@@ -38,5 +37,4 @@ enum class BarStyle {
3837
*/
3938
Segmented20,
4039
};
41-
4240
} // namespace endstone

include/endstone/boss/boss_bar.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
#include "endstone/boss/bar_style.h"
2323

2424
namespace endstone {
25-
2625
class Player;
27-
2826
/**
2927
* @brief Represents a boss bar that is displayed to players.
3028
**/

src/endstone/core/boss/boss_bar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void EndstoneBossBar::send(BossEventUpdateType event_type, Player &player)
163163
pk->color = static_cast<BossBarColor>(color_);
164164
pk->overlay = static_cast<BossBarOverlay>(style_);
165165
pk->darken_screen = hasFlag(BarFlag::DarkenSky);
166+
pk->create_world_fog = hasFlag(BarFlag::CreateFog);
166167
handle.sendNetworkPacket(*packet);
167168
}
168169

src/endstone/core/boss/boss_bar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class EndstoneBossBar : public BossBar {
6161
float progress_{1.0F};
6262
BarColor color_;
6363
BarStyle style_;
64-
std::bitset<static_cast<int>(BarFlag::Count)> flags_;
64+
std::bitset<2> flags_;
6565
bool visible_{true};
6666
mutable std::unordered_set<UUID> players_;
6767
};

src/endstone/python/boss.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ void init_boss(py::module_ &m)
3232
.finalize();
3333

3434
py::native_enum<BarFlag>(m, "BarFlag", "enum.Enum") //
35-
.value("DARKEN_SKY", BarFlag::DarkenSky)
35+
.value("DARKEN_SKY", BarFlag::DarkenSky, "Darkens the sky like during fighting a wither.")
36+
.value("CREATE_FOG", BarFlag::CreateFog, "Creates fog around the world.")
3637
.finalize();
3738

3839
py::native_enum<BarStyle>(m, "BarStyle", "enum.Enum") //
39-
.value("SOLID", BarStyle::Solid)
40-
.value("SEGMENTED_6", BarStyle::Segmented6)
41-
.value("SEGMENTED_10", BarStyle::Segmented10)
42-
.value("SEGMENTED_12", BarStyle::Segmented12)
43-
.value("SEGMENTED_20", BarStyle::Segmented20)
40+
.value("SOLID", BarStyle::Solid, "Makes the boss bar solid (no segments)")
41+
.value("SEGMENTED_6", BarStyle::Segmented6, "Splits the boss bar into 6 segments")
42+
.value("SEGMENTED_10", BarStyle::Segmented10, "Splits the boss bar into 10 segments")
43+
.value("SEGMENTED_12", BarStyle::Segmented12, "Splits the boss bar into 12 segments")
44+
.value("SEGMENTED_20", BarStyle::Segmented20, "Splits the boss bar into 20 segments")
4445
.finalize();
4546

4647
py::class_<BossBar>(m, "BossBar", "Represents a boss bar that is displayed to players.")

0 commit comments

Comments
 (0)