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. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    I looked through the forums and couldn't find anything recent, but how would I get the projectile shooter? I know that ProjectileHitEvent might contain something, but couldn't find anything.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    $protjectile->shootingEntity
    ImagicalGamer and Irish like this.
  3. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    hm, I tried that with no success.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Code?
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Code from my minigame:

    PHP:
    public function onDamage(EntityDamageEvent $event){



    if(
    $event instanceof EntityDamageByEntityEvent){


    if(
    $event->getCause() == EntityDamageByEntityEvent::CAUSE_PROJECTILE){

    $killer $event->getDamager();
    $victim $event->getEntity();



    if(!
    $killer instanceof Arrow){



    $killer->sendMessage($this->PREFIX."You killed ┬ža".$victim->getName());


    }}}}
  6. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    hmm interesting code, but I finally found shootingEntity after a while. It just wouldn't popup in my ide.
  7. _Neisufek_
    Offline

    _Neisufek_ New Member

    Joined:
    Apr 17, 2016
    Posts:
    16
    Minecraft User:
    xNaisu
    Sending a message to a projectile? [FACEPALM x 2]
    ImagicalGamer likes this.
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Not "popping up" in your IDE does not mean it doesn't exist.. Please check the PM source next time
    Legoboy0215 likes this.
  9. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Who do you mean?
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    In other words, how can arrow receive a message? @_Neisufek_ if you look careful then you can see an 'if' statement wrapping that block of code.
  11. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Yep and a ! for if not
  12. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    I was probably using the wrong event when doing it which therefore it wouldn't show up. I understand that it was in there, and I checked the PM source on the event.
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Note, not only Player can be shooting entity. It's good to check if you're calling sendMessage() on Player class instead, for instance, a Skeleton class.
    Last edited: May 4, 2016
  14. _Neisufek_
    Offline

    _Neisufek_ New Member

    Joined:
    Apr 17, 2016
    Posts:
    16
    Minecraft User:
    xNaisu
    If($cause == CAUSE_PROJECTILE){
    don't you see?
    }
  15. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Don't you know what he is talking about? He tells you to check if the shootingEntity is a player, otherwise sendMessage() will give you an error, if it's not a player.
    Primus likes this.
  16. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Well when my code is so wrong, why does it work then?
  17. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Make Skeleton to shoot an arrow. It's not, as you say 'so wrong' it just contains one bug.
  18. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I know, but I use it for my ninigame and there skelettons are not needed, anyways the mob API isnt included?
  19. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    I am aware of this. I could define it as $shooter = $projectile->shootingEntity; and then do if($projectile instanceof Player){ /*code here*/
  20. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    *shooter

Share This Page

Advertisement