[TUTORIAL] How to create custom enchants (1.14.4)

Started by Max094_Reikeb on

Topic category: User side tutorials

Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] How to create custom enchants (1.14.4)

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".
toolenchant

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".
procedureeffect
kind

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.
lt

And tadam! Over! This is how it looks In Game:
igl

Of course, if you didn't understand what I've done, I have a little something for you: the archive of my project!
Here it ishttps://mega.nz/#!bAM0xapT!al1UVYpkXBxoxi1rtaEBR0qSK0oLcx6sohJ7hjh6Xy0

Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't see the colors on…
Sat, 04/18/2020 - 14:43

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.

Joined Apr 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i have done that but the…
Sat, 04/18/2020 - 15:28

i have done that but the colour codes show up ingame instead of changing the colour, yes i have the latest version

Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
show me a screenshot of the…
Sat, 04/18/2020 - 15:29

show me a screenshot of the localization tab and in-game color

 

Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I found out what was the…
Thu, 04/23/2020 - 13:29

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

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
okay this is extremely…
Thu, 05/14/2020 - 18:59

okay this is extremely complicated I mean how do you even do this and how did you figure it out.

 

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
help i cant open your…
Sat, 06/06/2020 - 00:47

help i cant open your workspace i dont know why and when i can open it its clear it have nothing inside

 

Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Just change its rarity to…
Wed, 01/27/2021 - 11:58

Just change its rarity to uncommon

Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
_Bob_ enchantments are a…
Wed, 02/10/2021 - 21:37

_Bob_ enchantments are a feature and also the rarity feature until recently

Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What's so bad about double…
Mon, 04/12/2021 - 13:25

What's so bad about double posting?

Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It clogs up the comment…
Mon, 04/12/2021 - 14:25

It clogs up the comment section and violates the MCreator publishing guidelines.