BraunBerry Posted October 1, 2022 Share Posted October 1, 2022 Hello everyone, In some mods, tools can be upgraded to a higher tier in the crafting table. The interesting part is, that the durability of the tool is kept during the crafting process. For example, in my mod I implemented various kinds of hammers (they are kind of similar to pickaxes). I can for example upgrade a stone hammer to an iron hammer using the following crafting recipe: X | X | X ---+---+--- X | H | X = Y ---+---+--- X | X | X where X = Iron Ingot H = Stone Hammer and Y = Iron Hammer The problem is, that the iron hammer has full durability every time regardless of the durability of the stone hammer. The use count for the material "Stone" is 131 uses and the use count for the material "Iron" is 250 uses. My goal is to keep the original durability during crafting and transfer it to the output tool. For example, if the stone hammer has a durability of 50/131 uses, the iron hammer should have a durability of 50/250 uses after crafting. Is there any way to achieve such a behaviour? Thank you in advance. Quote Link to comment Share on other sites More sharing options...
JoeBox9 Posted October 1, 2022 Share Posted October 1, 2022 1 hour ago, BraunBerry said: Hello everyone, In some mods, tools can be upgraded to a higher tier in the crafting table. The interesting part is, that the durability of the tool is kept during the crafting process. For example, in my mod I implemented various kinds of hammers (they are kind of similar to pickaxes). I can for example upgrade a stone hammer to an iron hammer using the following crafting recipe: X | X | X ---+---+--- X | H | X = Y ---+---+--- X | X | X where X = Iron Ingot H = Stone Hammer and Y = Iron Hammer The problem is, that the iron hammer has full durability every time regardless of the durability of the stone hammer. The use count for the material "Stone" is 131 uses and the use count for the material "Iron" is 250 uses. My goal is to keep the original durability during crafting and transfer it to the output tool. For example, if the stone hammer has a durability of 50/131 uses, the iron hammer should have a durability of 50/250 uses after crafting. Is there any way to achieve such a behaviour? Thank you in advance. I am a layman here, Have you tried googling really hard or looking at the code of other mods that have that? Quote Link to comment Share on other sites More sharing options...
warjort Posted October 1, 2022 Share Posted October 1, 2022 There is no way to change the NBT of an item crafted in the crafting table. Well there is, but it is not intended behaviour, glitchy and only works in some circumstances. 🙂 If you want this kind of thing you need to write your own "crafting table" where you can control what gets put in the result slot. I think you are confusing your requested behaviour with the IForgeItem.getRemainingItem() behaviour. Where you can change the item used in the crafting recipe. e.g. turning a lava bucket into an empty bucket, or damaging a tool used in crafting Or maybe you are thinking of the "hardcoded" repair processing in the anvil? Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post. Link to comment Share on other sites More sharing options...
BraunBerry Posted October 1, 2022 Author Share Posted October 1, 2022 Okay, thank you! Since smithing already provides the desired behaviour, I think I will just transform the crafting recipes to smithing recipes. So I don't have to invent a completely new mechanic. 😅 Quote Link to comment Share on other sites More sharing options...
Choonster Posted October 1, 2022 Share Posted October 1, 2022 It's entirely possible for crafting table recipes to customise their output (including setting NBT/damage) by overriding IRecipe#assemble. I have a recipe that does a similar thing for armour here. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. 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.