Skip to content

Commit

Permalink
Fixed multiple repairs being more effective than a single repair with…
Browse files Browse the repository at this point in the history
… the same amount of materials

Fixes #584
  • Loading branch information
squeek502 committed Jul 7, 2014
1 parent 4fce1a9 commit 443757c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/tconstruct/modifiers/tools/ModRepair.java
Expand Up @@ -64,18 +64,18 @@ private boolean calculateIfNecessary (ItemStack tool, ItemStack[] input)
if (numInputs == 0)
return false;

int totalRepairValue = calculateIncrease(tool, materialValue);
int totalRepairValue = calculateIncrease(tool, materialValue, numInputs);
float averageRepairValue = totalRepairValue / numInputs;

return numInputs == 1 || (damage - totalRepairValue >= -averageRepairValue);
}

private int calculateIncrease (ItemStack tool, int materialValue)
private int calculateIncrease (ItemStack tool, int materialValue, int itemsUsed)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int damage = tags.getInteger("Damage");
int dur = tags.getInteger("BaseDurability");
int increase = (int) (50 + (dur * 0.4f * materialValue));
int increase = (int) (50 * itemsUsed + (dur * 0.4f * materialValue));

int modifiers = tags.getInteger("Modifiers");
float mods = 1.0f;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void modify (ItemStack[] input, ItemStack tool)
}
}

int increase = calculateIncrease(tool, materialValue);
int increase = calculateIncrease(tool, materialValue, itemsUsed);
int repair = tags.getInteger("RepairCount");
repair += itemsUsed;
tags.setInteger("RepairCount", repair);
Expand Down

0 comments on commit 443757c

Please sign in to comment.