EntityDamageByEntityEvent

Discussion in 'Plugin Development' started by MoeMix, Feb 3, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MoeMix

    So I am using the EntityDamageByEntityEvent. I simply want to get the player that was hit with a snowball. I know there is the e.getDamager() but that is the player that threw the snowball. How do I get the damagee?
     
  2. Offline

    caseif

    Code:java
    1. if (e.getDamager() instanceof Projectile)
    2. Entity damagee = ((Projectile)e.getDamager()).getShooter();

    This code will check if the damager (the snowball) is an instance of a Projectile, and if so, cast it to such and get its shooter (the person who threw it).
     
  3. Offline

    MoeMix

  4. Offline

    caseif

    Ah, sorry, I misread your post. I believe e.getEntity() will suit your needs.
     
  5. Offline

    MoeMix

    oh haha, that was simple :p Thanks for your help!
     
Thread Status:
Not open for further replies.

Share This Page