Hardc0r3Br0n3 Posted June 21, 2015 Posted June 21, 2015 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. Quote "It's basically a big ball of wibily wobily timey wimey." - The Doctor
coolAlias Posted June 21, 2015 Posted June 21, 2015 You make the ItemStack first, add the enchantment, then create the recipe: ItemStack stack = new ItemStack(sword, ...); stack.addEnchantment(whateverEnchantmentYouWant, ...); GameRegistry.addRecipe(stack, ...); Quote http://i.imgur.com/NdrFdld.png[/img]
Hardc0r3Br0n3 Posted June 21, 2015 Author Posted June 21, 2015 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.) Quote "It's basically a big ball of wibily wobily timey wimey." - The Doctor
Jedispencer21 Posted June 21, 2015 Posted June 21, 2015 Show the errors, don't just say you have errors. No one will know how to help if you don't show the errors Quote
coolAlias Posted June 21, 2015 Posted June 21, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img]
Hardc0r3Br0n3 Posted June 21, 2015 Author Posted June 21, 2015 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. Quote "It's basically a big ball of wibily wobily timey wimey." - The Doctor
Jedispencer21 Posted June 21, 2015 Posted June 21, 2015 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 Quote
coolAlias Posted June 21, 2015 Posted June 21, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img]
Hardc0r3Br0n3 Posted June 21, 2015 Author Posted June 21, 2015 Okay, so that fixed a couple of errors, but it's still saying that there isn't a such thing as "sharpness" Quote "It's basically a big ball of wibily wobily timey wimey." - The Doctor
Jedispencer21 Posted June 21, 2015 Posted June 21, 2015 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. Quote
Hardc0r3Br0n3 Posted June 21, 2015 Author Posted June 21, 2015 I added "Enchantment." in front of sharpness and it fixed it. Thank You! Quote "It's basically a big ball of wibily wobily timey wimey." - The Doctor
Recommended Posts
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.