Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combustion Engine Logic Fixes #2287

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.api.recipe.RecipeHelper;
import com.gregtechceu.gtceu.api.recipe.content.ContentModifier;
import com.gregtechceu.gtceu.api.recipe.logic.OCParams;
import com.gregtechceu.gtceu.api.recipe.logic.OCResult;
import com.gregtechceu.gtceu.common.data.GTMaterials;
Expand All @@ -33,7 +34,6 @@

import com.google.common.primitives.Ints;
import lombok.Getter;
import lombok.val;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

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

private static final FluidStack OXYGEN_STACK = GTMaterials.Oxygen.getFluid(20);
private static final FluidStack LIQUID_OXYGEN_STACK = GTMaterials.Oxygen.getFluid(FluidStorageKeys.LIQUID, 80);
private static final FluidStack OXYGEN_STACK = GTMaterials.Oxygen.getFluid(1);
private static final FluidStack LIQUID_OXYGEN_STACK = GTMaterials.Oxygen.getFluid(FluidStorageKeys.LIQUID, 4);
private static final FluidStack LUBRICANT_STACK = GTMaterials.Lubricant.getFluid(1);

@Getter
private final int tier;
// runtime
@DescSynced
private boolean isOxygenBoosted = false;
private int runningTimer = 0;

public LargeCombustionEngineMachine(IMachineBlockEntity holder, int tier) {
super(holder);
Expand Down Expand Up @@ -131,6 +132,14 @@ public static GTRecipe recipeModifier(MetaMachine machine, @NotNull GTRecipe rec
} else {
eut = EUt * parallelResult.getSecond();
}

recipe = new GTRecipe(recipe.recipeType, recipe.id,
recipe.copyContents(recipe.inputs, ContentModifier.multiplier(parallelResult.getSecond())),
recipe.copyContents(recipe.outputs, ContentModifier.multiplier(parallelResult.getSecond())),
recipe.tickInputs, recipe.tickOutputs, recipe.inputChanceLogics, recipe.outputChanceLogics,
recipe.tickInputChanceLogics, recipe.tickOutputChanceLogics, recipe.conditions,
recipe.ingredientActions, recipe.data, recipe.duration, recipe.isFuel, recipe.recipeCategory);

result.init(-eut, recipe.duration, 1, params.getOcAmount());
return recipe;
}
Expand All @@ -142,20 +151,24 @@ public static GTRecipe recipeModifier(MetaMachine machine, @NotNull GTRecipe rec
public boolean onWorking() {
boolean value = super.onWorking();
// check lubricant
val totalContinuousRunningTime = recipeLogic.getTotalContinuousRunningTime();
if ((totalContinuousRunningTime == 1 || totalContinuousRunningTime % 72 == 0)) {

if (runningTimer % 72 == 0) {
// insufficient lubricant
if (!getLubricantRecipe().handleRecipeIO(IO.IN, this, this.recipeLogic.getChanceCaches())) {
recipeLogic.interruptRecipe();
return false;
}
}
// check boost fluid
if ((totalContinuousRunningTime == 1 || totalContinuousRunningTime % 20 == 0) && isBoostAllowed()) {
if (isBoostAllowed()) {
var boosterRecipe = getBoostRecipe();
this.isOxygenBoosted = boosterRecipe.matchRecipe(this).isSuccess() &&
boosterRecipe.handleRecipeIO(IO.IN, this, this.recipeLogic.getChanceCaches());
}

runningTimer++;
if (runningTimer > 72000) runningTimer %= 72000; // reset once every hour of running

return value;
}

Expand Down
Loading