Fix #817: Simplify internal recipe building
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.
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
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.
~~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?
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.
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.
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?
Could be moved to #900