Fixing turbine switching off.

This commit is contained in:
Technus 2017-03-07 09:29:09 +01:00
parent 28d13b27b3
commit 570114be0e
5 changed files with 20 additions and 17 deletions

View file

@ -142,15 +142,14 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M
((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier()
* ((GT_MetaGenerated_Tool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed * ((GT_MetaGenerated_Tool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed
* 50)); * 50));
} else {
counter++;
}
}
if(optFlow<=0 || baseEff<=0){ if(optFlow<=0 || baseEff<=0){
stopMachine();//in case the turbine got removed stopMachine();//in case the turbine got removed
return false; return false;
} }
} else {
counter++;
}
}
int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow
@ -158,7 +157,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M
// Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick)
// This is how much the turbine can actually change during this tick // This is how much the turbine can actually change during this tick
int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long)Math.ceil(Math.abs(difference) * 0.01))); int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long)Math.abs(difference)/100));
if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change
int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative.
@ -166,8 +165,10 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M
} else } else
this.mEUt = newPower; this.mEUt = newPower;
if (mEUt <= 0) { if (this.mEUt <= 0) {
stopMachine(); //stopMachine();
this.mEUt=0;
this.mEfficiency=0;
return false; return false;
} else { } else {
this.mMaxProgresstime = 1; this.mMaxProgresstime = 1;

View file

@ -106,7 +106,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT
totalFlow += flow; // track total input used totalFlow += flow; // track total input used
} }
} }
if(totalFlow<=0)return 0;
tEU = GT_Utility.safeInt((long)totalFlow * fuelValue); tEU = GT_Utility.safeInt((long)totalFlow * fuelValue);
if (totalFlow != actualOptimalFlow) { if (totalFlow != actualOptimalFlow) {

View file

@ -96,10 +96,10 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La
depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount));
} }
} }
if(totalFlow<=0)return 0;
tEU = totalFlow; tEU = totalFlow;
addOutput(GT_ModHandler.getSteam(totalFlow)); addOutput(GT_ModHandler.getSteam(totalFlow));
if (totalFlow > 0 && totalFlow != aOptFlow) { if (totalFlow != aOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow);
//if(totalFlow>aOptFlow){efficiency = 1.0f;} //if(totalFlow>aOptFlow){efficiency = 1.0f;}
tEU *= efficiency; tEU *= efficiency;

View file

@ -127,7 +127,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar
addOutput(output); addOutput(output);
} }
} }
if(totalFlow<=0)return 0;
tEU = GT_Utility.safeInt((long)((fuelValue / 20D) * (double)totalFlow)); tEU = GT_Utility.safeInt((long)((fuelValue / 20D) * (double)totalFlow));
//System.out.println(totalFlow+" : "+fuelValue+" : "+aOptFlow+" : "+actualOptimalFlow+" : "+tEU); //System.out.println(totalFlow+" : "+fuelValue+" : "+aOptFlow+" : "+actualOptimalFlow+" : "+tEU);
@ -181,7 +181,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar
// Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick)
// This is how much the turbine can actually change during this tick // This is how much the turbine can actually change during this tick
int maxChangeAllowed = Math.max(200, GT_Utility.safeInt((long)Math.ceil(Math.abs(difference) * 0.2))); int maxChangeAllowed = Math.max(200, GT_Utility.safeInt((long)Math.abs(difference)/5));
if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change
int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative.
@ -189,8 +189,10 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar
} else } else
this.mEUt = newPower; this.mEUt = newPower;
if (mEUt <= 0) { if (this.mEUt <= 0) {
stopMachine(); //stopMachine();
this.mEUt=0;
this.mEfficiency=0;
return false; return false;
} else { } else {
this.mMaxProgresstime = 20; this.mMaxProgresstime = 20;

View file

@ -106,11 +106,11 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg
depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount));
} }
} }
if(totalFlow<=0)return 0;
tEU = totalFlow; tEU = totalFlow;
int waterToOutput = useWater(totalFlow / 160.0f); int waterToOutput = useWater(totalFlow / 160.0f);
addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); addOutput(GT_ModHandler.getDistilledWater(waterToOutput));
if (totalFlow > 0 && totalFlow != aOptFlow) { if (totalFlow != aOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow);
//if(totalFlow>aOptFlow){efficiency = 1.0f;} //if(totalFlow>aOptFlow){efficiency = 1.0f;}
tEU *= efficiency; tEU *= efficiency;