Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting projectile shooter

Comments in 'Plugin Development' started by Irish, Apr 30, 2016.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    It's always good practice to check even if you know it's not going to happen.
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    No, not really, you don't have to check if projectile is instanceof Player, it'll always return false as Player class can not be shot (Theoretically I'm wrong).
    PHP:
    /** @var \pocketmine\entity\Arrow $arrow */
    $arrow $event->getEntity(); # not ->getProjectile()
    /** @var \pocketmine\entity\Entity $shooter */
    $shooter $arrow->shootingEntity;

    if( ( 
    $shooter instanceof \pocketmine\Player ) === true ) { # Ik, don't say anything.
            #
    }
    Last edited: May 5, 2016
  3. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    If you didn't notice, I did correct myself by saying shooter..
    Primus likes this.
  4. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Is getProjectile even under that? Just a question.
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Mind yourself that this isn't chat room you can always edit your posts.
    As far as I remember it should be ProjectileLaunchEvent::getProjectile()

    Edit: I'm wrong, it as to be ProjectileLaunchEvent::getEntity(). My bad sorry.
  6. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Ok, thanks for all the help :D I'll remember to edit my post next time, thanks again :)

Share This Page

Advertisement