Modern-Industrialization icon indicating copy to clipboard operation
Modern-Industrialization copied to clipboard

Fix #817: Simplify internal recipe building

Open Swedz opened this issue 1 year ago • 7 comments

Closes #817

This is the code I've been using in a mixin in Tesseract for a while now, and it seems to work properly. It doesn't feel quite optimized to me though.

Swedz avatar Sep 17 '24 20:09 Swedz

It might be worth considering changing ProxyableMachineRecipeType#fillRecipeList to have the RecipeManager and RegistryAccess as parameters instead of the Level. I can make this change too if that would be desirable

Swedz avatar Sep 18 '24 00:09 Swedz

All the weird cache invalidation should not be called on the client; it might lead to outdated recipes in JEI forever. Passing the recipe manager and registry access is fine. Speaking of the invalidation, I think it's also time to remove it, and instead invalidate after a data pack (re)load using an event. This should remain server-exclusive behavior.

Technici4n avatar Sep 19 '24 09:09 Technici4n

~~Is the cache invalidation something I did in this change? I don't see what would cause it to be invalidating. If there's something somewhere where this is happening I can change it to use a datapack event listener.~~ I found it, the stuff with UPDATE_INTERVAL in ProxyableMachineRecipeType, right?

Swedz avatar Sep 19 '24 18:09 Swedz

As for passing the recipe manager and registry access, I'm a little conflicted on it. Passing the level is very useful for me in Extended Industrialization, since it lets me access the PotionBrewing instance for the level and generate recipes using it.

Swedz avatar Sep 19 '24 18:09 Swedz

I found it, the stuff with UPDATE_INTERVAL in ProxyableMachineRecipeType, right?

Yes. Maybe just making a method without caching works.

Passing the level is very useful for me in Extended Industrialization, since it lets me access the PotionBrewing instance for the level and generate recipes using it.

True.

Technici4n avatar Sep 19 '24 20:09 Technici4n

Looking for what event(s) to use for invalidating the cache here. I see OnDatapackSyncEvent and AddReloadListenerEvent which seems to be server side only, and RecipesUpdatedEvent which seems to be client side only. Why do you say that this invalidation should only be done server side? Do the recipes generated by fillRecipeList get sent to the client? Or does the client also need to build these themselves?

Swedz avatar Sep 20 '24 00:09 Swedz

Could be moved to #900

Swedz avatar Oct 02 '24 17:10 Swedz