Jump to content

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


ZTagre

Recommended Posts

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

 

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!

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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