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

Commit

Permalink
Fix crash with Nq Gen if coolant has just been depleted (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune authored Dec 12, 2023
1 parent a480037 commit fc36b70
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public boolean onRunningTick(ItemStack stack) {
// If there's no startRecipeProcessing, ME input hatch wouldn't work
startRecipeProcessing();
FluidStack[] input = getStoredFluids().toArray(new FluidStack[0]);
int eff = 100, time = 1;
int time = 1;
if (LiquidAirConsumptionPerSecond != 0
&& !consumeFuel(Materials.LiquidAir.getFluid(LiquidAirConsumptionPerSecond), input)) {
this.mEUt = 0;
Expand All @@ -255,7 +255,7 @@ public boolean onRunningTick(ItemStack stack) {
endRecipeProcessing();
return true;
}
if (getCoolant(input, true) != null) eff = getCoolant(input, false).getValue();
int eff = consumeCoolant(input);
if (consumeFuel(lockedFluid, input)) time = times;
this.mEUt = basicOutput * eff * time / 100;
this.trueEff = eff;
Expand Down Expand Up @@ -309,17 +309,23 @@ public Pair<FluidStack, Integer> getExcited(FluidStack[] input, boolean isConsum
return null;
}

public Pair<FluidStack, Integer> getCoolant(FluidStack[] input, boolean isConsume) {
/**
* Finds valid coolant from given inputs and consumes if found.
*
* @param input Fluid inputs.
* @return Efficiency of the coolant. 100 if not found.
*/
private int consumeCoolant(FluidStack[] input) {
for (Pair<FluidStack, Integer> fluidPair : coolant) {
FluidStack tFluid = fluidPair.getKey();
for (FluidStack inFluid : input) {
if (inFluid != null && inFluid.isFluidEqual(tFluid) && inFluid.amount >= tFluid.amount) {
if (isConsume) inFluid.amount -= tFluid.amount;
return fluidPair;
inFluid.amount -= tFluid.amount;
return fluidPair.getValue();
}
}
}
return null;
return 100;
}

public void addAutoEnergy(long outputPower) {
Expand Down

0 comments on commit fc36b70

Please sign in to comment.