Jump to content

[SOLVED]Getting the ID of Custom Enchantments


Recommended Posts

So it's been a long time since I needed your help.


I've created an Enchantment which is called Devourer. I want my sword to have that enchant in creative inv and JEI. For that i will need to get the ID of that Enchantment. I've tried the getEnchantmentID(Enchantment) method but it returns actually nothing


Edit: I forgot to mention it's in 1.10.2

Link to comment
Share on other sites

You don't need to get the ID yourself. Use


to add an


to an




Make sure you've registered your





Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Choonster maybe if I post my code it will help to understand my problem




public class ItemToolSword extends ItemSword{


private String name;

private int enchantment, enchantmentLvl;


public ItemToolSword(ToolMaterial material, String name, int enchantment, int enchantmentLvl) {


this.name = name;

this.enchantment = enchantment;

this.enchantmentLvl = enchantmentLvl;


setRegistryName(NewToolAge.ModID, name);





public String getUnlocalizedName(){

return "item." + NewToolAge.ModID + ":" + name;




public String getUnlocalizedName(ItemStack stack) {

if (getHasSubtypes()) {

return getUnlocalizedName() + "." + stack.getItemDamage();



return getUnlocalizedName();




public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {

ItemStack result = new ItemStack(itemIn);


        if(enchantment != -1 && enchantmentLvl != -1) result.addEnchantment(Enchantment.getEnchantmentByID(enchantment), enchantmentLvl);

        if(enchantment == 71 && enchantmentLvl != -1) result.addEnchantment(ModEnchants.DEVOURER, enchantmentLvl);











public static final ItemToolSword TITANIUM_SWORD = new ItemToolSword(MaterialHandler.Tools.Titanium, "titanium_sword", -1, -1);

public static final ItemToolSword VIBRANIUM_SWORD = new ItemToolSword(MaterialHandler.Tools.Vibranium, "vibranium_sword", -1, -1);

public static final ItemToolSword ADAMANTIUM_SWORD = new ItemToolSword(MaterialHandler.Tools.Adamantium, "adamantium_sword", -1, -1);

public static final ItemToolSword SIRIUM_SWORD = new ItemToolSword(MaterialHandler.Tools.Sirium, "sirium_sword", -1, -1);

public static final ItemToolSword DEMONIC_SWORD = new ItemToolSword(MaterialHandler.Tools.Demonic, "demonic_sword", 71, -1);

public static final ItemToolSword STEEL_SWORD = new ItemToolSword(MaterialHandler.Tools.Steel, "steel_sword", -1, -1);

public static final ItemToolSword BRONZE_SWORD = new ItemToolSword(MaterialHandler.Tools.Bronze, "bronze_sword", -1, -1);

public static final ItemToolSword SILVER_SWORD = new ItemToolSword(MaterialHandler.Tools.Silver, "silver_sword", 17, 5);
















Link to comment
Share on other sites

Like other singletons,


IDs are automatically assigned and can change between saves. Do not use IDs, pass the


instance to your constructor.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.