Fix secondary energy consumption with speed upgrades.

Might make them less efficient with speed upgrades and add a secondary
energy upgrade that mitigates this, like the current energy upgrade.
This commit is contained in:
Ben Spiers 2014-08-27 02:17:45 +01:00
parent 6714034771
commit 40c06f1004
3 changed files with 14 additions and 3 deletions

View file

@ -96,7 +96,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
boolean changed = false;
if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(this, ENERGY_PER_TICK) && gasTank.getStored() >= SECONDARY_ENERGY_PER_TICK)
if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(this, ENERGY_PER_TICK) && gasTank.getStored() >= (int)MekanismUtils.getSecondaryEnergyPerTick(this, SECONDARY_ENERGY_PER_TICK))
{
setActive(true);
@ -109,7 +109,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
operatingTicks = 0;
}
gasTank.draw(SECONDARY_ENERGY_PER_TICK, true);
gasTank.draw(MekanismUtils.getSecondaryEnergyPerTick(this, SECONDARY_ENERGY_PER_TICK), true);
electricityStored -= MekanismUtils.getEnergyPerTick(this, ENERGY_PER_TICK);
}
else {

View file

@ -348,7 +348,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
public int getSecondaryEnergyPerTick()
{
return RecipeType.values()[recipeType].getSecondaryEnergyPerTick();
return MekanismUtils.getSecondaryEnergyPerTick(this, RecipeType.values()[recipeType].getSecondaryEnergyPerTick());
}
public void handleSecondaryFuel()

View file

@ -620,6 +620,17 @@ public final class MekanismUtils
return def * Math.pow(Mekanism.maxUpgradeMultiplier, (2*mgmt.getSpeedMultiplier()-mgmt.getEnergyMultiplier())/8.0);
}
/**
* Gets the secondary energy required per tick for a machine via upgrades.
* @param mgmt - tile containing upgrades
* @param def - the original, default secondary energy required
* @return max secondary energy per tick
*/
public static int getSecondaryEnergyPerTick(IUpgradeTile mgmt, int def)
{
return def * (int)Math.pow(general.maxUpgradeMultiplier, mgmt.getComponent().getUpgrades(Upgrade.SPEED)/(float)Upgrade.SPEED.getMax());
}
/**
* Gets the maximum energy for a machine via it's upgrades.
* @param energyUpgrade - number of energy upgrades