mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
BossEventPacket: add some functions to ease creation
This commit is contained in:
parent
287c8c2dd4
commit
3b5df90b0b
@ -66,6 +66,57 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
public $overlay;
|
public $overlay;
|
||||||
|
|
||||||
|
private static function base(int $bossEntityUniqueId, int $eventId) : self{
|
||||||
|
$result = new self;
|
||||||
|
$result->bossEid = $bossEntityUniqueId;
|
||||||
|
$result->eventType = $eventId;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function show(int $bossEntityUniqueId, string $title, float $healthPercent, int $unknownShort = 0) : self{
|
||||||
|
$result = self::base($bossEntityUniqueId, self::TYPE_SHOW);
|
||||||
|
$result->title = $title;
|
||||||
|
$result->healthPercent = $healthPercent;
|
||||||
|
$result->unknownShort = $unknownShort;
|
||||||
|
$result->color = 0; //hardcoded due to being useless
|
||||||
|
$result->overlay = 0;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function hide(int $bossEntityUniqueId) : self{
|
||||||
|
return self::base($bossEntityUniqueId, self::TYPE_HIDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function registerPlayer(int $bossEntityUniqueId, int $playerEntityUniqueId) : self{
|
||||||
|
$result = self::base($bossEntityUniqueId, self::TYPE_REGISTER_PLAYER);
|
||||||
|
$result->playerEid = $playerEntityUniqueId;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function unregisterPlayer(int $bossEntityUniqueId, int $playerEntityUniqueId) : self{
|
||||||
|
$result = self::base($bossEntityUniqueId, self::TYPE_UNREGISTER_PLAYER);
|
||||||
|
$result->playerEid = $playerEntityUniqueId;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function healthPercent(int $bossEntityUniqueId, float $healthPercent) : self{
|
||||||
|
$result = self::base($bossEntityUniqueId, self::TYPE_HEALTH_PERCENT);
|
||||||
|
$result->healthPercent = $healthPercent;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function title(int $bossEntityUniqueId, string $title) : self{
|
||||||
|
$result = self::base($bossEntityUniqueId, self::TYPE_TITLE);
|
||||||
|
$result->title = $title;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function unknown6(int $bossEntityUniqueId, int $unknownShort) : self{
|
||||||
|
$result = self::base($bossEntityUniqueId, self::TYPE_UNKNOWN_6);
|
||||||
|
$result->unknownShort = $unknownShort;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
protected function decodePayload() : void{
|
protected function decodePayload() : void{
|
||||||
$this->bossEid = $this->getEntityUniqueId();
|
$this->bossEid = $this->getEntityUniqueId();
|
||||||
$this->eventType = $this->getUnsignedVarInt();
|
$this->eventType = $this->getUnsignedVarInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user