Improved Fire Overlay

Improved Fire Overlay

22k Downloads

Performance improvement idea

altrisi opened this issue ยท 5 comments

commented

Since you are looping through a list every frame/whatever, for every entity, the performance drops considerably when there are many mobs on soul fire and even worse when there are also many mobs on fire.

Idea:
Make a boolean field in the entity to set whether it is on soul fire (fields in mixin get copied to the actual class, you just need setters/getters implementing an interface).

This also allows you to remove the checks as to whether an entity is removed every tick, and you could maybe also mix into where the onFire field is set to false and set the on soul fire to false too to remove the not on fire check every tick.

commented

Actually, I just crashed with a CME due to that list!

Maybe it was being modified from both the mixin and the onClientTick, so that's why? I assume it's rare, I changed the fire type to maybe around 300 creepers at the same time.

Relevant stack:

java.util.ConcurrentModificationException
    at Not Enough Crashes deobfuscated stack trace.(1.16.5+build.4)
    at java.util.ArrayList.removeIf(ArrayList.java:1411)
    at com.santapexie.santapexie_soulflame.Main.lambda$onInitializeClient$3(Main.java:31)

Full crash:
crash-2021-08-06_13.00.26-client.txt

commented

Actually, let me make a PR, why not, you can close it if you don't like it. Will also try to fix the other things I found.

commented

Thank you for thinking of this, I will keep this in mind and see what I can do to improve performance.

commented

Making the PR right now

commented

I think I made a thing that works according

Since you are looping through a list every frame/whatever, for every entity, the performance drops considerably when there are many mobs on soul fire and even worse when there are also many mobs on fire.

Idea:
Make a boolean field in the entity to set whether it is on soul fire (fields in mixin get copied to the actual class, you just need setters/getters implementing an interface).

This also allows you to remove the checks as to whether an entity is removed every tick, and you could maybe also mix into where the onFire field is set to false and set the on soul fire to false too to remove the not on fire check every tick.

I have made a commit, according to ur reply and i'm pretty sure it works, ill credit u in my readme! Thanks so much