Posted February 17, 201411 yr 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; } }
February 17, 201411 yr Author Wait exactly where do I put this. My item im trying to get the damage of hasn't been set to an ItemStack.
February 17, 201411 yr 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()
February 17, 201411 yr Think of it this way- STACKS get damaged & repaired, not items. so you want to add info to the stack inside AddInfo(), not the item of the class. http://i1149.photobucket.com/albums/o583/battleaxe333/mcMML-objBanner.png[/img]
February 17, 201411 yr 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.