Jump to content

[1.12.2] Regarding recipes factories and all that goodness...


Recommended Posts

Posted

I have a feature in my mod where the player can put a damaged item in a crafting grid, combine it with some other ingredients, and the output would be the same item except that the damage has been improved.  I have all this working using the traditional in-code way of generating shapeless recipes, but I am struggling with trying to map this to recipe jsons and the _factories feature that Forge has.

 

To briefly outline what the traditional in-code way does:  during post init the logic will scan the registered item list looking for items that are damageable and derived from some well known classes (like ItemTool).  If there is a match a modded shapeless recipe is created with an ItemStack representing the damaged tool with a wildcard specified, the fixed ingredients my mod supplies, with the output being listed as a fully repaired tool.  So if there were 50 items registered in the system 50 recipes would be created.  To clarify the point related to the modded shapeless recipe, I have a class that derives from ShapelessRecipes, overriding matches() and getCraftingResults() to ensure the right things happen during the craft operation.

 

I know enough about the JSON/factory system to be confused - more than likely me looking at this particular problem domain incorrectly.  So before I go light my hair on fire, run around in the backyard beating a drum and spouting Vogon poetry is what I am wanting to even possible using factories and recipe json?  If it is possible I would appreciate an outline of what I need to do to implement - I can go through and sort through the details myself. :)

Posted (edited)
25 minutes ago, OreCruncher said:

is what I am wanting to even possible using factories and recipe json?

Yes, absolutely. You would need to rethink your recipe logic though and instead of having n recipes where n is the amount of items matching the criteria you would have one recipe that matches all tools matching the criteria and determines the outcome based on the inputs dynamically. Then you can register that recipe with json and a custom factory just fine.

Edited by V0idWa1k3r
Posted (edited)

Ok.  So if I am understanding correctly I would have to implement an IRecipeFactory that creates a modded IRecipe handler that accepts the damaged tools on input and provides the repaired tool on output.  I would also create a recipe.JSON that specifies my recipe handler (input/output would be irrelevant in the JSON because of how my custom recipe would work).  And lastly I would update _factories.json with the specifications for the recipe handler.

 

EDIT:  If this is indeed the case what would my IRecipe::getRecipeOutput() return?  It wouldn't have any notion about the input stack.  Seems the system is built around the fact that getRecipeOutput() is deterministic.

 

EDIT2:  I had getRecipeOutput() return ItemStack.EMPTY and it runs and works.  Of course, it is a hidden recipe because of the finagling I had to do.  I guess my next stop is to look at JEI and fix things up there.

 

Thanks!

Edited by OreCruncher

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.