Cancel Arrow Despawning?

Discussion in 'Plugin Development' started by scarabcoder, Jun 16, 2014.

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

    scarabcoder

    I am making a plugin where a zombie can sit down, and I can only accomplish that by having him sit on arrows. However, the arrows despawn after a few minutes. Is there any event that's called? I've already tried setting the ticks lived to -12500, and using this event:
    Code:java
    1.  
    2. @EventHandler
    3. public void entityDespawnEvent(ItemDespawnEvent e){
    4. if (e.getEntityType() == EntityType.ARROW) {
    5. e.getEntity().setTicksLived(1);
    6. e.setCancelled(true);
    7. }
    8. }
     
  2. Offline

    Ice3ider4

  3. Offline

    scarabcoder

  4. Offline

    cs475x

    The only things I see that could be wrong with that solution is the event is not being registered, or another plugin is stopping it from being cancelled.
     
  5. Offline

    xTigerRebornx

  6. Offline

    cs475x

    xTigerRebornx After looking through that section, I don't see a mention of any event being fired.
     
  7. Offline

    xTigerRebornx

    cs475x Yeah, doing some research, EntityDeathEvent is only fired for LivingEntities (which an Arrow isn't)
    ItemDespawnEvent won't be fired either, since its not an Item.
     
  8. Offline

    scarabcoder

  9. scarabcoder Does the event fire for arrows? If it does, you could spawn another arrow in the same place. If it doesn't... I guess you could try and edit the counter using nms & reflection, but chances are that's probably too advanced.
     
  10. Offline

    scarabcoder

    AdamQpzm Even if it did, spawning an arrow in the same place wouldn't work. A zombie is actually riding it.
     
  11. scarabcoder Spawn new arrow and then make the zombie ride the new arrow instead.
     
  12. Offline

    scarabcoder

    AdamQpzm Yes, but as said before, there isn't any event fired for when it despawns.
     
  13. scarabcoder
     
  14. Offline

    Garris0n

    @OP are you trying to despawn an actual arrow or an arrow Item? Because there's a significant difference.

    Ice3ider4 Regardless of what he was trying to do, please don't spoonfeed undocumented and blatantly incorrect (wouldn't even compile) code...
     
    xTigerRebornx and Konkz like this.
  15. Offline

    scarabcoder

    I'm trying to KEEp from despawning an arrow entity. Sorry if that wasn't clear.
     
  16. Offline

    Ice3ider4

    Garris0n Hm... I don't think there's anything wrong with my code and I just wanted to give him an idea on how to solve the problem.

    Edit: I'm sorry I fixxed them now :s
     
  17. Ice3ider4 Your code has a strange aversion to the use of parenthesis. This will hold it back in the Java world.
     
    Garris0n likes this.
  18. Offline

    Ice3ider4

    AdamQpzm Yep I did some mistakes because I wrote it without my development environment ._.
     
  19. Ice3ider4 I don't spoonfeed code, but if I was to I wouldn't miss out almost half the parenthesis or say "use this" and "don't think there's anything wrong with my code", with or without an IDE ;)
     
    Garris0n likes this.
Thread Status:
Not open for further replies.

Share This Page