Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

ItemStack#addEnchantment

to add an

Enchantment

to an

ItemStack

.

 

Make sure you've registered your

Enchantment

with

GameRegistry.register

.

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.

  • Author

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) {

super(material);

this.name = name;

this.enchantment = enchantment;

this.enchantmentLvl = enchantmentLvl;

 

setRegistryName(NewToolAge.ModID, name);

setCreativeTab(NewToolAge.INSTANCE.tab);

}

 

@Override

public String getUnlocalizedName(){

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

}

 

@Override

public String getUnlocalizedName(ItemStack stack) {

if (getHasSubtypes()) {

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

}

 

return getUnlocalizedName();

}

 

@Override

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);

     

        subItems.add(result);

}

 

}

 

 

 

 

 

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);

 

 

 

 

 

registerItem(ModItems.TITANIUM_SWORD);

registerItem(ModItems.VIBRANIUM_SWORD);

registerItem(ModItems.ADAMANTIUM_SWORD);

registerItem(ModItems.SIRIUM_SWORD);

registerItem(ModItems.DEMONIC_SWORD);

registerItem(ModItems.STEEL_SWORD);

registerItem(ModItems.BRONZE_SWORD);

registerItem(ModItems.SILVER_SWORD);

 

 

Like other singletons,

Enchantment

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

Enchantment

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.

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.