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

The idea is I have a battery and I want the tool tip to say "Power Left: " and then how much power the battery has in it at the moment it is registered with a max power of 10000 (using metadata) but I'm unsure on how to get the current damage value to add to the end of the string.

 

 

This is the battery class the damage and id are registered in the main class

public class CarbonBattery extends Item {
private final String setInfo;
private final String setColor;


public CarbonBattery(int id, int maxPower) {
	super(id);

	this.setMaxDamage(maxPower);
	this.setInfo = "Power Left: ";
	this.setColor = "\u00A75";

}

public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean bool){
	list.add(setToolTipData());
}

private String setToolTipData(){
	return this.setColor + this.setInfo;
}

}

  • Author

I thought it would be part of the this.setInfo because that is what gets put into the list. I found this code here on the forums for the addInformation and understand all but the ItemStack and boolean, but I'm assuming the boolean is for if you want to do something like isDamaged()

  • Author

No. I really don't know what I'm doing. Why I'm here trying to learn, as well as looking for every tutorial I can to figure out how it works. Thanks for the help I don't intend to seem like and Idiot. I used the example you gave me to make it how I wanted.

public CarbonBattery(int id, int maxPower) {
	super(id);

	this.setMaxDamage(maxPower);
}

public void addInformation(ItemStack stack, EntityPlayer entityplayer, List list, boolean extendedToolTips){
	list.add("Power Left: " + (this.getMaxDamage() - stack.getItemDamage()) + "/" + this.getMaxDamage());
}


}

 

So now it will display "Power Left: 1000/1000" and will count down.

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.