Posted June 21, 201510 yr I have this: GameRegistry.addRecipe(new ItemStack(Items.diamond_sword), " E ", " E ", " S ", 'E', Items.emerald, 'S', Items.stick); Except I want the diamond sword that comes out to be enchanted, and I'm not sure how to do that. "It's basically a big ball of wibily wobily timey wimey." - The Doctor
June 21, 201510 yr You make the ItemStack first, add the enchantment, then create the recipe: ItemStack stack = new ItemStack(sword, ...); stack.addEnchantment(whateverEnchantmentYouWant, ...); GameRegistry.addRecipe(stack, ...); http://i.imgur.com/NdrFdld.png[/img]
June 21, 201510 yr Author I did this: ItemStack stack = new ItemStack(Items.diamond_sword); stack.addEnchantment(sharpness, 4); GameRegistry.addRecipe(new ItemStack(Items.diamond_sword), " E ", " E ", " S ", 'E', Items.emerald, 'S', Items.stick); Still have a bunch of errors... help? (Sorry about this.) "It's basically a big ball of wibily wobily timey wimey." - The Doctor
June 21, 201510 yr Show the errors, don't just say you have errors. No one will know how to help if you don't show the errors
June 21, 201510 yr I did this: ItemStack stack = new ItemStack(Items.diamond_sowrd); stack.addEnchantment(sharpness, 4); GameRegistry.addRecipe(new ItemStack(Items.diamond_sword), " E ", " E ", " S ", 'E', Items.emerald, 'S', Items.stick); Still have a bunch of errors... help? (Sorry about this.) Yikes - you probably need to spend some time following Java tutorials. 1. Items.diamond_sowrd is misspelled, which your IDE would probably tell you if you hovered over the error 2. GameRegistry.addRecipe(new ItemStack(Items.diamond_sword), <-- not an error, but that is not the stack with the enchanment Well that's it - I only saw one error that your IDE would complain about, so if you're getting a 'bunch', then you've got some work to do. http://i.imgur.com/NdrFdld.png[/img]
June 21, 201510 yr Author I fixed the spelling error a couple of seconds after posting that reply... So by stack does that mean I put (stack, 1) instead of diamond_sword? I'm new to this and haven't even got around to adding custom Items yet... but recipes where at least easy enough for me to have some fun with it until I learn more so I can go to Items. Sorry for my noob-y-ness. "It's basically a big ball of wibily wobily timey wimey." - The Doctor
June 21, 201510 yr The one is not required when your output is only one item, thats what ItemStack defaults to, secondly don't create a new ItemStack when you have an ItemStack already created, where new ItemStack(Items.diamond_sword) is should just be stack
June 21, 201510 yr You make the ItemStack first, add the enchantment, then create the recipe: ItemStack stack = new ItemStack(sword, ...); stack.addEnchantment(whateverEnchantmentYouWant, ...); GameRegistry.addRecipe(stack, ...); @OP DO you see what I used for addRecipe? 'stack', because that's the name of the ItemStack to which I added the enchantment, and that's the stack I want as the recipe output. http://i.imgur.com/NdrFdld.png[/img]
June 21, 201510 yr Author Okay, so that fixed a couple of errors, but it's still saying that there isn't a such thing as "sharpness" "It's basically a big ball of wibily wobily timey wimey." - The Doctor
June 21, 201510 yr Because there is no LOCAL VARIABLE called sharpness, you have to call the class with Enchantment.whateverEnchantmentYouWant. If you want to know "no such variable" then try learning some basic java, then go back to modding.
June 21, 201510 yr Author I added "Enchantment." in front of sharpness and it fixed it. Thank You! "It's basically a big ball of wibily wobily timey wimey." - The Doctor
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.