Posted June 25, 201411 yr hey guys , who knows how to add custom sword enchantment by default , like at twithlight forest mod? that i would be show in creative to Proud mod developer of: Mob Armor mod Block monster mod Clay Living Dolls mod Much More Spiders mod Elemental cows reborn Mr gorilla mod
June 26, 201411 yr Author bump, how add one, by default on sword or armor, like in creative tab and it will work to Proud mod developer of: Mob Armor mod Block monster mod Clay Living Dolls mod Much More Spiders mod Elemental cows reborn Mr gorilla mod
June 26, 201411 yr You can create your own enchantment class and declare it in your mod class package claygolem.util; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnumEnchantmentType; public class EnchantmentTest extends Enchantment { private static final String __OBFID = "CL_00000100"; public EnchantmentTest(int effectID, int weight) { super(effectID, weight, EnumEnchantmentType.weapon); this.setName("testEnchantment"); } /** * Returns the minimal value of enchantability needed on the enchantment level passed. */ public int getMinEnchantability(int par1) { return 20; } /** * Returns the maximum value of enchantability nedded on the enchantment level passed. */ public int getMaxEnchantability(int par1) { return 50; } /** * Returns the maximum level that the enchantment can have. */ public int getMaxLevel() { return 1; } } in your mod class, add the following: /** custom enchantment 'Test' */ public static final Enchantment test = new EnchantmentTest(113, 0);//id's may not conflict, maybe register the id in a config so it stays compatible with other mods.
June 26, 201411 yr Author how to make that enchantment usable? Proud mod developer of: Mob Armor mod Block monster mod Clay Living Dolls mod Much More Spiders mod Elemental cows reborn Mr gorilla mod
June 26, 201411 yr Well you can write an event that triggers when the player hits an entity. //I don't know which event it is, you would have to look it up yourself. EntityPlayer player = event.Player; ItemStack stack = player.inventory.getCurrentItem(); if(stack != null && stack.isItemEnchanted()) { if(EnchantmentHelper.getEnchantmentLevel(Enchantment.baneOfArthropods.effectId, stack) > 0) System.out.println("BoA");//do effect } Using the EnchantmentHelper class, you can check for all enchantments on the itemstack using EnchantmentHelper#getEnchantments this will return a hashmap. I used it to combine effect, like if horse armor had fire aspect + some custom ones, do the following.
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.