fix CCGT allowing throttle over max when using OpenComputers callbacks

This commit is contained in:
PewPewCricket 2025-07-17 14:46:57 -05:00
parent 5fb88801ec
commit 8686a64141

View File

@ -105,11 +105,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
tanks[0].setTankType(fluid);
}
}
if(autoMode) { //power production depending on power requirement and fuel level
int powerSliderTarget;
//when low on fuel, decrease consumption linearly
if(tanks[0].getFill() * 10 > tanks[0].getMaxFill()) {
powerSliderTarget = 60 - (int) (60 * power / maxPower); //scales the slider proportionally to the power gauge
@ -117,7 +117,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
else {
powerSliderTarget = (int) ( tanks[0].getFill() * 0.0001 * (60 - (int) (60 * power / maxPower)) );
}
if(powerSliderTarget > powerSliderPos) { //makes the auto slider slide instead of snapping into position
powerSliderPos++;
}
@ -403,12 +403,12 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
double waterPerTick = (consMax * energy * (temp - tempIdle) / 220000); //it just works fuck you
this.waterToBoil = waterPerTick; //caching in a field for the EC compat to use
int heatCycles = (int) Math.floor(waterToBoil);
int waterCycles = tanks[2].getFill();
int steamCycles = (tanks[3].getMaxFill() - tanks[3].getFill()) / 10;
int cycles = BobMathUtil.min(heatCycles, waterCycles, steamCycles);
tanks[2].setFill(tanks[2].getFill() - cycles);
tanks[3].setFill(tanks[3].getFill() + cycles * 10);
}
@ -619,8 +619,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] setThrottle(Context context, Arguments args) {
powerSliderPos = (int) (args.checkInteger(0) * 60D / 100D);
return new Object[] {};
double input = args.checkInteger(0) * 60D / 100D;
if (input < 0 || input > 100)
return new Object[] {null, "Input out of range."};
powerSliderPos = (int) (input);
return new Object[] {true};
}
@Callback(direct = true, limit = 4)