knokko / custom-items-gradle

Knokko's Custom Items: Add custom items to your server, completely free of charge
MIT License
15 stars 3 forks source link

Show custom tool durability bar in minecraft 1.14 and later #179

Closed knokko closed 2 weeks ago

knokko commented 2 years ago

Currently, custom tools never have a durability bar because they are technically unbreakable. In the past, this was absolutely required because only unbreakable tools could be retextured. But if I were to use CustomModelData instead, this would no longer be required.

But, this is not as easy as it looks: when I remove the unbreakable tag, the custom tool will also lose 'natural' durability, which may conflict with its custom durability. To avoid this, I should change the 'minecraft durability' of the custom tool to ('current custom durability' / 'max custom durability') * 'max minecraft durability' whenever the durability changes. (But I should be careful when the durability gets close to 0...)

If done properly, this should give the illusion that the tool truly has a custom durability with a nice durability bar.