Started by
Taras Ogurtsov
on
Topic category: Help with Minecraft modding (Java Edition)
In my mod there are placeable items, one of which is a kitchen knife that has its own durability. I would like to know how to make it so that when I break a block, I don't get a new knife, but a knife with the strength it had before it was placed.
Hello!
A slightly messy way to do this, but simple in concept, would be to create an invisible entity to hold your knife in their inventory, and then give it back when right clicked again.
You can use block NBT tags for it too, just make sure you enable Block Entity for the block you are working on.
Hope this helps!
You can add this to the procedure when you place the knife:
And this to the procedure when you pickup the knife:
And replace "Provided itemstack" or "Item in main hand of the player" to anything that refers to your knife in the procedure of course.
Thanks for the help!