Posted June 11, 201411 yr 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.).
June 11, 201411 yr 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]);
June 15, 201411 yr 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 _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
June 15, 201411 yr 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.