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.

Using a tool as a crafting ingredient, regardless of condition (damage) in 1.8

Featured Replies

Posted

Hello;

 

   I am relatively new to modding MC, and have been quickly picking up skills in modding 1.8 w/Forge.

 

   Now I have run into a "snag", and I'm sure many (most?) of you have seen this problem before...

 

   I want to implement "recycling" of my (relatively "expensive") custom tools and armor in my mod, and I thought I could easily implement this using crafting recipes in the vanilla crafting table. For any tool or armor item (my mods ONLY), I would also require that one other item from my mod be present in the shapeless recipe as well (a specific GEM item, for example...).

 

   Now, I have this working well in 1.8, for any BRAND-NEW tool or armor item (ie one not yet damaged through use). But, whenever the item has been even the slightest bit damaged, that same item no longer works!

 

   I am aware that, previously, you would use an ItemStack with a condition value of -1, and this would work:

         new ItemStack(myModItem.SpecialSword, 1, -1)

 

instead of just the item itself. So, for example:

                   GameRegistry.addShapelessRecipe(new ItemStack(myModItem.specialIngot, myModItem.customGem, new ItemStack(myModItem.SpecialSword, 1, -1));

 

would give me an ingot back from the recycling of my mods custom sword. But this does not seem to work when the sword has taken even the slightest bit of damage!

 

   Is there any way to make a custom sword, in any condition, act as the "same sword" in a crafting recipe?

 

You might also create a villager profession (junk dealer?) who offers custom trades (takes damaged tool and returns its repair item). Then your players would not only have a way to recycle, but they'd have new motivation to find and develop villages.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

10 minutes ago, TheSunCat said:

How do you create a new villager profession? Is there any solved topics on this?

Have you tried the search feature yet?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Thanks, Diesieben07! That's got it. Where can I find out more about the OreDictionary, because it looks incredibly interesting, as well as useful! I mean, I really don't know how I would have ever figured this one out. Got any good links? Something relevant, but also that pertains to MC 1.8 as well (ie. not too recent)?

  • Author

 

Thanks for the link, lars!

 

   I did actually read a lot of the Forge docs at that site, when I was first researching BlockStates...; somehow, I simply "missed" the OreDictionary! I am going to read it ALL now...

 

   Much appreciated!

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.