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

Projectile Hit... assistance..

Discussion in 'Development' started by LinuxLogo, Dec 14, 2017.

  1. LinuxLogo

    LinuxLogo Spider

    Messages:
    8
    GitHub:
    jrodr10
    Question:
    How can i change this without changing the entire thing

    Code:

    public function onArrowHit(ProjectileHitEvent $ev){
    $e = $ev->getEntity();
    if ($e instanceof Snowball){
    $x = $e->getX();
    $z = $e->getZ();
    $y = $e->getY();
    $explosion = new Explosion(new Position($x,$y,$z,$e->getLevel()), 3);
    $explosion->explodeB();
    }
    if (!$e instanceof Arrow){
    return ;
    }
    $p = $ev->getEntity()->shootingEntity;
    if ($p instanceof Player){
    switch ($this->main->bowtype[$p->getName()]){
    case 0:return ;
    case 1:


    LINE GIVING THE ERROR:
    $p = $ev->getEntity()->shootingEntity;

    THE ERROR:
    1:29:51] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\entity\ProjectileHitEvent' to 'Core': Call to undefined method pocketmine\entity\projectile\Arrow::shootingEntity() on dc\Events\EventsListener

    [01:29:51] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\entity\projectile\Arrow::shootingEntity()" (EXCEPTION) in "DRC-DRN/src/dc/Events/EventsListener" at line 64
     
    Last edited: Dec 14, 2017
  2. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Could it be that you're looking for a method like this?
     
  3. LinuxLogo

    LinuxLogo Spider

    Messages:
    8
    GitHub:
    jrodr10
  4. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    You're trying to get the owner of the projectile entity, so you should use $projectileEntity->getOwningEntity(). Is that your issue?
     
    LinuxLogo likes this.
  5. LinuxLogo

    LinuxLogo Spider

    Messages:
    8
    GitHub:
    jrodr10
    @SalmonDE no im trying to get the location of the arrow. Like were is lands. Its a plugin that makes the bow react to a token system. For example tap bow on ground changes to explosive bow. When arrow hits the floor explosion happens were arrow landed, another would be Teleport bow. Where arrow lands is were player teleport s to, jsut a feature in my core that needs to be updated to compatibiity with PMMP as i haven't been around for almost a year when pocketmine was dead
     
  6. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    Couldn't you simply use $projectileEntity->asPosition() ?
     
    SalmonDE likes this.
  7. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    I see, but according to the error you've provided, you also have to replace $ev->getEntity()->shootingEntity because it doesn't exist anymore. (API change)
     
    Last edited: Dec 15, 2017
  8. LinuxLogo

    LinuxLogo Spider

    Messages:
    8
    GitHub:
    jrodr10
    @SalmonDE Yes that would be the problem as described ill try the alternative method
     
  9. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    You can get location of thrown arrow in EntityMotionEvent
     
  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.