Solved Entity Despawn Event!

Discussion in 'Plugin Development' started by ThaH3lper, Oct 9, 2012.

?

Do you want EntityDespawnEvent

  1. Yes!

    100.0%
  2. Nope

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    ThaH3lper

    Hello!
    I work with a plugin that handels alot of entitys etc... However I need to know when they despawn so I can save them, But there is no way to do this :( Is it hard for bukkit to add a EntityDespawnEvent?
     
  2. Offline

    Woobie

  3. Offline

    Comphenix

    Do you mean when they die of old age? You can probably use EntityDeathEvent for that.

    Or do you mean when they're unloaded from memory and saved to the map? If so, use ChunkUnloadEvent and enumerate every entity in that chunk. That should give you every "despawned" entity.
     
  4. Offline

    ThaH3lper

    But doesn't the mobs despawn when player gets too far away... Or is it only the chunk that is calculated? Are you suere it works to 100%?
     
  5. ThaH3lper AFAIK Entities are saved with the chunk. So if a player moves to far away the chunk unloads with all entities in it, but if a player comes back nearby the chunk loads again with all saved entities.
     
  6. Offline

    ThaH3lper

    AFAIK Entities? Will it have same ID? and monsters despawns when chunk unloads and loads...
     
  7. Offline

    TwistedMexi

    "As far as I know"

    and you need to specify what you want here. Are you talking about passive/tameable mobs, or are you talking about monster mobs? What is your goal here, so we can respond with useful information?
     
  8. Look for yourself what is saved and whatnot: https://github.com/Bukkit/CraftBukk...in/java/net/minecraft/server/Entity.java#L991 (keep in mind that some entities may overwrite this function...)
    monsters are entities, aren't they? Did you never get to some place in the world and wondered why there are monsters burning at the afternoon? It's because the chunk unloaded at night but reloaded at day...
     
  9. Offline

    ThaH3lper

    Hmm.. it looks like it saves but they don't have sme ID :/ However, I made my own "despawn" so I know exactly when a mob despawns etc...
     
  10. ThaH3lper Did you try to use the UUID instead of the ID? Keeping every chunk a mob is in loaded may be a bad idea... ^^
     
  11. Offline

    ThaH3lper

    No, When there is no player within 40blocks then force despawn mob and save it, then if player comes 30blocks close to it spawn mob again :)
     
Thread Status:
Not open for further replies.

Share This Page