Jump to content

Forge 1.19 Keep Durability when upgrading Tool in Crafting Table


BraunBerry

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

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

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.

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

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I downloaded forge for 1.21 because I wanted to play the new update with a few mods. When I load up the game on the forge installation, the game seems to launch fine, but then freezes and goes into that "not responding" state a few seconds after sitting on the menu. It stays on not responding forever, and I have to close the game myself. The normal vanilla game without forge loads and works perfectly fine, though. The exit code I receive is either 1 or -805306369, depending on how I close the game. When I force close with task manager, I get exit code 1. When I close using the not responding menu (close the program or wait for it to respond), I get exit code -805306369. I tried taking all of the mods out to see if they were the problem, but the same issue still persists even with 0 mods in the mods folder. The pastebin linked is the log from when I launched the game with forge after taking all of the mods out of the mods folder. (Nothing ever shows up in the crash-reports folder, but I do have this from the logs): https://pastebin.com/9bL8awvE I had to delete some of the bottom of the log to be able to upload it onto pastebin, but anything deleted was identical to the lines there at the bottom. Some things I have tried include: Allocating more ram, updating display drivers, updating java version (currently have Java 21, tried switching to java 17 but that did not work either), removing or changing settings on programs that may conflict with minecraft (followed this list https://minecrafthopper.net/help/known-incompatible-software/). None have worked so far. I'm aware of course that this is a beta version of forge, but I just wanted to see if there was something I could do to fix this, or if I will just need to wait for a more stable, non beta version to be released.  
    • sorry if this is an incorrect log or wrong tag ive never used this before and im new to modding latest log: file:///C:/Users/jason/curseforge/minecraft/Instances/Cottage Witch/logs/latest.log
    • Hi its me from my first account. I added creative core but when i start minecraft he gives me an error. Now i can't send you the log but I will later 
    • I want my mod to add two new NBT values to Block Displays and Item Displays (Like left-rotation, scale, transformation, etc.), which I call texture_repetition and texture_shift (both Vector3f variables). Texture_repetition allows the Display to repeat its texture or only show part of it, and the texture_shift value allows you to shift to the part of the texture you want the display to show. I already tried Mixins, and I assume I need to use the renderstate() function and entityData variable, but entityData is protected, which means I can not edit it using Mixins. How would I add these NBT values to the Display class without using the entityData class? (These two data values, if coded correctly, could allow slabs/stairs/walls of any block to be represented using Displays without being limited by the vanilla inventory options)
  • Topics

×
×
  • Create New...

Important Information

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