
Knowledge tick is expensive/laggy
someaddons opened this issue ยท 3 comments
The way the player tick is structure for adding knowledge is a bit laggy, esp with multiple players.
From looking at the code it looks like its searching the whole inventory for each knowledge by itself which is probably why it is laggy as with multiple ItemKnowledges its searching the same inventory a lot of times.
I think you could restructure it a bit to loop the inventory once, and lookup the relevant Knowledge via HashSet<Item> or similar for fast O(1) access. And maybe even do this only every 10 ticks and add 10 times the knowledge then.
Great mod otherwise :)