Merge pull request #2910 from hacker-on-steroids/turbines

attempted turbine efficiency fix
This commit is contained in:
HbmMods 2026-05-11 18:39:23 +02:00 committed by GitHub
commit a459e274f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,9 +39,11 @@ public class TileEntityMachineIndustrialTurbine extends TileEntityTurbineBase im
public float lastRotor; public float lastRotor;
public double spin = 0; public double spin = 0;
public static double ACCELERATION = 1D / 400D; public static double FLYWHEEL_MAX_ENERGY = 0.5e8; //aka flywheel mass
public long maxPower = 0;
public long lastPowerTarget = 0; public long lastPowerTarget = 0;
public long flywheel_energy = 0;
private AudioWrapper audio; private AudioWrapper audio;
private float audioDesync; private float audioDesync;
@ -59,7 +61,7 @@ public class TileEntityMachineIndustrialTurbine extends TileEntityTurbineBase im
@Override @Override
public void writeConfig(JsonWriter writer) throws IOException { public void writeConfig(JsonWriter writer) throws IOException {
writer.name("INFO").value("industrial steam turbine consumes 20% of availible steam per tick"); writer.name("INFO").value("industrial steam turbine consumes 20% of available steam per tick");
writer.name("I:inputTankSize").value(inputTankSize); writer.name("I:inputTankSize").value(inputTankSize);
writer.name("I:outputTankSize").value(outputTankSize); writer.name("I:outputTankSize").value(outputTankSize);
writer.name("D:efficiency").value(efficiency); writer.name("D:efficiency").value(efficiency);
@ -80,29 +82,17 @@ public class TileEntityMachineIndustrialTurbine extends TileEntityTurbineBase im
FT_Coolable trait = tanks[0].getTankType().getTrait(FT_Coolable.class); FT_Coolable trait = tanks[0].getTankType().getTrait(FT_Coolable.class);
double eff = trait.getEfficiency(CoolingType.TURBINE) * getEfficiency(); double eff = trait.getEfficiency(CoolingType.TURBINE) * getEfficiency();
int maxOps = (int) Math.ceil((tanks[0].getMaxFill() * consumptionPercent()) / trait.amountReq); int maxOps = (int) Math.ceil((tanks[0].getMaxFill() * consumptionPercent()) / trait.amountReq);
this.lastPowerTarget = (long) (maxOps * trait.heatEnergy * eff); // theoretical max output at full blast with this type this.maxPower = (long) (maxOps * trait.heatEnergy * eff);
double fraction = (double) steamConsumed / (double) (trait.amountReq * maxOps); // % of max steam throughput currently achieved
if(Math.abs(spin - fraction) <= ACCELERATION) { this.flywheel_energy += power;
this.spin = fraction;
} else if(spin < fraction) {
this.spin += ACCELERATION;
} else if(spin > fraction) {
this.spin -= ACCELERATION;
}
} }
@Override @Override
public void onServerTick() { public void onServerTick() {
if(!operational) { this.spin = (double) flywheel_energy / FLYWHEEL_MAX_ENERGY; //because dense steams have way lower energy output, turbines running them take a lot longer to spool up
this.spin -= ACCELERATION; this.lastPowerTarget = (long) (this.spin * maxPower);
} this.flywheel_energy -= this.lastPowerTarget;
this.powerBuffer = (long) (this.lastPowerTarget);
if(this.spin <= 0) {
this.spin = 0;
} else {
this.powerBuffer = (long) (this.lastPowerTarget * this.spin);
}
} }
@Override @Override