Topic category: User side tutorials
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.
Nice tutorial!
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
Hi !
Look at the screenshot juste before the in game example :
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.
Good tutorial but instead of creating a new IngredientType
I think you should use VanillaTypes.ITEM instead.
is it work on 1.16.5?
It should. Just change version of it in gradle.
Thx!
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.
Pls can you make a Tutorial for Custom JEI Recipes?
I got an error on line 20 with the bracket, and I don't know why. Can anybody help?
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.
If i use a plug-in to add JEI api, do i need to add the stuff to the build.gradle?