IC2 Classic

IC2 Classic

2M Downloads

Caching items too early in 1.19.2

pupnewfster opened this issue ยท 4 comments

commented

I started looking a bit more into this issue that was reported to me and I feel like this is likely an issue with how IC2C is doing things. It seems that IC2 is caching things (for use with recipes?) in FMLLoadCompleteEvent which fires before there is a world/"server". This errors because we are querying configs in Mekanism for whether certain items should be added to the creative tab (filled tanks) and also to know the configured capacity of various items.

I started changing some of our checks to have some defaulting logic for if the configs aren't loaded, but ran into a couple places where it would be a bit annoying to change/add unnecessary overhead in other code paths and before I went ahead and did so wanted to verify if this is an issue on your end. Is there a reason IC2C is caching things related to recipes so early (given the fact recipes don't load until the world is loaded and can also be reloaded using /reload)? Or is this just a legacy bug related to porting and that being a decent place to do it back in 1.12?

My best guess is that Mekanism isn't the only mod querying configs for purposes of filling the creative tab, but as it only is an exception at dev time currently there is a good chance other people have not ran into it yet.

commented

Small addition:
On the client this "StackCache" is used for the "What item goes into this specific slot, or the item selector".
Or anything that isn't easily accessible itemlists.
Like fluid containers, Specific predicates and a few other things.
Basically static data that never changes. This has nothing to do with tags or datapacks.

commented

Will change it on our end to just default, though the part that was server config based and doesn't make sense as a client or common config is what the max capacity of certain things (so we can set the proper energy values etc for adding a filled version to the creative tab).

Granted in regards to things like fluid containers I will warn you I know some mods definitely have items that depending on their state are either a fluid container or aren't, so you definitely need to make sure to have some sort of fallback for those kind of things.

commented

@pupnewfster creative tabs are "client sided" so using "server configs" for them are pointless.
And the server side cache actually loads in the "ServerAboutToStartEvent", meaning mekanism is at fault.
If they apply "Server Configs" on "Clients" then that is not my fault.

if(FMLEnviorment.isClient() ? ClientConfig.shouldBeVisible() : ServerConfig.shouldBeVisible())
Otherwise i would suggest to use the common configs.

The ItemStack cache is just a "Global List" cache that is there if i want to find any item that i wish really quickly.
If i have to recalculate every single stack possible whenever i just try to find matching ones, that would cause a huge performance problem. This system basically makes it a array search which is the fastest possible.
Also Common Caches get pre-calculated. This only has to be done once on game start.
For servers later, but clients are fine to start earlier.

My best guess is that Mekanism isn't the only mod querying configs for purposes of filling the creative tab, but as it only is an exception at dev time currently there is a good chance other people have not ran into it yet.

Yes botania was the other one but that was solved by moving the "server" specific one to the about to start event.
Since they used common configs and forge adjust based on what you need.

The client can not be expected to have not everything loaded after you reached the main menu.
If server configs are required to do anything that is just a bad idea to begin with.

Or is this just a legacy bug related to porting and that being a decent place to do it back in 1.12?

Nah this mod was rewritten from scratch. Started in 1.14.4 but i did major rewrites with every version bump so this "Dirty Port" Scenario you asked about "Only fix least amount required", would never happen.

I hope that answers your questions.
@pupnewfster

(Done typing)

commented

@pupnewfster thank you!

The idea is that you get as accurate as possible. It doesn't have to be 100% accurate.
Since its "Filter Helpers" or "Indicators what could match" it doesn't have to be perfect to begin with.

By the way if you have any other issue don't hesitate to ask.
Even if i sound rough.
I am sorry if i made you feel attacked.