Skip to content

Instantly share code, notes, and snippets.

@mDiyo
Created March 9, 2013 21:59
Show Gist options
  • Select an option

  • Save mDiyo/5125931 to your computer and use it in GitHub Desktop.

Select an option

Save mDiyo/5125931 to your computer and use it in GitHub Desktop.
Colored tooltip
/* Tags and information about the tool */
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (!stack.hasTagCompound())
return;
NBTTagCompound tags = stack.getTagCompound();
if (tags.hasKey("charge"))
{
String color = "";
int power = tags.getInteger("charge");
if (power != 0)
{
if (power <= this.getMaxCharge() / 3)
color = "\u00a74";
else if (power > this.getMaxCharge() * 2 / 3)
color = "\u00a72";
else
color = "\u00a76";
}
String charge = new StringBuilder().append(color).append(tags.getInteger("charge")).append("/").append(getMaxCharge()).append(" En").toString();
list.add(charge);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment