Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED][1.16] How to stop resetting nbt when player dies?


Recommended Posts

I have a class of items called Ragnarok_Cards. My ideia was creating the item Loot_Box with would spawn a random already seen card.

For that I was registering in nbt of player every time he pickup a card. But when the player dies, the nbt is reset.

How I can stop the nbt from resetting?
( Or if this is not the proper way of storing extra data of the player, what is the right one?)

 

Ragnarok_Card: https://github.com/GustavoSasaki/Ragnarok-Cards/blob/main/src/main/java/ragnarok_cards/Items/RagnarokCard.java

Pickup event: https://github.com/GustavoSasaki/Ragnarok-Cards/blob/main/src/main/java/ragnarok_cards/Events/PickUp.java

Loot_Box: https://github.com/GustavoSasaki/Ragnarok-Cards/blob/main/src/main/java/ragnarok_cards/Items/LootBox.java

Edited by theagente00g
Link to post
Share on other sites
  • @Mod.EventBusSubscriber(Dist.CLIENT) - This is not what you want. Why are you doing this only on the client?
  • When using Entity#getPersistentData you must store your data in a sub-compound namespaced by your Mod ID to avoid collisions. This is a global data dump where all mods have shared access to. A better option would be to use capabilities. Additionally, if you want the data to persist across respawns for players you must store the data in the PlayerEntity.PERSISTED_NBT_TAG sub compound. Again, a capability would be a better option.
  • Thanks 1
Link to post
Share on other sites
  • theagente00g changed the title to [SOLVED][1.16] How to stop resetting nbt when player dies?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.