You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it seems like the only way of defining a custom result is either making one file for each option and putting excluding conditions in each, or creating your own recipe factory. Problem with the recipe factory is that the existing factories are defined either as lambdas or methods, and are therefore not extendable (meaning you would have to duplicate the entire code even if all you wanted to change is how the result is parsed).
An easy solution would be moving them into an extendable class with a protected parseResult(JsonObject json, JsonContext context) modders can override in a subclass. A possibly more clean solution would be to provide an IResultFactory that works similar to all the other factories.
As for my use case: my mod Ex Compressum supports multiple Ex Nihilo variants at the same time, which means some of the recipes have to automatically adjust based on what variant is being used. Multiple files with forge:mod_loaded each would work, but wouldn't be very elegant and would exclude the possibility of a mod adding support from their side. Another use case would be recipes that adjust based on configurations or other external factors.
Mockup recipe factory using Solution 1 (extendable default recipe factories):
public class NihiloRecipeFactory extends ShapelessOreRecipe {
@Override
public ItemStack parseResult(JsonObject json, JsonContext context) {
return ExNihiloProvider.getNihiloItem(json.get("value").getAsString());
}
}
This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!
stalebot
added
the
Stale
This request hasn't had an update from the author in a long time.
label
Feb 19, 2018
Currently it seems like the only way of defining a custom result is either making one file for each option and putting excluding conditions in each, or creating your own recipe factory. Problem with the recipe factory is that the existing factories are defined either as lambdas or methods, and are therefore not extendable (meaning you would have to duplicate the entire code even if all you wanted to change is how the result is parsed).
An easy solution would be moving them into an extendable class with a
protected parseResult(JsonObject json, JsonContext context)
modders can override in a subclass. A possibly more clean solution would be to provide anIResultFactory
that works similar to all the other factories.As for my use case: my mod Ex Compressum supports multiple Ex Nihilo variants at the same time, which means some of the recipes have to automatically adjust based on what variant is being used. Multiple files with
forge:mod_loaded
each would work, but wouldn't be very elegant and would exclude the possibility of a mod adding support from their side. Another use case would be recipes that adjust based on configurations or other external factors.Mockup recipe factory using Solution 1 (extendable default recipe factories):
Mockup recipe using Solution 2 (IResultFactory):
I can PR either solution once I know which would be preferred.
The text was updated successfully, but these errors were encountered: