[Solved] Catch or Check for Despawning Mobs

Discussion in 'Spigot Plugin Development' started by rgaminecraft, Jun 8, 2015.

  1. I am currently developing a Spigot plugin using the latest spigot version and am having problems with named mobs despawning. I tried all sorts of tricks (giving armor, weapons, custom names, etc.) and they still seem to despawn in front of my eyes.

    My mod basically loads mobs dynamically from a file and places them in the world. I store the entity in an array for tracking purposes and notice that after they despawn their reference is still valid and not null. I was wondering if there is a way I can check the entity to see if it is still spawned within the world. Basically I just need a way to see if Entity.IsNotDespawned() and if it is then I can manually respawn it (unless there is a .Respawn() method or something).

    It's not a distance issue, as I've sat a few blocks away and watched them slowly disappear. It's possible that it may be a vanilla Minecraft issue, but I feel that there has to be something to tell if the mob is still in the game or not.
  2. I just found the isValid() function, so I'm hoping this will answer my questions about if it is still within the world. I will give it a shot and see if that works!
  3. Yes, in case anyone else is wondering the isValid() does show if the mob has been desapawned. I was able to use this to complete my task.