[Bug]: EntitySummonTrigger being quite performance heavy
Flemmli97 opened this issue ยท 0 comments
Describe the bug
the EntitySummonTrigger
for rituals is taking quite a bit a toll on performance.
I added the spark report for it and while it is using only 5% this is still a decent number considering its only from one source.
the actual version is 1.18.2-1.2.2 but its not selectable. also the code is the same on 1.19
proposed fixes:
-
since you just use
LivingSpawnEvent
but not a sub event all sub events get passed to the event handler as well. it might be better to useLivingSpawnEvent.CheckSpawn
and do the logic if that event is not cancelled which would then cover natural spawning etc. -
check the predicate already in the event handler before
https://github.com/MinecraftschurliMods/Ars-Magica-Legacy/blob/version/1.19.x/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/ritual/trigger/EntitySummonTrigger.java#L39 since getting entities in area around is performance heavy specially if performed for every spawned mob and since the ritual can only run anyway if the predicate matches it makes sense to check that first
Steps to Reproduce
- Just load up a world with the mod
- Use spark to profile
Expected behavior
No response
Screenshots
No response
Version
1.18.2-1.2.0
Forge Version
40.1.92
Other Mods
No response
Log
https://spark.lucko.me/T3wO0RwHzn