How can I get the cause of why an entity was removed? I'm use Paper and their API marks EntityRemoveEvent and EntityRemoveEvent.Cause deprecated. The only thing left is EntityRemoveFromWorldEvent that doesn't give anything about the cause. Here's why I'm asking. I have a plugin that spawns mobs to kill a player. When a mob gets too far away, I manually remove it then increase the number of mobs to be spawned because it was never killed and needs to be spawned again. However, EntityRemoveFromWorldEvent is also called when an entity is removed from being killed, not just with entity#remove(). Conclusively, I need to determine when I should increment the numMobsToSpawn based on the reason for removal.
Between my automatic tests and the program itself, the mobs are being removed in a couple different spots and I would rather not duplicate code if I have to. Worst case, I should be able to handle the logic there.
@Smeary_Subset In that case, you could make a function and call that for each of the different spots.
I ended up just compromising and making it so an enemy being removed from far away counted as a death.