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

I have a NBT tag called "ConsumedAmount" on an item. Got everything about it working very well, but as a sort of 'final touch', I want to add a durability bar. However, this durability bar should use the ConsumedAmount. So if it's 0/there is no tag compound/ConsumedAmount key then it won't display, 1 then it'll be super low, all the way up to 32 which would be full.

 

Is there any way I can accomplish this? I've noticed that a mod like EnderIO has a 'durability bar' that uses RF instead of actual durability (I've only seen this for the Staff of Travelling so far, though). I don't exactly want the custom gradient that it uses, but just something like that.

 

 

As a completely optional question (and I hope this isn't too complex...), is it possible to change the bar's color at a certain value? Not gradually change it overtime like vanilla's, but literally change the entire color. So green to gray, gray to gold, etc. etc..

Yes, all of that is possible!

  • Item#showDurabilityBar checks whether the bar should display (you probably just want to override it to return true).
  • Item#getDurabilityForDisplay defines how much of the bar should be full (as a double between 0 and 1) - this is where you can read your custom NBT and convert it into the proportion of the bar to fill.
  • Item#getRGBDurabilityForDisplay defines the colour of the filled part of the bar (as an int representing an RGB hex colour) - this is where you can set the colour according to your custom NBT.
  • Author
20 minutes ago, Jay Avery said:

Yes, all of that is possible!

  • Item#showDurabilityBar checks whether the bar should display (you probably just want to override it to return true).
  • Item#getDurabilityForDisplay defines how much of the bar should be full (as a double between 0 and 1) - this is where you can read your custom NBT and convert it into the proportion of the bar to fill.
  • Item#getRGBDurabilityForDisplay defines the colour of the filled part of the bar (as an int representing an RGB hex colour) - this is where you can set the colour according to your custom NBT.

Thank you so much! That basically answers 99% of my question!

 

The remaining question is, how should I format RGB hex colors? Just like usual, as in #FF0000?

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.