From e89e23f47ea8516b59c7fff33f646bad400fb0a3 Mon Sep 17 00:00:00 2001 From: HoleFish <1594248739@qq.com> Date: Mon, 5 Feb 2024 14:03:30 +0800 Subject: [PATCH] fix fuel search --- .../GregtechMTE_NuclearReactor.java | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java index 2c80d73a4..002989e30 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java @@ -323,27 +323,6 @@ public boolean turnCasingActive(final boolean status) { return true; } - public int getStoredFuel(GT_Recipe aRecipe) { - int aFuelStored = 0; - FluidStack aFuelFluid = null; - for (FluidStack aFluidInput : aRecipe.mFluidInputs) { - if (!aFluidInput.getFluid().equals(NUCLIDE.Li2BeF4.getFluid())) { - aFuelFluid = aFluidInput; - break; - } - } - if (aFuelFluid != null) { - for (GT_MetaTileEntity_Hatch_Input aInputHatch : this.mInputHatches) { - if (aInputHatch.getFluid() != null && aInputHatch.getFluidAmount() > 0) { - if (aInputHatch.getFluid().isFluidEqual(aFuelFluid)) { - aFuelStored += aInputHatch.getFluidAmount(); - } - } - } - } - return aFuelStored; - } - @Override protected ProcessingLogic createProcessingLogic() { return new ProcessingLogic() { @@ -367,15 +346,29 @@ public CheckRecipeResult process() { @NotNull @Override protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { - mFuelRemaining = getStoredFuel(recipe); + mFuelRemaining = 0; + int li2bef4 = 0; + FluidStack aFuelFluid = null; + for (FluidStack aFluidInput : recipe.mFluidInputs) { + if (!aFluidInput.getFluid().equals(NUCLIDE.Li2BeF4.getFluid())) { + aFuelFluid = aFluidInput; + break; + } + } + if (aFuelFluid != null) { + for (FluidStack fluidStack : getStoredFluids()) { + if (fluidStack.isFluidEqual(aFuelFluid)) { + mFuelRemaining += fluidStack.amount; + } else if (fluidStack.getFluid().equals(NUCLIDE.Li2BeF4.getFluid())) { + li2bef4 += fluidStack.amount; + } + } + } if (mFuelRemaining < 100) { return CheckRecipeResultRegistry.NO_FUEL_FOUND; } - for (GT_MetaTileEntity_Hatch_Input aInputHatch : mInputHatches) { - if (aInputHatch.getFluid().getFluid().equals(NUCLIDE.Li2BeF4.getFluid()) - && aInputHatch.getFluidAmount() < 200) { - return SimpleCheckRecipeResult.ofFailure("no_li2bef4"); - } + if (li2bef4 < 200) { + return SimpleCheckRecipeResult.ofFailure("no_li2bef4"); } return CheckRecipeResultRegistry.SUCCESSFUL; }