Modifying Max durability on individual items?

Started by deathzero021 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Modifying Max durability on individual items?

How much work would it take to create an item that can be used either in crafting table or smithing table that increases the max durability of a tool\armor ?  

 

Ideally I am thinking of a mod that extended the max durability of a tool that can be used universally with other mods.

The code could potentially use the "repair item" variable of the tool to identify what the base material is and upgrade the durability based on that. But I'm not even sure if max durability can be changed on an individual item as opposed to modifying the entire item class.

Anyone have any thoughts or tips? 

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well all I can think of is…
Wed, 08/30/2023 - 06:43

Well all I can think of is that Unbreaking kind already does this, while not exactly increasing the durability it lowers the chance of a durability point to get used. Something similar to this might be better? Like having a chance of healing 1 durability on item use?

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I see what you mean but I…
Wed, 08/30/2023 - 18:28

I see what you mean but I think that would be confusing for players. Unbreaking is already confusing because it doesn't communicate to the player any information on how it works or extends the durability since it's basically rolling a dice every time you use the tool.

Is it possible to force the current durability to be over the max? I think I may have seen this done in commands before but I don't know for sure.

 

I was also thinking of potentially allowing the player to use the item via right clicking to instantly restore durability on the tool in left hand, but that wouldn't be as convenient for armor. 

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tested the concept of…
Thu, 08/31/2023 - 06:18

I tested the concept of using commands to set durability higher than the max and it can be done, but it's buggy. It appears that you have to set the damage tag to over the max durability, which will cause some overflow that show the tool as having negative durability that counts upwards to 0, than destroys itself. The durability bar is also glitched with the offset being pushed to the left of the icon. 

So basically this idea could only be done by completely rewriting item durability, which is too much work for such a small concept. 

My last ditch effort to do this than could be to have this new item be combinable with a tool of the same base material and apply "Unbreaking III" to it, perhaps either through the smithing table or anvil. (Anvil has some obvious drawbacks with XP costs that I would like to avoid) 

Is it possible to use Smithing to add enchantments though?

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@deathzeo021 The “damage…
Mon, 09/25/2023 - 23:29

@deathzeo021

The “damage item” procedure actually sets the amount of damage the item has taken, not how much durability it actually has left!

I would instead try to subtract the item damage by the amount of durability you want to add instead, admittedly this might not actually work (Minecraft might just decide to reset the durability or something because it’s to high of a value) but it might be worth a shot if your still trying to make something like this work.

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
As for adding enchantments…
Mon, 09/25/2023 - 23:37

As for adding enchantments to items in smithing tables recipes, you could probably do it pretty easily with a little bit of custome code (even I figured out how to do it and I’m absolutely terrible at Java script) you would just have to make the output item have the right NBT enchantment data which should be easy enough to find on the Minecraft wiki!