How to add NBT tag unique for an item? (+questions about 'itemstack' thing)

Started by Toma400 on

Topic category: Help with modding (Java Edition)

How to add NBT tag unique for an item? (+questions about 'itemstack' thing)
Thu, 03/11/2021 - 13:46 (edited)

I tried to solve problem with adding clip mechanics for my firearms in mod. I thought it would be nice to have it as unique NBT tag for tool/item which will save how many ammo gun contains. Tried that with >>Set NBT number tag "Ammo" of provided itemstack<<, but it doesn't work with two different procedures, considering this value separately (I mean, these "NBT number tags" are local, and I'd like one that is bound with an item, not within procedure).
Is it any way for making that unique value which I can "get/set" on different procedures?

Also, second question is about itemstacks. When (back in the days) I wanted to make gun delay after shooting, using it on "provided itemstack" caused weird problem: if I have revolvers in both hands (the same type), they both were "locked".
I thought "provided itemstack" means --this specific item--, but after that "locking" I'm not sure if it's not --item of specific category--. Can someone explain me what kind of instance does "provided itemstack" refers to?

I'm using 2020.3 MCreator if that helps. Thanks in advance <3

Edited by Toma400 on Thu, 03/11/2021 - 13:46
Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
itemstack nbt data is not…
Sat, 03/13/2021 - 08:43

itemstack nbt data is not local variable . it is bound to that itemstack and will stay with that itemstack even if you drop it and its picked up by some other player.

"provided itemstack" is the itemstack that was passed to this procedure by the caller. 

Thanks for your answer. Not…
Sun, 03/14/2021 - 16:44

Thanks for your answer. Not sure if it's thanks to you or not, but I solved all issues, and shooting is now almost perfect <3 also thanks a lot for that information about itemstack not being local - I saw my mistake thanks to this, and also I know now how to use itemstack nbt data better ^^

Last seen on 09:11, 23. Mar 2024
Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
But is itemstack for example…
Sat, 01/28/2023 - 12:27

But is itemstack for example one of the 36 places in your inventory?