Add a cooling buffer, fix #2530
Now no coolant is lost due to rounding, and coolants that are too strong will not cause engines to blow up before even being used.
This commit is contained in:
parent
dda34827c8
commit
f99777f903
1 changed files with 18 additions and 12 deletions
|
@ -48,6 +48,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
||||||
public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
|
public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
|
||||||
|
|
||||||
private int burnTime = 0;
|
private int burnTime = 0;
|
||||||
|
private float coolingBuffer = 0.0f;
|
||||||
|
|
||||||
private TankManager<Tank> tankManager = new TankManager<Tank>();
|
private TankManager<Tank> tankManager = new TankManager<Tank>();
|
||||||
private IFuel currentFuel;
|
private IFuel currentFuel;
|
||||||
|
@ -246,6 +247,21 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
||||||
private void coolEngine(float idealHeat) {
|
private void coolEngine(float idealHeat) {
|
||||||
float extraHeat = heat - idealHeat;
|
float extraHeat = heat - idealHeat;
|
||||||
|
|
||||||
|
if (coolingBuffer < extraHeat) {
|
||||||
|
fillCoolingBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coolingBuffer >= extraHeat) {
|
||||||
|
coolingBuffer -= extraHeat;
|
||||||
|
heat -= extraHeat;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
heat -= coolingBuffer;
|
||||||
|
coolingBuffer = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillCoolingBuffer() {
|
||||||
FluidStack coolant = this.tankCoolant.getFluid();
|
FluidStack coolant = this.tankCoolant.getFluid();
|
||||||
if (coolant == null) {
|
if (coolant == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -256,18 +272,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
||||||
if (currentCoolant != null) {
|
if (currentCoolant != null) {
|
||||||
float cooling = currentCoolant.getDegreesCoolingPerMB(heat);
|
float cooling = currentCoolant.getDegreesCoolingPerMB(heat);
|
||||||
cooling /= getBiomeTempScalar();
|
cooling /= getBiomeTempScalar();
|
||||||
|
coolingBuffer += coolantAmount * cooling;
|
||||||
if (cooling > extraHeat) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (coolantAmount * cooling > extraHeat) {
|
|
||||||
tankCoolant.drain(Math.round(extraHeat / cooling), true);
|
|
||||||
heat -= extraHeat;
|
|
||||||
} else {
|
|
||||||
tankCoolant.drain(coolantAmount, true);
|
tankCoolant.drain(coolantAmount, true);
|
||||||
heat -= coolantAmount * cooling;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue