diff --git a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java index 67405dade3f..cc2ce878aee 100644 --- a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.function.Predicate; import static gregtech.api.GTValues.ULV; import static gregtech.api.recipes.logic.OverclockingLogic.*; @@ -513,26 +512,12 @@ protected static int getMinTankCapacity(@NotNull IMultipleTankHandler tanks) { */ @Nullable protected Recipe findRecipe(long maxVoltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs) { - return this.findRecipe(maxVoltage, inputs, fluidInputs, null); - } - - /** - * Find a recipe using inputs - * - * @param maxVoltage the maximum voltage the recipe can have - * @param inputs the item inputs used to search for the recipe - * @param fluidInputs the fluid inputs used to search for the recipe - * @param extraPredicate an optional extra predicate to apply when searching - * @return the recipe if found, otherwise null - */ - @Nullable - protected Recipe findRecipe(long maxVoltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs, Predicate extraPredicate) { RecipeMap map = getRecipeMap(); if (map == null || !isRecipeMapValid(map)) { return null; } - return map.findRecipe(maxVoltage, inputs, fluidInputs, extraPredicate); + return map.findRecipe(maxVoltage, inputs, fluidInputs); } /** diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index 319ecf4b372..2f9417afe27 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -507,17 +507,7 @@ protected ValidationResult postValidateRecipe(@NotNull ValidationResult< @Nullable public Recipe findRecipe(long voltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs) { - return this.findRecipe(voltage, GTUtility.itemHandlerToList(inputs), GTUtility.fluidHandlerToList(fluidInputs), null); - } - - @Nullable - public Recipe findRecipe(long voltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs, Predicate extraPredicate) { - return this.findRecipe(voltage, GTUtility.itemHandlerToList(inputs), GTUtility.fluidHandlerToList(fluidInputs), extraPredicate); - } - - @Nullable - public Recipe findRecipe(long voltage, List inputs, List fluidInputs, Predicate extraPredicate) { - return findRecipe(voltage, inputs, fluidInputs, false, extraPredicate); + return this.findRecipe(voltage, GTUtility.itemHandlerToList(inputs), GTUtility.fluidHandlerToList(fluidInputs)); } /** @@ -530,7 +520,7 @@ public Recipe findRecipe(long voltage, List inputs, List */ @Nullable public Recipe findRecipe(long voltage, List inputs, List fluidInputs) { - return findRecipe(voltage, inputs, fluidInputs, false, null); + return findRecipe(voltage, inputs, fluidInputs, false); } /** @@ -545,22 +535,6 @@ public Recipe findRecipe(long voltage, List inputs, List @Nullable public Recipe findRecipe(long voltage, final List inputs, final List fluidInputs, boolean exactVoltage) { - return findRecipe(voltage, inputs, fluidInputs, exactVoltage, null); - } - - /** - * Finds a Recipe matching the Fluid and/or ItemStack Inputs. - * - * @param voltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage - * @param inputs the Item Inputs - * @param fluidInputs the Fluid Inputs - * @param exactVoltage should require exact voltage matching on recipe. used by craftweaker - * @param extraPredicate optional extra filter predicate - * @return the Recipe it has found or null for no matching Recipe - */ - @Nullable - public Recipe findRecipe(long voltage, final List inputs, final List fluidInputs, - boolean exactVoltage, Predicate extraPredicate) { final List items = inputs.stream().filter(s -> !s.isEmpty()).collect(Collectors.toList()); final List fluids = fluidInputs.stream().filter(f -> f != null && f.amount != 0) .collect(Collectors.toList()); @@ -574,7 +548,7 @@ public Recipe findRecipe(long voltage, final List inputs, final List< // there is not enough voltage to consider the recipe valid return false; } - return recipe.matches(false, inputs, fluidInputs) && (extraPredicate == null || extraPredicate.test(recipe)); + return recipe.matches(false, inputs, fluidInputs); }); } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/LargeTurbineWorkableHandler.java b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/LargeTurbineWorkableHandler.java index 4ad96f9550e..a260542061c 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/LargeTurbineWorkableHandler.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/LargeTurbineWorkableHandler.java @@ -10,6 +10,11 @@ import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeBuilder; +import gregtech.api.recipes.RecipeMap; + +import gregtech.api.util.GTUtility; + +import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; @@ -19,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.stream.Collectors; public class LargeTurbineWorkableHandler extends MultiblockFuelRecipeLogic { @@ -82,7 +88,7 @@ private int getParallel(Recipe recipe, double totalHolderEfficiencyCoefficient, (Math.abs(recipe.getEUt()) * totalHolderEfficiencyCoefficient)); } - private boolean canDoRecipeConsideringParallel(Recipe recipe) { + private boolean canDoRecipeWithParallel(Recipe recipe) { IRotorHolder rotorHolder = ((MetaTileEntityLargeTurbine) metaTileEntity).getRotorHolder(); if (rotorHolder == null || !rotorHolder.hasRotor()) return false; @@ -101,13 +107,26 @@ private boolean canDoRecipeConsideringParallel(Recipe recipe) { @Override protected boolean checkPreviousRecipe() { - return super.checkPreviousRecipe() && canDoRecipeConsideringParallel(this.previousRecipe); + return super.checkPreviousRecipe() && canDoRecipeWithParallel(this.previousRecipe); } @Override protected @Nullable Recipe findRecipe(long maxVoltage, IItemHandlerModifiable inputs, IMultipleTankHandler fluidInputs) { - return super.findRecipe(maxVoltage, inputs, fluidInputs, this::canDoRecipeConsideringParallel); + RecipeMap map = getRecipeMap(); + if (map == null || !isRecipeMapValid(map)) { + return null; + } + + final List items = GTUtility.itemHandlerToList(inputs).stream().filter(s -> !s.isEmpty()).collect( + Collectors.toList()); + final List fluids = GTUtility.fluidHandlerToList(fluidInputs).stream().filter(f -> f != null && f.amount != 0) + .collect(Collectors.toList()); + + return map.find(items, fluids, recipe -> { + if (recipe.getEUt() > maxVoltage) return false; + return recipe.matches(false, inputs, fluidInputs) && this.canDoRecipeWithParallel(recipe); + }); } @Override