Skip to content

Commit

Permalink
Change exposed damage back to 0-100 because it'd break the Short.MAX_…
Browse files Browse the repository at this point in the history
…VALUE limit easily
  • Loading branch information
bonii-xx committed Sep 20, 2014
1 parent dd4f53f commit a0c0358
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/main/java/tconstruct/library/tools/ToolCore.java
Expand Up @@ -738,18 +738,7 @@ public boolean showDurabilityBar(ItemStack stack) {
@Override
public int getMaxDamage (ItemStack stack)
{
NBTTagCompound tags = stack.getTagCompound();
if (tags == null)
{
return 0;
}
if (tags.hasKey("Energy"))
{
int energy = tags.getInteger("Energy");
if (energy > 0)
return this.getMaxEnergyStored(stack);
}
return tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
return 100;
}

@Override
Expand All @@ -762,10 +751,20 @@ public int getDamage(ItemStack stack) {
if (tags.hasKey("Energy"))
{
int energy = tags.getInteger("Energy");
int max = getMaxEnergyStored(stack);
if(energy > 0)
return getMaxEnergyStored(stack) - energy;
return ((max - energy)*100)/max;
}
return tags.getCompoundTag("InfiTool").getInteger("Damage");
int dur = tags.getCompoundTag("InfiTool").getInteger("Damage");
int max = tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
int damage = (dur*100)/max;

if(damage == 0 && dur > 0)
return 1;
if(max > 0)
return damage;
else
return 0;
}

@Override
Expand Down

0 comments on commit a0c0358

Please sign in to comment.