You should check for valid when you would naturally be doing something to your entity anyway,
Except when the mod doesn't do anything like that... Here's how this issue affects my bridge:
The ends of the bridge are `pipe-to-ground` entities. The ramps are the pipe covers
Once a bridge is constructed, my mod sits idle, there's no `on_tick`.
To allow the player to walk over the bridge, during construction I replace any water tiles between the two ends with fake water tiles that have the player collision mask removed.
If the end of the bridge, or any segment between the ends is destroyed, I get an event: If it's mined, if it dies (eg. due to fire), I get told about it. When this happens, I do one of two things:
* If it's bridge end, I find other end via `.neighbours`
* If it's a segment in the bridge, I know the`max_underground_distance` (well,
I would) so I center that on the destroyed segment, then search that area for applicalbe end entity (`pipe-to-ground` of specific name), then find other end via `.neighbours`
Once I have both ends, I can safely destroy the bridge - both ends, the segments between them, and replacing fake water with real water again.
Now, along comes a mod that destroys one end of my bridge, or a segment... I know nothing about this. Even if that mod destroyed all entities in the bridge, the fake water would still be there and player would be able to walk on it.
This is why I need to know when something gets destroyed by a mod. It's why all this talk of "just check .valid" is of no use to me whatsoever, because my mod is not using `on_tick`. I've spent ages making sure the mod sits idle until triggered to do something (build bridge, destroy bridge) by an event. I've even set `.active = false` on the `pipe-to-ground` so that a built bridge has almost zero impact on UPS/FPS.
And then along comes this nightmare that `.destroy()` doesn't fire an event, with people telling me "just check .valid", which is equivalent to "just add on_tick handler and check .valid for every piece of every bridge on every surface" which in turn means "maintain a table of all your bridge entities, just so you can work out when one of them is destroyed by another mod".
A param on the destroy event to tell it to trigger an event would solve this problem, it would default to `false`. Mods such as Creative Mode, or anything else that can `.destroy` entities from other mods, would set the param to `true` to alert the other mod to their entity being destroyed.
As for the `create_entity()`, that also poses a problem. One of the things I wanted to do was write a separate mod that would automatically build a bridge at start of game if player is trapped on a small island. That should be simple case of placing two ends of bridge at which point my mod would do the rest (build the inner segments, swap water for fake water, etc). But, because `create_entity()` doesn't fire an event, my mod literally has no clue that another mod is trying to build a bridge. If `create_entity()` had an additional param, `false` by default, that told it to trigger an event, this problem would be easily solved.
The events would benefit any mod that uses compound entities (concrete lamppost, torches, ks_power, electric vehicles, etc) or wish to create/destroy entities from external mods (creative mode, vehicle wagon, etc).