Entity despawn or death not trigger DestructEntityEvent

I am design a mob tide minigame, When the player cleans up all zombies in a round, start next round, but sometimes when a creeper explosion, or skeletion despawn in my field of vision when i was dead,
It doesn’t go through the event.

when call spawnEntity, i save mob uuid to a list,

world.spawnEntity(en);
roundEntityIds.add(en.getUniqueId());
System.out.println("spawnEntity:" + en.getType().getName().toString() + " " + en.getUniqueId().toString());

and listen DestructEntityEvent remove the uuid to check if need start next round:

System.out.println("death:" + entity.getType().getName().toString() + " " + entity.getUniqueId().toString());
if(roundEntityIds.remove(uuid)){
    if(roundEntityIds.isEmpty){
           nextRound();
     }
}

log show the spawn size is not match death size:

[20:42:21] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.dim.DimInfoZombies$Round:spawnEntity:748]: spawnEntity:spider c39f0bc5-6e0b-4dba-80a5-87503aeeed65
[20:42:23] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.dim.DimInfoZombies$Round:spawnEntity:748]: spawnEntity:zombie 5fe03c81-6ddb-4a4c-b4af-9e9f6998190b
[20:42:25] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.dim.DimInfoZombies$Round:spawnEntity:748]: spawnEntity:wolf d772e064-fcce-4de6-b8c6-39278ee4a2da
[20:42:27] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.dim.DimInfoZombies$Round:spawnEntity:748]: spawnEntity:spider 81dd1aec-9dfa-4983-ac03-c1e91133b7ed
[20:42:29] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.dim.DimInfoZombies$Round:spawnEntity:748]: spawnEntity:skeleton 12a12fe3-18a1-420f-a353-21b293a6517a
[20:42:31] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.dim.DimInfoZombies$Round:spawnEntity:748]: spawnEntity:skeleton 270a4249-691a-47c1-a1b3-9e84907812b8
[20:42:32] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.listener.MiniEventListener:damageEntityEvent:96]: death:spider c39f0bc5-6e0b-4dba-80a5-87503aeeed65
[20:42:37] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.listener.MiniEventListener:damageEntityEvent:96]: death:spider 81dd1aec-9dfa-4983-ac03-c1e91133b7ed
[20:42:47] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.listener.MiniEventListener:damageEntityEvent:96]: death:zombie 5fe03c81-6ddb-4a4c-b4af-9e9f6998190b
[20:43:00] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.listener.MiniEventListener:damageEntityEvent:96]: death:skeleton 270a4249-691a-47c1-a1b3-9e84907812b8
[20:43:11] [Server thread/INFO] [STDOUT]: [halo.mfbl.minigame.listener.MiniEventListener:damageEntityEvent:96]: death:wolf d772e064-fcce-4de6-b8c6-39278ee4a2da

Some users seem to have had the same problem.

You could schedule a task that, every x seconds, goes through all or some entities still in that list and checks if they are still alive… :slight_smile:

1 Like

That’s exactly what I’m doing right now…