Started by
Ion99
on
Topic category: Help with Minecraft modding (Java Edition)
First of all, before anyone comments "just set the durability to zero," no, that's not what I want. I want a melee weapon with very limited durability that still stays in your inventory when it breaks, and you just can't use it until the durability is replenished or "reloaded" with a certain item by hitting a key (I kinda know how keybinds work) with the weapon in your hand, which depletes the count of said specific item by one, and in turn heals the durability of the weapon by one.
I really hope I can get some help in order to achieve something at least remotely similar to this idea. Anything's appreciated, thanks.
Make a procedure for the object that, when its durability is at 1, (or some other low value), the item is swapped out with a 'damaged' variant of that item. (Making sure to retain the name, enchantments, NBT data, etc.) Then when the keybind is pressed, just swap it out again. I use this system for reloadable weapons, and it works pretty well. (Though retaining custom data between items can be somewhat tricky, and you need to check that the item is named before transferring names; otherwise it'll italicize the item's name the first time it's reloaded, which isn't the end of the world, but is slightly annoying. You can check if the display name equals the registry name of the item to get around this.)