Elite_Forges Posted November 15, 2013 Share Posted November 15, 2013 I really need to know a working (and tested, too) way to code it so when you craft with an item, it takes damage for each use until it finally runs out of durability and gets destroyed. I am working on a mod for my modpack and I have searched through a ridiculous amount of pages explaining how to do it with no success. I managed to get it to take 1 damage when crafted with but after you craft with it once, its done. You can't craft with it anymore and you are left with a slightly damaged item. I understand you use a crafting handler but I can't seem to get it to work any better then what I just explained. Can somebody out there please just take some time and explain to me exactly how to get this to work with minecraft version 1.6.2? If you could, I'd also like to know how to do the same thing, only instead of taking damage it just has infinite uses. I tried setting the metadata value in the crafting recipes to -1 but that had no effect. An example of this is Equivalent Exchange 3 and Pam's Harvestcraft. In EE3, if you craft with a minium stone, for every time you use it it takes a damage then destroys itself when it's out of durability, just like a tool such as a pickaxe does when it's out of uses. I need to get this same thing to happen with 2 of my mod items. In Pam's Harvestcraft, the cooking utensils such as the juicer or the cutting board have infinite uses in crafting. For example, if you need to use the juicer for some jelly, you put it next to the fruit of choice in the crafting table and when you click on the final product to craft it, the juicer stays while the fruit is consumed. I want this exact thing to happen for a few of my mod items. If you need any more information on my coding/mod please let me know and Il be happy to post it to you. I am not looking for a reply that leads me to another post unless it has been tested and proven to work with MC 1.6.2, so if you are going to reply with a link to a tutorial or something like that, please make sure that you KNOW it works. Quote Link to comment Share on other sites More sharing options...
chimera27 Posted November 16, 2013 Share Posted November 16, 2013 The mod EE3 is open source and has an item that does this called the Minium Stone, I would check that out! All his code is really readable too, so it should be quite easy to track down how he did that! Quote Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more! http://i.imgur.com/ghgWmA3.jpg[/img] Link to comment Share on other sites More sharing options...
TheGreyGhost Posted November 16, 2013 Share Posted November 16, 2013 Hi I don't have any working code, so if that's a problem you should stop reading now :-P I think I might be able to help you get one step further what what you've figured out already- ShapedRecipes: .checkMatch() and in particular if (itemstack1 != null || itemstack != null) { if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) { return false; } if (itemstack.itemID != itemstack1.itemID) { return false; } if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage()) { return false; } } This is probably the reason that your item stops crafting when it's been damaged. Luckily it looks like you can create your own MyRecipe implements IRecipe to change the matching to whatever you want (i.e. ignoring damage). Alternatively, if you put your Item in the Recipe as an ItemStack with damage of 32767, I think it will match regardless of the damage of the tool. -TGG Quote Link to comment Share on other sites More sharing options...
Elite_Forges Posted November 16, 2013 Author Share Posted November 16, 2013 Thanks for the suggestions so far but I have no success either that or im entering in your code into the wrong place/replacing the wrong parts Quote Link to comment Share on other sites More sharing options...
TheGreyGhost Posted November 16, 2013 Share Posted November 16, 2013 Hi Hmm that's a bummer What I mean is for example ItemStack dirtStack = new ItemStack(Block.dirt); ItemStack matchAnyDamageValueItemStack = new ItemStack(MyItem, 1, 32767); GameRegistry.addRecipe(new ItemStack(Block.cobblestone), "xy", "yx", 'x', dirtStack, 'y', matchAnyDamageValueItemStack); That way the recipe should match your item regardless of its damage value. (You said you've already figured out how to damage the item by 1 every time it is crafted with?) -TGG Quote Link to comment Share on other sites More sharing options...
ThePocketSoul Posted November 16, 2013 Share Posted November 16, 2013 Hi Hmm that's a bummer What I mean is for example ItemStack dirtStack = new ItemStack(Block.dirt); ItemStack matchAnyDamageValueItemStack = new ItemStack(MyItem, 1, 32767); GameRegistry.addRecipe(new ItemStack(Block.cobblestone), "xy", "yx", 'x', dirtStack, 'y', matchAnyDamageValueItemStack); That way the recipe should match your item regardless of its damage value. (You said you've already figured out how to damage the item by 1 every time it is crafted with?) -TGG Here use this ItemStack dirtStack = new ItemStack(Block.dirt); ItemStack matchAnyDamageValueItemStack = new ItemStack(MyItem, 1, WILDCARD_VALUE); GameRegistry.addRecipe(new ItemStack(Block.cobblestone), "xy", "yx", 'x', dirtStack, 'y', matchAnyDamageValueItemStack); and put this somewhere too public static final int WILDCARD_VALUE = Short.MAX_VALUE; Quote Link to comment Share on other sites More sharing options...
GotoLink Posted November 16, 2013 Share Posted November 16, 2013 I'd complete ThePocketSoul answer with OreDictionary.WILD_CARD_VALUE let Forge handle that for you Quote Link to comment Share on other sites More sharing options...
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.