Topic category: User side tutorials
For this tutorial, I'll show you how to create a custom enchantment.
But read this WARNING first : the enchantments that you'll create will be applied only on custom items that you create (so no vanilla) and these enchantments won't be found in the enchantment table and you won't be able to use them in the Anvil.
Are you good? Here we go!
First of all, you need to create an Enchanted Book. On the first page, you will add the name of your enchantment as the description. And don't forget to check "glowing effect".
Then, you'll need to edit your Enchanted Book, and around line 60, you'll find this
list.add(new StringTextComponent("Thundering"));
You'll need to add "\u00A77" before the Enchantment name to set it as the others, in grey. When you finish, lock the code, and build the workspace.
Then, you'll need to create your tool. Create it and don't forget to create the effect of your Enchantment. I wanted an enchantment that makes you able to summon lightning. And as a condition, you'll need to check if the NBT tag is true. And finally, don't forget to link the procedure to your item. For me, it'll be "When right clicked on block".
Then, again, you'll need to enter a code: your tool's code. You'll need these dependencies (take out the one you've got already)
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.world.World;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Direction;
import net.minecraft.util.ActionResultType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Item;
import net.minecraft.item.IItemTier;
import net.minecraft.item.AxeItem;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.block.BlockState;
And also, if it's not here, don't forget to call your procedure (replace ThunderingEffectProcedure by the name of your procedure)
import net.mcreator.testenchant.procedures.ThunderingEffectProcedure;
Then around line 66, you'll see this:
}, 1, -2.7999999999999998f, new Item.Properties().group(ItemGroup.TOOLS)) {
@Override
public ActionResultType onItemUse(ItemUseContext context) {
........
........
........
}
}.setRegistryName("netherite_axe"));
}
You'll need to paste the following code between the line 1 of the extract above and the line 2 of the extract above:
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack itemstack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if ((((itemstack).getOrCreateTag().getBoolean("EnchantThundering")) == (true))) {
tooltip.add(new StringTextComponent("\u00A77Thundering"));
}
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean hasEffect(ItemStack itemstack) {
if ((((itemstack).getOrCreateTag().getBoolean("EnchantThundering")) == (true))) {
return true;
} else {
return false;
}
}
There are 2 things you'll need to modify: the name of the boolean because with me it's "EnchantThundering" but it'll be something else with you. The second thing is the name of the Enchantment with the line "tooltip.add(...);"
Almost done! The last thing you'll have to do is to find a way to give the Enchanted book to the players (can be a drop or a loot table) AND you'll need a way to apply the book on the tool.
For me, I've created a simple block with a GUI and in the procedure, I add the NBT tag to the tool.
Nice!
Hope you'll like it and use it!
Great tutorial! Might end up making some enchantments.
This is a great tutorial indeed! Love the work you did. Congrats on doing such a great job :]
Great Tutorial, my only problem is, is that the new enchanted book item stands out as the rest of the books are highlighted in yellow. Any idea on how to change the Items name colour?
also the images are broken
Please, avoid double posts.
What do you mean by "the images are broken"?
To change an item name (the name of the book) you need to go to the tab named "Localization" and there you will be able to use a color code.
Ok, i didn't double post but thanks :D
im confused, i have been to the localisation tabs but none of the colour codes work? where exactly do i put the colour code?
Please again avoid double posts!
And download the workspace I gave at the end of the tutorial to see it!
Your google/ firefox or whatever you use is glitched, or its the website. im not double posting :/
Yes you are double posting.
oops i realise my mistake, i thought you meant double posting as in 2 posts with the same exact words, sorry and im doing it again!
also the workspace provided did not help with the question i asked you as you have not done that either. What i asked is if you know how to make The Enchanting Books label be yellow instead of white. i have some images so you can see what i mean.
Here is your book:
Here is minecrafts book (with a yellow tag in the name of the book):
well mcreator didnt show the images so heres the links to them
Your book:
https://www.pinterest.co.uk/pin/644507396662459335/
Minecrafts book (with the yellow name instead of it being white):
https://www.pinterest.co.uk/pin/644507396662459341/