Skip to content

BossBar 5.46.0 ​

final class · pocketmine\entity\boss\BossBar · source

The boss bar of a boss entity (vanilla "minecraft:boss" component): shown to the players who see the boss within the HUD range, with the boss' health. The bar is attached to the boss entity itself (BossEvent with the boss' actor ID), like vanilla, so no fake entity is needed.

Constants ​

VIEWER_UPDATE_INTERVAL ​

php
public const VIEWER_UPDATE_INTERVAL = 10

Ticks between two checks of which players are in range.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Living $boss, float $range, string $title, int $color = \pocketmine\network\mcpe\protocol\types\BossBarColor::PINK)

getPercent() ​

php
public function getPercent() : float

Returns the fraction of health displayed (0-1).

getRange() ​

php
public function getRange() : float

getTitle() ​

php
public function getTitle() : string

getViewers() ​

php
public function getViewers() : array

hide() ​

php
public function hide(\pocketmine\player\Player $player) : void

hideAll() ​

php
public function hideAll() : void

isViewer() ​

php
public function isViewer(\pocketmine\player\Player $player) : bool

setTitle() ​

php
public function setTitle(string $title) : void

setVisible() ​

php
public function setVisible(bool $visible) : void

Hides the bar from everyone until shown again (e.g. during the boss' death animation).

show() ​

php
public function show(\pocketmine\player\Player $player) : void

tick() ​

php
public function tick() : void

Called every tick by the boss: updates the players who see the bar and the displayed health.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.