After reading multiple tutorials about NBT in ItemStacks, I wonder, why NBT is not saved for me.
This is my code:
What I expect from this code:
First click on itemstack should result in text "New NBT = TEST".
Every click on the itemstack after the first click, should result in “Old NBT = TEST”, because the first click overwrote the default-nulled stackTagCompound to a newly initialized NBT with real values.
But instead I always get "New NBT = TEST", no matter how many times I click. By this, it is clear, that data is written to stackTagCompound, but not saved.
From the tutorials and documentations, I understand, that stackTagCompound is available in every itemstack by default, but set to “null”. Obviously, my code successfully writes to stackTagCompound and it is not “null” anymore until end of the current procedure. Why is it not saved?
In no tutorial is mentioned, that saving/loading stackTagCompound needs to be done manually. I presumed the stackTagCompound is handled by MC automatically.
I am sure, I miss something essential.
While thinking about it: Is this related to creative mode? I haven’t tried in survival mode and can’t do so at the moment...