Jump to content

Recommended Posts

Posted

Hi was wondering if there was a way to pre-enchant items when you craft them. If so can you please give me the method(im not asking for the args to be filled in just what the line of code for it would be.).

Posted

you can return an itemstack in a crafting recipe, so you can just append the enchantment on that itemstack and then return it.

return itemstack.addEnchantment([your enchantment], [your level of the enchantment]);

Posted

First (assuming you created your item) you need to make the ItemStack of your item. Do this

 

code start

 

registerItem(yourItem, "Your item"); //<--- normal thing

ItemStack yourItemStack= new ItemStack(YourMainClass.yourItem); //making an ItemStack
yourItemStack.addEnchantment(Enchantment.protection, 3); // adding enchantments. Do what ever you like
yourItemStack.addEnchantment(Enchantment.unbreaking, 2);
GameRegistry.addRecipe(yourItemStack, new Object[] { "###", '#', Blocks.dirt}); //adding a recipe. So when your item is crafted, it will have enchantments on it 

 

code end

 

I hope this helps :)

_         

___ ___| |__  _ __ 

/ __/ __| '_ \| '_ \

\__ \__ \ | | | | | |

|___/___/_| |_|_| |_|

Posted

Stop over complicating things. I would use onUpdate or onCreated in your item's class. There you can use the same method and you won't have to over complicate code.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information

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

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

Announcements



×
×
  • Create New...

Important Information

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