From 570114be0e819600276dc45640aaa0bcd0d16b73 Mon Sep 17 00:00:00 2001 From: Technus Date: Tue, 7 Mar 2017 09:29:09 +0100 Subject: [PATCH] Fixing turbine switching off. --- .../multi/GT_MetaTileEntity_LargeTurbine.java | 17 +++++++++-------- .../GT_MetaTileEntity_LargeTurbine_Gas.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 4 ++-- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 10 ++++++---- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index a16d7652..b901f2dc 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -142,23 +142,22 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() * ((GT_MetaGenerated_Tool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed * 50)); + if(optFlow<=0 || baseEff<=0){ + stopMachine();//in case the turbine got removed + return false; + } } else { counter++; } } - if(optFlow<=0 || baseEff<=0){ - stopMachine();//in case the turbine got removed - return false; - } - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow int difference = newPower - this.mEUt; // difference between current output and new output // 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 - 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 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 this.mEUt = newPower; - if (mEUt <= 0) { - stopMachine(); + if (this.mEUt <= 0) { + //stopMachine(); + this.mEUt=0; + this.mEfficiency=0; return false; } else { this.mMaxProgresstime = 1; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 14ed9d8c..0b55b9cf 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -106,7 +106,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT totalFlow += flow; // track total input used } } - + if(totalFlow<=0)return 0; tEU = GT_Utility.safeInt((long)totalFlow * fuelValue); if (totalFlow != actualOptimalFlow) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index 9a5ef27a..b3137ad7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -96,10 +96,10 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); } } - + if(totalFlow<=0)return 0; tEU = totalFlow; addOutput(GT_ModHandler.getSteam(totalFlow)); - if (totalFlow > 0 && totalFlow != aOptFlow) { + if (totalFlow != aOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); //if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index 47edfa4d..84ab7cd3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -127,7 +127,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar addOutput(output); } } - + if(totalFlow<=0)return 0; tEU = GT_Utility.safeInt((long)((fuelValue / 20D) * (double)totalFlow)); //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) // 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 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 this.mEUt = newPower; - if (mEUt <= 0) { - stopMachine(); + if (this.mEUt <= 0) { + //stopMachine(); + this.mEUt=0; + this.mEfficiency=0; return false; } else { this.mMaxProgresstime = 20; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 38b5be83..9a5dbe76 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -106,11 +106,11 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); } } - + if(totalFlow<=0)return 0; tEU = totalFlow; int waterToOutput = useWater(totalFlow / 160.0f); addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); - if (totalFlow > 0 && totalFlow != aOptFlow) { + if (totalFlow != aOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); //if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency;