Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Let remainingFlow become 125% of realOptFlow, rather than raw optimal… (
Browse files Browse the repository at this point in the history
#841)

* Let remainingFlow become 125% of realOptFlow, rather than raw optimal flow.
This can fix the inconsistance between optimal flow in tooltip and that in turbine.

* criteria should be totalFlow != realOptFlow in HP Steam and Steam turbine

* fluidIntoPower should be long type, because ichorium huge turbine can generate power greater than Integer.MAX_VALUE on SC Turbine.

* Final change.

* 1 -> 1L

* revert the accidentally refactor in Plasma turbine

---------

Co-authored-by: yiteng.liu <yiteng.liu@11bee.com>
  • Loading branch information
koiNoCirculation and yiteng.liu authored Feb 28, 2024
1 parent b0ef9ce commit ece12a2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected boolean filtersFluid() {
}

@Override
int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
if (aFluids.size() >= 1) {
int tEU = 0;
int actualOptimalFlow = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected boolean filtersFluid() {
}

// How much the turbine should be producing with this flow
int newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers);
long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers);

// Reduce produced power depending on the ratio between fuel value and turbine EU/t with the following
// formula:
Expand Down Expand Up @@ -218,7 +218,7 @@ protected boolean filtersFluid() {
}

@Override
int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
if (aFluids.size() >= 1) {
aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks
int tEU = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ public int getFuelValue(FluidStack aLiquid) {
}

@Override
int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
int tEU = 0;
int totalFlow = 0; // Byproducts are based on actual flow
int flow = 0;
int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow.
// Variable required outside of loop for
// Variable required outside of loop for
// multi-hatch scenarios.
this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0];
this.realOptFlow = aOptFlow;
// this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0];
// Will there be an multiplier for SC?
int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to
// 125% of optimal flow.

storedFluid = 0;
FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1);
Expand All @@ -78,16 +81,16 @@ int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, f
if (totalFlow <= 0) return 0;
tEU = totalFlow;
addOutput(GT_ModHandler.getSteam(totalFlow));
if (totalFlow != aOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow);
if (totalFlow != realOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow);
// if(totalFlow>aOptFlow){efficiency = 1.0f;}
tEU *= efficiency;
tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L));
} else {
tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L);
}

return (int) Math.min(tEU * 100L, Integer.MAX_VALUE);
return tEU * 100L;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public int getFuelValue(FluidStack aLiquid) {
}

@Override
int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
if (looseFit) {
aOptFlow *= 4;
if (aBaseEff > 10000) {
Expand All @@ -77,13 +77,17 @@ int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, f
aBaseEff *= 0.75f;
}
}
int tEU = 0;
// prevent overflow like that in SC Steam
long tEU = 0;
int totalFlow = 0; // Byproducts are based on actual flow
int flow = 0;
int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow.
// Variable required outside of loop for

// Variable required outside of loop for
// multi-hatch scenarios.
this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0];
this.realOptFlow = aOptFlow * flowMultipliers[0];

int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to
// 125% of optimal flow.

storedFluid = 0;
for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) {
Expand Down Expand Up @@ -111,13 +115,13 @@ int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, f
if (totalFlow <= 0) return 0;
tEU = totalFlow;
addOutput(GT_ModHandler.getSteam(totalFlow));
if (totalFlow != aOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow);
if (totalFlow != realOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow);
// if(totalFlow>aOptFlow){efficiency = 1.0f;}
tEU *= efficiency;
tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L));
tEU = Math.max(1L, tEU * aBaseEff / 10000L);
} else {
tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L);
tEU = tEU * aBaseEff / 10000L;
}

return tEU;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public int getFuelValue(FluidStack aLiquid) {
}

@Override
int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
if (looseFit) {
aOptFlow *= 4;
if (aBaseEff > 10000) {
Expand All @@ -86,13 +86,19 @@ int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, f
aBaseEff *= 0.75f;
}
}
int tEU = 0;
// prevent overflow like that in SC Steam
long tEU = 0;
int totalFlow = 0; // Byproducts are based on actual flow
int flow = 0;
int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow.
// Variable required outside of loop for

// Variable required outside of loop for
// multi-hatch scenarios.
this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0];
this.realOptFlow = aOptFlow * flowMultipliers[0];

int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to
// use up to
// 125% of
// optimal flow.

storedFluid = 0;
for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and
Expand Down Expand Up @@ -120,13 +126,13 @@ int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, f
tEU = totalFlow;
int waterToOutput = useWater(totalFlow / 160.0f);
addOutput(GT_ModHandler.getDistilledWater(waterToOutput));
if (totalFlow != aOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow);
if (totalFlow != realOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow);
// if(totalFlow>aOptFlow){efficiency = 1.0f;}
tEU *= efficiency;
tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L));
tEU = Math.max(1L, tEU * aBaseEff / 20000L);
} else {
tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L);
tEU = tEU * aBaseEff / 20000L;
}

return tEU;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ protected void depleteTurbineFromStock(ItemStack aTurbine) {
}

// How much the turbine should be producing with this flow
int newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers);
long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers);
long difference = newPower - this.lEUt; // 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
Expand Down Expand Up @@ -553,7 +553,7 @@ public int getMaxParallelRecipes() {
return (getFullTurbineAssemblies().size());
}

abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers);
abstract long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers);

@Override
public int getDamageToComponent(ItemStack aStack) {
Expand Down

0 comments on commit ece12a2

Please sign in to comment.