[SOLVED] Catch a Skeleton Arrow event?

Discussion in 'Plugin Development' started by phondeux, May 29, 2012.

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

    phondeux

    Is it possible to catch when a skeleton fires an arrow? I want to override it for some skeletons and have them fire a flame arrow instead.

    Okay, looks like it's EntityShootBowEvent, but it looks for a livingentity ... is a skeleton a living entity? Maybe I'm thinking too literal and the API is differentiating between a dispenser and creature/player?

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

    CorrieKay

    uh... a flame arrow?

    thats not part of the standard bukkit api, afaik.
    My mistake, i forgot about enchantments :p

    To catch when an entity fires a projectile, you would listen for the ProjectileLaunchEvent

    To catch when the projectile hits something, you'd listen for the ProjectileHitEvent

    edit: ...or that :p
     
    phondeux likes this.
  3. Offline

    r0306

    phondeux
    Code:
    @EventHandler
    public void onShoot(EntityShootBowEvent event) {
    Entity e = (Entity) event.getEntity();
    if (e instanceof Skeleton) {
    if (event.getProjectile() instanceof Arrow) {
    Arrow a = (Arrow) event.getProjectile();
    a.setFireTicks(ticks);
    }
    }
    }
     
    phondeux likes this.
  4. Offline

    CorrieKay

    Yes, the skeleton is a living entity.

    do this

    if(event.getEntity() instanceof Skeleton(){
    Skeleton skeleton = (Skeleton)event.getEntity();
    //code here
    }
     
    phondeux likes this.
  5. Offline

    phondeux

    Thank you, you are beautiful people. :D
     
Thread Status:
Not open for further replies.

Share This Page