Check when a snowball hits something

Discussion in 'Plugin Development' started by boardinggamer, Dec 5, 2012.

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

    boardinggamer

    What listener would I use for when a snowball hits something? I need to check if it hits a block or an entity.

    Would it work with EntityInteractEvent?
     
  2. Offline

    tommycake50

    idk try it?
    if it doesnt work then come back to this thread.
     
  3. Offline

    Chuckleluck

    ProjectileHitEvent is what you're looking for, if you're talking about hitting blocks. If you want to detect if it hits an entity, do EntityDamageByEntityEvent.
     
  4. Offline

    Latzafs

    Sorry, also need a bit of help with this, know of a way to get the defender entity? I need to make a plugin that checks both if it hits players and what player it hits.
     
  5. Offline

    Muxon

    EntityDamageByEntityEvent.Check with event.
    getDamager() if thev damager is instanceof Snowball. If true cast the event.getDamger to a Snowball and get the Shooter of it with snowball.grtShooter. This is the attacker. Also on the first check check if event.getEnty is instanceof a Player. when both is true (snoeball is snowball and player is player)cast the event.getEntity to a Player and then you can do
    whatever you want to do with them:)
     
Thread Status:
Not open for further replies.

Share This Page