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

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

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.

tDmixXt.png

I am the author of Draconic Evolution

  • 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

 

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

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

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.