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.
I don't see the colors on your images sorry but are you sure you used 1.14.4 version and latest MCreator (2020.2) ?
You have to go to "Localization" and in front of the name "Enchanted book" you add the color code of yellow which is "\u00A7e``
So you get "\u00A7eEnchanted Book" and Minecraft will change the "\u00A7e" into yellow and Enchanted Book will appear in yellow.
i have done that but the colour codes show up ingame instead of changing the colour, yes i have the latest version
show me a screenshot of the localization tab and in-game color
I found out what was the problem.
The color code you had to put isn't "\u00A7e" but its "§e"
So in the Localization tab, you need to put "§eEnchanted Book" and it should work out
okay this is extremely complicated I mean how do you even do this and how did you figure it out.
Cool
help i cant open your workspace i dont know why and when i can open it its clear it have nothing inside
Just change its rarity to uncommon
_Bob_ enchantments are a feature and also the rarity feature until recently
What's so bad about double posting?
It clogs up the comment section and violates the MCreator publishing guidelines.