Recipe Categories [Minecraft 1.16.5 to 1.18.2] - mezz/JustEnoughItems GitHub Wiki

[!NOTE] Version note: This page covers recipe categories for Minecraft 1.16.5, 1.18.2, 1.19.2, and 1.20.1. Use the API Javadocs for exact class and method names on the version you target.

Other recipe category pages:

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 ResourceLocation that represents the category. Returning something along the lines of new ResourceLocations("yourmodid", "yourcraftingsystem") will generally do the trick here.
  • (REQUIRED) getRecipeClass() - Returns the class of the recipe that your category uses. return YourRecipeClass.class is what you'll want to use here, assuming YourRecipeClass is 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 IGuiHelper has 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 IIngredients parameter 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 in the API Javadocs for your target Minecraft version if any of this seems confusing.

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()).