Minecraftforge: IResultFactory or extendable recipe factories

Created on 20 Aug 2017  路  3Comments  路  Source: MinecraftForge/MinecraftForge

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());
    }
}

Mockup recipe using Solution 2 (IResultFactory):

{
  "type": "forge:ore_shapeless",
  "result": {
    "type": "excompressum:nihilo_result_item",
    "value": "DUST",
    "count": 9
  },
  "ingredients": [
    {
      "item": "excompressum:compressed_block",
      "data": 0
    }
  ],
  "conditions": [
    {
      "type": "excompressum:has_nihilo_item",
      "value": "DUST"
    }
  ]
}

I can PR either solution once I know which would be preferred.

Stale

Most helpful comment

i vote for the IResultFactory

All 3 comments

i vote for the IResultFactory

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!

This issue has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tterrag1098 picture tterrag1098  路  3Comments

williewillus picture williewillus  路  3Comments

bs2609 picture bs2609  路  3Comments

ErikBigDev picture ErikBigDev  路  3Comments

MJRLegends picture MJRLegends  路  3Comments