Skip to content

Commit c74f36d

Browse files
authored
Combustion Engine Logic Fixes (GregTechCEu#2287)
1 parent 7d7bf54 commit c74f36d

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeCombustionEngineMachine.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine;
1515
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
1616
import com.gregtechceu.gtceu.api.recipe.RecipeHelper;
17+
import com.gregtechceu.gtceu.api.recipe.content.ContentModifier;
1718
import com.gregtechceu.gtceu.api.recipe.logic.OCParams;
1819
import com.gregtechceu.gtceu.api.recipe.logic.OCResult;
1920
import com.gregtechceu.gtceu.common.data.GTMaterials;
@@ -33,7 +34,6 @@
3334

3435
import com.google.common.primitives.Ints;
3536
import lombok.Getter;
36-
import lombok.val;
3737
import org.jetbrains.annotations.NotNull;
3838
import org.jetbrains.annotations.Nullable;
3939

@@ -54,15 +54,16 @@ public class LargeCombustionEngineMachine extends WorkableElectricMultiblockMach
5454
protected static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(
5555
LargeCombustionEngineMachine.class, WorkableMultiblockMachine.MANAGED_FIELD_HOLDER);
5656

57-
private static final FluidStack OXYGEN_STACK = GTMaterials.Oxygen.getFluid(20);
58-
private static final FluidStack LIQUID_OXYGEN_STACK = GTMaterials.Oxygen.getFluid(FluidStorageKeys.LIQUID, 80);
57+
private static final FluidStack OXYGEN_STACK = GTMaterials.Oxygen.getFluid(1);
58+
private static final FluidStack LIQUID_OXYGEN_STACK = GTMaterials.Oxygen.getFluid(FluidStorageKeys.LIQUID, 4);
5959
private static final FluidStack LUBRICANT_STACK = GTMaterials.Lubricant.getFluid(1);
6060

6161
@Getter
6262
private final int tier;
6363
// runtime
6464
@DescSynced
6565
private boolean isOxygenBoosted = false;
66+
private int runningTimer = 0;
6667

6768
public LargeCombustionEngineMachine(IMachineBlockEntity holder, int tier) {
6869
super(holder);
@@ -131,6 +132,14 @@ public static GTRecipe recipeModifier(MetaMachine machine, @NotNull GTRecipe rec
131132
} else {
132133
eut = EUt * parallelResult.getSecond();
133134
}
135+
136+
recipe = new GTRecipe(recipe.recipeType, recipe.id,
137+
recipe.copyContents(recipe.inputs, ContentModifier.multiplier(parallelResult.getSecond())),
138+
recipe.copyContents(recipe.outputs, ContentModifier.multiplier(parallelResult.getSecond())),
139+
recipe.tickInputs, recipe.tickOutputs, recipe.inputChanceLogics, recipe.outputChanceLogics,
140+
recipe.tickInputChanceLogics, recipe.tickOutputChanceLogics, recipe.conditions,
141+
recipe.ingredientActions, recipe.data, recipe.duration, recipe.isFuel, recipe.recipeCategory);
142+
134143
result.init(-eut, recipe.duration, 1, params.getOcAmount());
135144
return recipe;
136145
}
@@ -142,20 +151,24 @@ public static GTRecipe recipeModifier(MetaMachine machine, @NotNull GTRecipe rec
142151
public boolean onWorking() {
143152
boolean value = super.onWorking();
144153
// check lubricant
145-
val totalContinuousRunningTime = recipeLogic.getTotalContinuousRunningTime();
146-
if ((totalContinuousRunningTime == 1 || totalContinuousRunningTime % 72 == 0)) {
154+
155+
if (runningTimer % 72 == 0) {
147156
// insufficient lubricant
148157
if (!getLubricantRecipe().handleRecipeIO(IO.IN, this, this.recipeLogic.getChanceCaches())) {
149158
recipeLogic.interruptRecipe();
150159
return false;
151160
}
152161
}
153162
// check boost fluid
154-
if ((totalContinuousRunningTime == 1 || totalContinuousRunningTime % 20 == 0) && isBoostAllowed()) {
163+
if (isBoostAllowed()) {
155164
var boosterRecipe = getBoostRecipe();
156165
this.isOxygenBoosted = boosterRecipe.matchRecipe(this).isSuccess() &&
157166
boosterRecipe.handleRecipeIO(IO.IN, this, this.recipeLogic.getChanceCaches());
158167
}
168+
169+
runningTimer++;
170+
if (runningTimer > 72000) runningTimer %= 72000; // reset once every hour of running
171+
159172
return value;
160173
}
161174

0 commit comments

Comments
 (0)