Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

  • 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

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.

  • 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

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

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.

  • 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

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.

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.