Snowball throw event

Discussion in 'Plugin Development' started by Zix, Apr 10, 2014.

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

    Zix

    I know there is an event for when an egg is thrown, is there one for a Snowball? Because I cannot seem to find one and I would rather not use eggs because I really dont want chickens running around all over the place.

    If there is a way to make the eggs not spawn chickens, that would work aswell

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    Shadowwolf97

    You have to use the ProjectileLaunchEvent. From that event, do
    Code:java
    1. if(event.getEntity() instanceof Snowball) {
    2. //Execute code here for snowball launch
    3. }


    Hope this helped! Let me know if you need more assistance :)
     
  3. Offline

    Zix

    Shadowwolf97 Is there a way to get the player that threw it?
     
    Shadowwolf97 likes this.
  4. Zix Projectiles have a method to see who shot them (see javadocs if you need to know which)
     
  5. Offline

    Shadowwolf97


    Code:java
    1. if(event.getEntity() instanceof Snowball) {
    2. Snowball snow = (Snowball) event.getEntity();
    3. if(snow.getShooter() instanceof Player) {
    4. Player p = (Player) snow.getShooter();
    5. }
    6. }


    Code isnt tested but it should work.
     
    Zix likes this.
  6. Offline

    Zix

  7. Offline

    Shadowwolf97

    Glad I could help :3
     
Thread Status:
Not open for further replies.

Share This Page