Removing Arrows From Entity

Discussion in 'Plugin Development' started by ShadowLAX, Dec 22, 2013.

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

    ShadowLAX

    Hello bukkit. Is it possible to remove the arrow entity once it has hit another entity? For example, I shoot a bow with an arrow and it hits another player, then removes the arrow. My goal is to try and remove the after effect of the arrow sticking out of the player/mob. If there is another way to do that then what I am suggesting is possible, please let me know.

    Thanks!
     
  2. Offline

    user_90854156

    Code:java
    1. @EventHandler
    2. public void onHit(ProjectileHitEvent e) {
    3. Projectile p = e.getEntity();
    4. if (p instanceof Arrow) {
    5. p.remove();
    6. }
    7. }

    .remove() to remove it \o/
    You'd need to add some check probably
     
  3. Offline

    ShadowLAX

    MrTang That's what I am currently using, but when it hits a player/mob it remains in the player/mob, and that is what I am trying to get rid of is that after-effect. Thanks though!
     
  4. Offline

    reider45

    ShadowLAX I believe there were other threads on this, I'm not sure if any were solved though
     
  5. Offline

    ShadowLAX

    reider45 That's cool, but if none of them were solved that doesn't exactly help xD
     
  6. Offline

    Developing

    ShadowLAX Maybe you should try the EntityInteractEvent and check if the entity is an arrow. If so , remove the arrow like how you did above but using a different event other than ProjectileHitEvent.
     
  7. Offline

    NathanWolf

    You could try doing the remove in a scheduled task for one tick later, maybe that would help?
     
  8. Offline

    ThunderWaffeMC

    My plugin (swordbow) uses:

    Code:java
    1.  
    2. @EventHandler
    3. public void onArrowHit(ProjectileHitEvent event) {
    4. Projectile entity = event.getEntity();
    5. if(entity instanceof Arrow) {
    6. Arrow arrow = (Arrow)event.getEntity();
    7. arrow.remove();
    8. }
    9. }
    10. }
    11.  
     
    zzienzz likes this.
  9. Offline

    reider45

    ShadowLAX I said I wasnt sure, its worth looking around for
     
  10. Offline

    ShadowLAX

    So I looked around, and I saw some suggested using this:

    Code:java
    1. for (Entity entity : player.getNearbyEntities(2.0,2.0,2.0)) {
    2. if (entity.getType() == EntityType.ARROW) {
    3. entity.remove()
    4. }
    5. }


    That doesn't work. So I was thinking maybe its client side because that would clear any entities around the player that were arrows, and if they were in the player as well.
     
Thread Status:
Not open for further replies.

Share This Page