Posted May 10, 201411 yr Hi, I've been working on this for a few days now and I can't seem to get it to work. I'm making a pick to have fortune 5 when crafted. I've tried many different sources, Forge forums, MC forums, etc. Here's the code for the Pickaxe class package DiamondEnder.items.tools.witherEnder; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import DiamondEnder.DiamondEnder; public class WitherEnderPickaxe extends ItemPickaxe { // Constructors public WitherEnderPickaxe(ToolMaterial material) { super(material); this.setUnlocalizedName("WitherEnderPickaxe"); this.setTextureName("diamondender:WitherEnderPickaxe"); this.setCreativeTab(DiamondEnder.tabDiamondEnderT4); ItemStack WitherEnderPickaxe = new ItemStack(DiamondEnder.WitherEnderPickaxe); { if(!WitherEnderPickaxe.hasEffect(Enchantment.fortune.effectId)) { WitherEnderPickaxe.addEnchantment(Enchantment.fortune, 5); } } } } What am I doing wrong? Thanks in advance for any help I get
May 10, 201411 yr your best bet would be to add the enchant when crafting it just give me a minute to set up an example I am the author of Draconic Evolution
May 10, 201411 yr when you register your recipe do it like this. ItemStack enchantedPick = new ItemStack(Items.diamond_pickaxe); enchantedPick.addEnchantment(Enchantment.fortune, 5); CraftingManager.getInstance().addRecipe(enchantedPick, "DDD", " S ", "BSB", 'D', Items.diamond, 'S', Items.stick, 'B', Items.book); The way this works is you are creating a new instance of the pick (in this case diamond) and adding the enchant to that then in the recipe you return the enchanted pick. I am the author of Draconic Evolution
May 10, 201411 yr Author Why's that? I've just starting modding in 1.7.2 and have never done anything other than basic wepons and blocks, etc. I had no idea how to do it, I studied the web and found nothing. Just because you're really good at thisa doesn't mean everyone else is. Give me a break
May 10, 201411 yr This thread makes me sad. Oh didnt see your post. Yes that is a much better way to do it! @Override public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par1ItemStack.addEnchantment(Enchantment.fortune, 5); super.onCreated(par1ItemStack, par2World, par3EntityPlayer); } Not sure if you need the super call or not. Edit: no i dont think you do. I think he was sad because he gave a perfect solution (which i didnt see) then i gave another solution which works but isnt nearly as good and you decided to go with mine. I am the author of Draconic Evolution
May 10, 201411 yr Author On that note, can you make a tool material have enchantments, say a shovel, and a pick having the same enchantments using just 1 method overall?
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.