Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by izako
wrote the version

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).

  • 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

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.