Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Save data on death
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Babatunde

Save data on death

By Babatunde, January 9 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Babatunde    0

Babatunde

Babatunde    0

  • Tree Puncher
  • Babatunde
  • Members
  • 0
  • 15 posts
Posted January 9 (edited)

Hi Modders, 

 

I'm working on a mod where a player starts with 1 heart and every time they die they gain a heart until they have 10 hearts.

 

But I struggling with how I save the amount a hearts the player has. If I put it in the player data, it will be deleted when the player dies. Same goes for capabilities.

I've tried it with a Hashmap but I know its not the best way of doing thing so I'd like some feedback from you guys. 

 

Thanks.

 

EDIT: I'm using 1.15.2 and 1.14.4.

Edited January 9 by Babatunde
forgot version
  • Quote

Share this post


Link to post
Share on other sites

Babatunde    0

Babatunde

Babatunde    0

  • Tree Puncher
  • Babatunde
  • Members
  • 0
  • 15 posts
Posted January 9

Wrong category, sorry.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7614

diesieben07

diesieben07    7614

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7614
  • 55199 posts
Posted January 9

Capabilities are the way to go here. The documentation explains how to make it persist beyond player death: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/#persisting-across-player-deaths

  • Quote

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • AzizD
      [1.16.4] Custom item enchantability

      By AzizD · Posted 33 minutes ago

      I got it.
    • diesieben07
      [1.16.4] Custom item enchantability

      By diesieben07 · Posted 39 minutes ago

      Please don't use raw types. Store the Set in a field, don't create it every time.
    • AzizD
      [1.16.4] Custom item enchantability

      By AzizD · Posted 40 minutes ago

      It looks way better. Thanks for the advice. @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { Set e = ImmutableSet.of( Enchantments.SHARPNESS, Enchantments.LOOTING, Enchantments.FIRE_ASPECT, Enchantments.UNBREAKING, Enchantments.KNOCKBACK ); return e.contains(enchantment); }  
    • Nikibiki
      [1.16] Custom ItemGroup icon

      By Nikibiki · Posted 46 minutes ago

      I just want to say that this thread has been massively helpful to me! Thank you to all who have contributed.
    • diesieben07
      minecraft crashes as soon as I use shaders

      By diesieben07 · Posted 47 minutes ago

      That's the graphics driver
  • Topics

    • AzizD
      9
      [1.16.4] Custom item enchantability

      By AzizD
      Started 12 hours ago

    • JoieNL
      4
      [1.16] Custom ItemGroup icon

      By JoieNL
      Started September 25, 2020

    • JoehnMama
      4
      minecraft crashes as soon as I use shaders

      By JoehnMama
      Started 4 hours ago

    • MrDuck20
      1
      Error exit code 0 when i start the game.

      By MrDuck20
      Started 53 minutes ago

    • BBoi69
      1
      My modpack takes years to load

      By BBoi69
      Started 1 hour ago

  • Who's Online (See full list)

    • XDKara
    • starstorms21
    • AzizD
    • Nikibiki
    • Zemelua
    • diesieben07
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Save data on death
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community