Unify tool speed calculation in one accessible place, instead of having the same code floating around 3 times.

This commit is contained in:
Bernhard Bonigl committed 2014-08-28 14:29:12 +02:00
1 parent 7ca3acad88
commit 2dd426f1d7
4 files changed
+52 -89

No files matched your search

@@ -141,38 +141,14 @@ public abstract class HarvestTool extends ToolCore
public float calculateStrength (NBTTagCompound tags, Block block, int meta)
{
float mineSpeed = tags.getInteger("MiningSpeed");
int heads = 1;
if (tags.hasKey("MiningSpeed2"))
{
mineSpeed += tags.getInteger("MiningSpeed2");
heads++;
}
if (tags.hasKey("MiningSpeedHandle"))
{
mineSpeed += tags.getInteger("MiningSpeedHandle");
heads++;
}
if (tags.hasKey("MiningSpeedExtra"))
{
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 100f) * breakSpeedModifier();
int hlvl = block.getHarvestLevel(meta);
int durability = tags.getInteger("Damage");
if (hlvl > tags.getInteger("HarvestLevel"))
return 0.1f;
float stonebound = tags.getFloat("Shoddy");
float bonusLog = (float) Math.log(durability / stoneboundModifier() + 1) * 2 * stonebound;
trueSpeed += bonusLog;
if (hlvl <= tags.getInteger("HarvestLevel"))
return trueSpeed;
return 0.1f;
return AbilityHelper.calcToolSpeed(this, tags);
}
public float breakSpeedModifier()
{
return 1.0f;