BossBar 5.46.0
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 = 10Ticks 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() : floatReturns the fraction of health displayed (0-1).
getRange()
php
public function getRange() : floatgetTitle()
php
public function getTitle() : stringgetViewers()
php
public function getViewers() : arrayhide()
php
public function hide(\pocketmine\player\Player $player) : voidhideAll()
php
public function hideAll() : voidisViewer()
php
public function isViewer(\pocketmine\player\Player $player) : boolsetTitle()
php
public function setTitle(string $title) : voidsetVisible()
php
public function setVisible(bool $visible) : voidHides the bar from everyone until shown again (e.g. during the boss' death animation).
show()
php
public function show(\pocketmine\player\Player $player) : voidtick()
php
public function tick() : voidCalled every tick by the boss: updates the players who see the bar and the displayed health.
