Skip to content

Commit

Permalink
Try syncing internal itemstack damage with the damage from the tool
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Oct 7, 2014
1 parent 9cb2e27 commit 5feb11f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/tconstruct/library/tools/ToolCore.java
Expand Up @@ -788,8 +788,11 @@ public int getDamage(ItemStack stack) {
{
int energy = tags.getInteger("Energy");
int max = getMaxEnergyStored(stack);
if(energy > 0)
return ((max - energy)*100)/max;
if(energy > 0) {
int damage = ((max - energy) * 100) / max;
super.setDamage(stack, damage);
return damage;
}
}
int dur = tags.getCompoundTag("InfiTool").getInteger("Damage");
int max = tags.getCompoundTag("InfiTool").getInteger("TotalDurability");
Expand All @@ -799,8 +802,11 @@ public int getDamage(ItemStack stack) {

// rounding.
if(damage == 0 && dur > 0)
return 1;
damage = 1;


// synchronize values with stack..
super.setDamage(stack, damage);
return damage;
}

Expand All @@ -813,6 +819,7 @@ public int getDisplayDamage(ItemStack stack) {
@Override
public void setDamage(ItemStack stack, int damage) {
AbilityHelper.damageTool(stack, damage - stack.getItemDamage(), null, false);
getDamage(stack); // called to synchronize with itemstack value
}

/* Prevent tools from dying */
Expand Down

0 comments on commit 5feb11f

Please sign in to comment.