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

Solved Riding And Rider Code,EntityLink

Discussion in 'Development' started by Irpan, Jul 5, 2020.

  1. Irpan

    Irpan Creeper

    Messages:
    2
    GitHub:
    IrpanXstrome
    Hello, I Need a Code EntityLink Packet That Works on Pocketmine 3.14.0 I tried using the code first, but an error

    public function addLink(Entity $entity, int $type): void {
    $this->eid = Entity::$entityCount++;
    $this->removeLink($entity, $type);
    $viewers = $this->getViewers();

    switch($type) {
    case self::LINK_RIDER:
    $link = new EntityLink();
    $link->fromEntityUniqueId = $this->getId();
    $link->type = EntityLink::TYPE_RIDER;
    $link->toEntityUniqueId = $entity->getId();
    $link->immediate = true;
    $link->causedByRider = true;

    if($entity instanceof Player) {
    $pk = new SetEntityLinkPacket();
    $pk->link = $link;
    $entity->dataPacket($pk);

    $link_2 = new EntityLink();
    $link_2->fromEntityUniqueId = $this->getId();
    $link_2->type = EntityLink::TYPE_RIDER;
    $link_2->toEntityUniqueId = 0;
    $link_2->immediate = true;
    $link_2->causedByRider = true;

    $pk = new SetEntityLinkPacket();
    $pk->link = $link_2;
    $entity->dataPacket($pk);
    unset($viewers[$entity->getLoaderId()]);
    }
    break;
    case self::LINK_RIDING:
    $link = new EntityLink();
    $link->fromEntityUniqueId = $entity->getId();
    $link->type = EntityLink::TYPE_RIDER;
    $link->toEntityUniqueId = $this->getId();
    $link->immediate = true;
    $link->causedByRider = true;

    if($entity instanceof Player) {
    $pk = new SetEntityLinkPacket();
    $pk->link = $link;
    $entity->dataPacket($pk);

    $link_2 = new EntityLink();
    $link_2->fromEntityUniqueId = $entity->getId();
    $link_2->type = EntityLink::TYPE_RIDER;
    $link_2->toEntityUniqueId = 0;
    $link_2->immediate = true;
    $link_2->causedByRider = true;

    $pk = new SetEntityLinkPacket();
    $pk->link = $link_2;
    $entity->dataPacket($pk);
    unset($viewers[$entity->getLoaderId()]);
    }
    or is there an error in the code, correct me
     
  2. alvin0319

    alvin0319 Creeper

    Messages:
    5
    GitHub:
    alvin0319
    EntityLinkPacket -> ActorLinkPacket
    SetEntityLinkPacket -> SetActorLinkPacket
     
    sdsd16 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.