1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Boss Bar

Discussion in 'Development' started by TheDiamondYT, Mar 21, 2018.

  1. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    i'm trying to send a boss bar as a test but it freezes the client.

    Here are the options im setting
    PHP:
    $bossPacket = new BossEventPacket();
    $bossPacket->bossEid 0;
    $bossPacket->eventType 0//SHOW
    $bossPacket->title "Wither";
    $bossPacket->healthPercent 1;
    $bossPacket->color 0;
    $bossPacket->playerEid = (player eid which i inserted manuallyi'll make it automated later)
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    You are not sending bossbar, boss event packet only update it.
     
  3. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    How do i send it then ?
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    With AddEntityPacket
     
  5. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Yeah but what is the minimum amount of code that i need to spawn it? i see BossBarAPI but it sets lots of seemingly useless metadata
     
  6. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    I don't think you can spawn without it
     
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I'm not sure about this, but I think you only want this
    Entity::DATA_LEAD_HOLDER_EID
    Entity::DATA_NAMETAG
    in metadata to create the bossbar
     
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You did it right, let me rewrite it a bit.
    PHP:
    $pk = new BossEventPacket();
    $pk->bossEid $bossEid;
    $pk->eventType BossEventPacket::TYPE_SHOW;
    $pk->healthPercent 1;
    $pk->title "";
    $bossEid has to be the Entity::getId() of any entity provided it is spawned to the player. But since you wanted minimal code, you can send an AddEntityPacket() to the client.
    PHP:
    $pk = new AddEntityPacket();
    $pk->type Entity::ZOMBIE;
    $pk->entityRuntimeId $bossEid Entity::$entityCount++:
    $pk->position = new Vector3();
    $pk->metadata[Entity::DATA_NAMETAG] = [Entity::DATA_TYPE_STRING"Title for the bossbar"];
    I'd say send the AddEntityPacket before BossEventPacket, but it should work irrespective of the order of packets.

    P.S: BossEventPacket->bossEid and BossEventPacket->eventType are mandatory fields. The rest of the fields depend upon the value of BossEventPacket->eventType. For example, in your case (BossEventPacket::TYPE_SHOW), the other mandatory fields would be BossEventPacket->title and BossEventPacket->healthPercent.

    Check BossEventPacket::encodePayload() for mandatory fields on the basis of BossEventPacket::$eventType.
     
    Last edited: Mar 22, 2018
    NickTehUnicorn likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.