[Tutorial] Adding JEI descriptions to items from your mod

Started by cubicgraphics on

Topic category: User side tutorials

Joined May 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] Adding JEI descriptions to items from your mod
Sun, 04/11/2021 - 20:52 (edited)

First you need to have the jei api,
To add this to mcreator open your build.gradle file

After Opening it you need to add

repositories {
  maven {
    // location of the maven that hosts JEI files
    name = "Progwml6 maven"
    url = "https://dvs1.progwml6.com/files/maven/"
  }
  maven {
    // location of a maven mirror for JEI files, as a fallback
    name = "ModMaven"
    url = "https://modmaven.k-4u.nl"
  }
}

into the file

And 

 compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.4:api")
  // at runtime, use the full JEI jar
  runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.4")

inside the bit at the bottom that says dependencies

So it looks like that.

Now to add descriptions to items
Create a new custom element and name it JeiPlugin or something along those lines.
Open it and delete everything except for the package line so it looks like this:
 

My mod is called dronecraft, your mods name should be where that word is.
 

Next add this code to your file:

import mezz.jei.api.*;
import mezz.jei.api.ingredients.IIngredientType;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.api.registration.IRecipeRegistration;
import mezz.jei.api.runtime.*;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import java.util.*;
import java.util.stream.Collectors;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.server.command.ModIdArgument;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;

@mezz.jei.api.JeiPlugin
public class [custom element name] implements IModPlugin { 
	
	@Override
	public ResourceLocation getPluginUid() {
		return new ResourceLocation("[mod name]", "default");
	}

	@Override
        public void registerRecipes(IRecipeRegistration registry) {
		IIngredientManager ingredientManager = registry.getIngredientManager();

		
		IIngredientType<ItemStack> itemType = ingredientManager.getIngredientType(ItemStack.class);



     }
}


So it should look like this:

In the screenshot I have replaced the [custom element name] and [mod name] with the custom element name and the mods name.

If it has been done correctly so far, it should not come up with any errors when you click on the build mod button or press play.
 

To add a description to an item then add this code below the IIngredientType line

registry.addIngredientInfo(new ItemStack([itemname].block), itemType, "[description]");

And also import the item or block you are creating the description for

import net.mcreator.[modname].item.[ItemName];

import net.mcreator.[modname].block.[BlockName];

Eg:

And they should appear in game
 

If you are having trouble trying to get the names of your items then i have a solution
Make a procedure and do this

(I have put in the item and block from my example)

Then close and save it, then open it using the edit code button.

You can get the names of the items / blocks here and delete the procedure after you have finished.
I hope this easy enough to follow or that I have explained it well enough.

Edited by cubicgraphics on Sun, 04/11/2021 - 20:52
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice tutorial! One question…
Tue, 04/20/2021 - 11:31

Nice tutorial!

One question tough: if I want to have several items having a description, do I need to create the custom element JeiPlugin for each one or can i put all the descriptions in the same one? And if yes, how?

Thanks in advance

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi ! Look at the screenshot…
Thu, 05/13/2021 - 20:55

Hi !

Look at the screenshot juste before the in game example :

Screenshot

You can see he added a description for two items, you can add as many as you want by just adding another line info. So you put all descriptions in one custom element.

Joined Apr 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Good tutorial but instead of…
Thu, 05/13/2021 - 22:33

Good tutorial but instead of creating a new IngredientType

I think you should use VanillaTypes.ITEM instead.

Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
is it work on 1.16.5?
Thu, 05/20/2021 - 09:47

is it work on 1.16.5?

Joined Apr 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It should. Just change…
Thu, 05/20/2021 - 10:42

It should. Just change version of it in gradle.

Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I cant seem to get this to…
Sun, 07/11/2021 - 08:27

I cant seem to get this to work, every time I try this the JeiPlugin custom element fails on me. Error is at the period after item and the first letter of my item in [itemname]
import net.mcreator.[modname].item.[itemname];

and 

registry.addIngredientInfo(new ItemStack([itemname].block), itemType, "[descriptoin]";

more specifcally "error: cant find symbol" for both

can I get some help please? and yes, I changed the [itemname] / [modname] to the correct things.

Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Pls can you make a Tutorial…
Sun, 07/18/2021 - 14:26

Pls can you make a Tutorial for Custom JEI Recipes?

Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I got an error on line 20…
Sun, 02/06/2022 - 16:42

I got an error on line 20 with the bracket, and I don't know why. Can anybody help?

Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have had this working on 1…
Sun, 02/27/2022 - 03:51

I have had this working on 1.14/15/16 it's very easy to enable.

I am trying to look at more advance things like links to other items or tool tips on works but part from that I have fully got the basic items to work.

Mine is little different to this but I have also tested this and it works fine.

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If i use a plug-in to add…
Tue, 09/06/2022 - 21:15

If i use a plug-in to add JEI api, do i need to add the stuff to the build.gradle?