21 public const NETWORK_ID = ProtocolInfo::BOSS_EVENT_PACKET;
42 public int $bossActorUniqueId;
43 public int $eventType;
45 public int $playerActorUniqueId;
46 public float $healthPercent;
48 public bool $darkenScreen;
52 private static function base(
int $bossActorUniqueId,
int $eventId) : self{
54 $result->bossActorUniqueId = $bossActorUniqueId;
55 $result->eventType = $eventId;
59 public static function show(
int $bossActorUniqueId,
string $title,
float $healthPercent,
bool $darkenScreen =
false,
int $color = BossBarColor::PURPLE,
int $overlay = 0) : self{
60 $result = self::base($bossActorUniqueId, self::TYPE_SHOW);
61 $result->title = $title;
62 $result->healthPercent = $healthPercent;
63 $result->darkenScreen = $darkenScreen;
64 $result->color = $color;
65 $result->overlay = $overlay;
69 public static function hide(
int $bossActorUniqueId) : self{
70 return self::base($bossActorUniqueId, self::TYPE_HIDE);
73 public static function registerPlayer(
int $bossActorUniqueId,
int $playerActorUniqueId) : self{
74 $result = self::base($bossActorUniqueId, self::TYPE_REGISTER_PLAYER);
75 $result->playerActorUniqueId = $playerActorUniqueId;
79 public static function unregisterPlayer(
int $bossActorUniqueId,
int $playerActorUniqueId) : self{
80 $result = self::base($bossActorUniqueId, self::TYPE_UNREGISTER_PLAYER);
81 $result->playerActorUniqueId = $playerActorUniqueId;
85 public static function healthPercent(
int $bossActorUniqueId,
float $healthPercent) : self{
86 $result = self::base($bossActorUniqueId, self::TYPE_HEALTH_PERCENT);
87 $result->healthPercent = $healthPercent;
91 public static function title(
int $bossActorUniqueId,
string $title) : self{
92 $result = self::base($bossActorUniqueId, self::TYPE_TITLE);
93 $result->title = $title;
97 public static function properties(
int $bossActorUniqueId,
bool $darkenScreen,
int $color = BossBarColor::PURPLE,
int $overlay = 0) : self{
98 $result = self::base($bossActorUniqueId, self::TYPE_PROPERTIES);
99 $result->darkenScreen = $darkenScreen;
100 $result->color = $color;
101 $result->overlay = $overlay;
105 public static function query(
int $bossActorUniqueId,
int $playerActorUniqueId) : self{
106 $result = self::base($bossActorUniqueId, self::TYPE_QUERY);
107 $result->playerActorUniqueId = $playerActorUniqueId;
112 $this->bossActorUniqueId = $in->getActorUniqueId();
114 switch($this->eventType){
115 case self::TYPE_REGISTER_PLAYER:
116 case self::TYPE_UNREGISTER_PLAYER:
117 case self::TYPE_QUERY:
121 case self::TYPE_SHOW:
125 case self::TYPE_PROPERTIES:
126 $this->darkenScreen = match($raw = $in->
getLShort()){
131 case self::TYPE_TEXTURE:
135 case self::TYPE_HEALTH_PERCENT:
138 case self::TYPE_TITLE:
147 $out->putActorUniqueId($this->bossActorUniqueId);
149 switch($this->eventType){
150 case self::TYPE_REGISTER_PLAYER:
151 case self::TYPE_UNREGISTER_PLAYER:
152 case self::TYPE_QUERY:
153 $out->putActorUniqueId($this->playerActorUniqueId);
156 case self::TYPE_SHOW:
157 $out->putString($this->title);
158 $out->putLFloat($this->healthPercent);
160 case self::TYPE_PROPERTIES:
161 $out->putLShort($this->darkenScreen ? 1 : 0);
162 case self::TYPE_TEXTURE:
166 case self::TYPE_HEALTH_PERCENT:
167 $out->putLFloat($this->healthPercent);
169 case self::TYPE_TITLE:
170 $out->putString($this->title);
178 return $handler->handleBossEvent($this);