Custom Item Attributes (Modpack Utils Series)

Custom Item Attributes (Modpack Utils Series)

3M Downloads

Suggestion: Optimize Attribute loading speed

Pandaismyname1 opened this issue ยท 3 comments

commented

Context, we have a heavy amount of items in our modpack, and quite a lot of them are modified.
In our modpack we noticed a really long server join time and server reload time because of this, and it's caused by CIA. We created a mod to mixin and patch it, but we would like to see it implemented in the mod itself.

Here's a gist with our changes (in the form of a Mixin) that boosted performances by orders of magnitude: https://gist.github.com/Pandaismyname1/71b35c9eca1e1b23621833dbfe7dd0bf

A little explanation of what it does, it uses a cache for the Item IDs, and the search for the correct item is no longer O(n), but rather O(1).
This cache is reloaded at each server start & server reload, so it has parity with the intended use case.
Due to the fact that CIA hooks into the ModifyItemAttributeModifiersCallback.EVENT, which is called for every item in the game, the original CIA implementation had an algorithm complexity of O(n^2), while this patch changes the complexity to O(n).

We would like to have this in the CIA mod, as it improves the quality of the mod, and also means fewer mixins for us to maintain.

commented

@Pandaismyname1 Would you mind if I swiped your mixin and util class for my own publicly available mod (rpgattr)?

commented

@Pandaismyname1 Would you mind if I swiped your mixin and util class for my own publicly available mod (rpgattr)?

Sure, go ahead

commented

Thanks for the suggestion, could you please PR this? :) Due to both the license and so you can be tagged as contributor