Jump to content

[1.16] what approach should I take to implement a custom crafting system?


Recommended Posts

In my mod, I'm going to have a custom crafting system. But I don't  know how I should go about implementing this.

for the vanilla recipes, I'm using the data generators, so I thought about making my crafting system be data oriented, and then I could look at the minecraft code to see how they do their systems. but I think it may be more hassle than it's worth. But if not data oriented, then how should I do it? (and if I want to have an api for my mod later on so other devs could make addons, would data oriented with the data generators be the best way to implement?)

I'd appreciate guidance on this, thank you

Link to comment
Share on other sites

26 minutes ago, Beethoven92 said:

I guess you would have to make your own custom recipe type for this..could you describe how your custom crafting system would work?

it would be much like the crafting recipes, with a 3x3 matrix. but with an additional ingredient that would be consumed, the recipe would have the crafting pattern, and an extra int. the extra item would be a mod specific item that would hold an int in a nbt, and the recipe would consume what it needed to from this item


the crafting would be done in an custom tile entity, I already have implemented the tile entity, and it is able to craft vanilla recipes at the moment.

so to get the vanilla recipes I use world.getRecipeManager.getRecipe(), so I suppose I would need my own instance of a custom recipe manager? maybe I can register my recipe type to the world recipe manager?

Link to comment
Share on other sites

You would need to implement your own IRecipe, its IRecipeSerializer to write/read your recipes and define a new IRecipeType. Notice that you you need to register your recipe serializer, this can be done through registry events or a DeferredRegister<IRecipeSerializer<?>>. You can see an example on how vanilla implements recipes and seralizers by looking at the AbtractCookingRecipe and its subclasses, and the CookingRecipeSerializer class. There should be almost everything you would need in order to implement your custom recipe. Other interesting classes to look at are the SpecialRecipe class and its subclasses

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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