Jump to content

Capability values get reset?(1.12.2)


Recommended Posts

So I'm trying to add stats to my mod using a mixture of capabilities to save the values and events to set attribute modifiers, but I'm having this universal problem with all my stats where when i exit out the game and re enter the capability value gets reset.
this is one of the events that i use for stats ^

in it the value healthStatCap gets reset when i exit mc and re enter, I think it has something to do with my capabilities so im going to put my capability code here too >

here is  the capability interface, capability implementation, the provider, and the IStorage class


Edited by izako
wrote the version
Link to comment
Share on other sites

1 hour ago, Meldexun said:

The healthStatCap variable in your HealthStat event is always 0 at the beginning. When your event gets called the first time it sets the value of healthStat from your capability to healthStatCap + 1 (0 + 1 = 1).

I didn't think that would make it reset, its weird I didn't think of that tbh but thanks it works now

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

How would it not reset? It's just a field in a class. When you create an instance of the class it will be set to the initial value: 0. I am not sure what this is trying to achieve, but you cannot share data like this. Your event class exists once there is one value for these fields for all players.

i have reset the value to get the capability of the player which is initially 0, would that work? I haven't tried it online yet

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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 Terms of Use.