Hello guys. How make wither bar with custom name? In n*kkit is somethink like BossEventPacket, but how in PM?
PMMP doesn't have the BossEventPacket implemented yet, so you need to make the packets by yourself. I show you how to make a bossbar: 1. Make a file, BossEventPacket.php PHP: <?phpnamespace Core;use pocketmine\network\protocol\DataPacket;class BossEventPacket extends DataPacket{ const NETWORK_ID = 0x4a; public $eid; public $state; public function decode(){ $this->eid = $this->getUUID(); $this->state = $this->getUnsignedVarInt(); } public function encode(){ $this->reset(); $this->putEntityId($this->eid); $this->putUnsignedVarInt($this->state); }} Change the Core namespace to your plugin's namespace 2. Add these things to your main plugin: PHP: public function addWitherBar($p){$title = "§bMy special wither bar text";$pk = new AddEntityPacket(); $pk->eid = 9272; $pk->type = 12; $pk->x = $p->x; $pk->y = $p->y + 2; $pk->z = $p->z; $pk->yaw = 0; $pk->pitch = 0; $pk->metadata = [Entity::DATA_LEAD_HOLDER_EID => [Entity::DATA_TYPE_LONG, -1], Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, 0 ^ 1 << Entity::DATA_FLAG_SILENT ^ 1 << Entity::DATA_FLAG_INVISIBLE], Entity::DATA_SCALE => [Entity::DATA_TYPE_FLOAT, 0], Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $title], Entity::DATA_BOUNDING_BOX_WIDTH => [Entity::DATA_TYPE_FLOAT, 0], Entity::DATA_BOUNDING_BOX_HEIGHT => [Entity::DATA_TYPE_FLOAT, 0]]; $p->dataPacket($pk);$pk2 = new BossEventPacket();$pk2->eid = 9272;$pk2->state = 0;$p->dataPacket($pk2);} It will display a wither bar by spawning an invisible entity to you, used as your boss (keep in mind that MCPE accepts every living entity as your boss) $p is a Player object and the eid is 9272 because I want, you can use another random entity ID, but it shouldn't conflict with other entities' IDs. 3. If your lobby or whereever you want to spawn is is bigger than 32 blocks, then implement this code, this will prevent that the wither bar despawns after a distance of 32. PHP: public function moveWitherBar($p){$pk = new MoveEntityPacket();$pk->eid = 9272;$pk->x = $p->x;$pk->y = $p->y + 2;$pk->z = $p->z;$pk->yaw = 0;$pk->headYaw = 0;$pk->pitch = 0;$p->dataPacket($pk);} When this function is called, the boss entity will be teleported right above you. I recommend you to call it in a task of 1 - 5 seconds. Simply add the wither bar on join: PHP: public function onPlayerJoin(PlayerJoinEvent $event){$this->addWitherBar($event->getPlayer());} Some credits go to thebigsmileXD.
If the entity has no HP: 1. Create a new class and change the namespace PHP: <?phpnamespace Core;class BossHealth{ public function getMinValue(){ return 0; } public function getMaxValue(){ return 10; } public function getValue(){ return 10; } public function getName(){ return "minecraft:health"; } public function getDefaultValue(){ return 0; }} The getValue() function returns 10 because the pig I use as boss has a maxhealth of 10 2. Paste this right after the AddEntityPacket code in the class where you spawn the wither: PHP: $pk2 = new UpdateAttributesPacket();$pk2->entries[] = new BossHealth();$pk2->entityId = 9272; // here goes your wither id$p->dataPacket($pk2); Credits still go to thebigsmileXD.
Great thanks for referring me so often! BossBarAPI is fully core/spoon independ, it should work on all cores, because: It adds the network classes itself, it has attribute stuff (currently missing in pmmp) to set health, you can set he name etc etc.