Posted July 10, 20196 yr 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.https://github.com/izako666/HunterX_Public_2/blob/master/main/java/com/izako/HunterX/stats/events/HealthStatEvent.java 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 >https://github.com/izako666/HunterX_Public_2/tree/master/main/java/com/izako/HunterX/stats/capabilities here is the capability interface, capability implementation, the provider, and the IStorage class Edited July 10, 20196 yr by izako wrote the version
July 10, 20196 yr 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).
July 10, 20196 yr Author 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
July 11, 20196 yr Author 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
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.