Recipe Categories [1.13 and Up] - mezz/JustEnoughItems GitHub Wiki
Recipe Categories
A recipe category defines everything that's common across entire categories of recipes. These include, but are not limited to: "crafting", "cooking" (for all furnace types), and "brewing".
Creating a Category
Create a new class, which implements IRecipeCategory<YourRecipeClass>. The interface outlines functions that need and can be implemented, which are described below.
Functions to Implement
- (REQUIRED) getUid() - Returns a
ResourceLocationthat represents the category. Returning something along the lines ofnew ResourceLocations("yourmodid", "yourcraftingsystem")will generally do the trick here. - (REQUIRED) getRecipeClass() - Returns the class of the recipe that your category uses.
return YourRecipeClass.classis what you'll want to use here, assumingYourRecipeClassis indeed the name of your recipe class. - (REQUIRED) getTitle() - Returns the title used for your category. For example, all anvil recipes use the title "Anvil" here.
- (REQUIRED) getBackground() - Returns the background used for your category. The
IGuiHelperhas methods that can help manipulate the image used for this. - (REQUIRED) getIcon() - Returns the icon used for your category. For example, anvil recipes return the item representation of an anvil here. To do this easily, you can use
IGuiHelper.createDrawableIngredient(new ItemStack(YourItem)). - (REQUIRED) setIngredients() - A function called for all your recipes to set the inputs and outputs. The
IIngredientsparameter here is where you'll want to set your inputs and outputs. - (REQUIRED) setRecipe() - A function used to "put" the items of your recipe into place.
- (OPTIONAL) draw() - Used to draw any additional information when displaying a recipe. JEI uses this to draw the experience required text for anvil recipes.
- (OPTIONAL) getTooltipStrings() - Gets the tooltips to display based on the X and Y position of the mouse.
- (OPTIONAL) handleClick() - Allows for handling of a mouse click.
- (OPTIONAL) isHandled() - Whether or not the recipe has been handled.
It may be best to take a look at IRecipeCategory if any of this seems confusing. You can find that interface here
Registering Your Category
Once you have a finished recipe category, it's pretty simple to register! Make sure you've created a JEI plugin, then inside of registerCategories, call IRecipeCategoryRegistration.addRecipeCategory(new YourModCategory()).