Help with NBT

Started by Taras Ogurtsov on

Topic category: Help with modding (Java Edition)

Last seen on 17:16, 21. Jun 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help with NBT

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.

Last seen on 16:59, 25. Jun 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello!A slightly messy way…
Tue, 08/01/2023 - 20:02

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!

Last seen on 14:53, 23. Aug 2023
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can add this to the…
Fri, 08/04/2023 - 00:42

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.

Last seen on 17:16, 21. Jun 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for the help!
Fri, 08/04/2023 - 17:57

Thanks for the help!