Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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.

Posted

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

Posted

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

Posted

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.

Posted

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.

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.