TorchMaster icon indicating copy to clipboard operation
TorchMaster copied to clipboard

Rework event handling logic

Open Xalcon opened this issue 2 years ago • 0 comments

This issue is a continuation of #161

Other mods still cause issues with the way the event handling is implemented. Generally, Torchmaster would like to be the first mod to handle any events for spawning, so it can tell the other mods in the chain if spawn handling was already done and if it was blocked. Forge provides 3 event results: Block, Default, Allow.

The default handling of torchmaster is to check if any other mod in the chain already set the result to anything but default. If it is not default, it simply skips its spawn checks. An additional configuration option (aggressiveSpawnChecks) was added which keeps processing the event even if another mod set the result to allow.

Now there are mods, that simply ignore the settings from other mods (like torchmaster), effectively overriding my block result.

One potential solution is to move torchmaster as low as possible into the priority chain - but even that does not guarantee that there is no other mod that still tries to override the value afterwards.

Another solution is to add additional information to the entity itself and check this during the generic EntityJoinWorld Event. This would allow us to block the entity, but it can also have a bigger performance impact since the EntityJoinWorld event is fired much more frequently than the CheckSpawn events.

Since there is no perfect solution, we may go with a middle ground solution:

  • Make the event handler priority configurable via the mod configuration. This will have the least impact on performance. (Also document why its not Lowest by default)
  • Add an additional configuration option that handles entities in a much more aggressive way via the EntityJoinWorld event

Xalcon avatar Jun 01 '22 11:06 Xalcon