From 5cb4c6e24033cf337812390d99a6817d24d21eab Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Sun, 12 Feb 2017 20:43:03 +0300 Subject: Removed explosion radius limitations. Explosion calculation optimized (reduced memory usage). One more detonator and explosive pack recipe. GT6 recipes for both chemical reactors and cryogenic distiller. Max stack size of muffle furnace is limited to 32. A lot of old features are removed. --- ihl/recipes/UniversalRecipeManager.java | 337 ++++++++++++++------------------ 1 file changed, 144 insertions(+), 193 deletions(-) (limited to 'ihl/recipes/UniversalRecipeManager.java') diff --git a/ihl/recipes/UniversalRecipeManager.java b/ihl/recipes/UniversalRecipeManager.java index 99f43bc..169d6f6 100644 --- a/ihl/recipes/UniversalRecipeManager.java +++ b/ihl/recipes/UniversalRecipeManager.java @@ -12,237 +12,188 @@ import net.minecraftforge.fluids.FluidStack; import ihl.utils.IHLUtils; public class UniversalRecipeManager { - - public static Map machineRecipeManagers = new HashMap(); + + public static Map machineRecipeManagers = new HashMap(); public final String machine; - public UniversalRecipeManager(String machine1) - { - machine=machine1; - if(machineRecipeManagers.containsKey(machine1)) - { - throw new IllegalArgumentException("Recipe manager for "+machine1+" already exist!"); + + public UniversalRecipeManager(String machine1) { + machine = machine1; + if (machineRecipeManagers.containsKey(machine1)) { + throw new IllegalArgumentException("Recipe manager for " + machine1 + " already exist!"); } machineRecipeManagers.put(machine1, this); } private final Map recipes = new HashMap(); private final Map keywordMap = new HashMap(); - - public void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) - { - if (input == null) - { - throw new NullPointerException("The recipe input is null"); - } - else - { - if (output.getFluidOutputs() == null || output.getItemOutputs() == null ||(output.getFluidOutputs().size()==0 && output.getItemOutputs().size()==0)) - { - throw new NullPointerException("The output is empty"); - } - } - - Iterator var8 = this.recipes.keySet().iterator(); - - while (var8.hasNext()) - { - UniversalRecipeInput existingInput = (UniversalRecipeInput)var8.next(); - if (existingInput.matches(input)) - { - StringBuffer ssError =new StringBuffer(255); - ssError.append("Ambiguous recipe. \n"); - ssError.append("Existing input: \n"); - Iterator iii1 = existingInput.getItemInputs().iterator(); - Iterator fii1 = existingInput.getFluidInputs().iterator(); - while(iii1!=null && iii1.hasNext()) - { - ssError.append(iii1.next().toString()); - ssError.append(" \n"); - } - while(fii1!=null && fii1.hasNext()) - { - ssError.append(fii1.next().toString()); - ssError.append(" \n"); - } - ssError.append("New input: \n"); - Iterator iii2 = input.getItemInputs().iterator(); - Iterator fii2 = input.getFluidInputs().iterator(); - while(iii2!=null && iii2.hasNext()) - { - ssError.append(iii2.next().toString()); - ssError.append(" \n"); - } - while(fii2!=null && fii2.hasNext()) - { - ssError.append(fii2.next().toString()); - ssError.append(" \n"); - } - throw new RuntimeException(ssError.toString()); - } - } - - this.recipes.put(input, output); - } - - public void addRecipe(String keyword, UniversalRecipeInput input, UniversalRecipeOutput output) - { - this.addRecipe(input, output); - this.keywordMap.put(keyword, input); - } - - public UniversalRecipeOutput getOutputFor(List fluidInputs, List itemInputs, boolean adjustInput, boolean inputAffectOutput) - { - if (fluidInputs == null && itemInputs == null) - { - return null; - } - else - { - Iterator> i$ = this.recipes.entrySet().iterator(); - - while (true) - { - if (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeInput recipeInput = entry.getKey(); - - if (!recipeInput.matches(fluidInputs, itemInputs)) - { - continue; - } - - if (recipeInput.adjustAmounts(fluidInputs, itemInputs,true, false)) - { - UniversalRecipeOutput output = entry.getValue(); - if (adjustInput) - { - if(inputAffectOutput) - { - int multiplier = recipeInput.getMultiplierAndAdjustAmounts(fluidInputs, itemInputs); - return output.copyWithMultiplier(multiplier); - } - else - { - recipeInput.adjustAmounts(fluidInputs, itemInputs,true, true); - } - } - return output; - } - } - - return null; - } - } - } - - public Map getRecipes() - { - return this.recipes; - } + public void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) { + if (input == null) { + throw new NullPointerException("The recipe input is null"); + } else { + if (output.getFluidOutputs() == null || output.getItemOutputs() == null + || (output.getFluidOutputs().size() == 0 && output.getItemOutputs().size() == 0)) { + throw new NullPointerException("The output is empty"); + } + } - public UniversalRecipeInput getRecipeInput(List fluidInputs1, List itemInputs1) { - { - Iterator> i$ = this.recipes.entrySet().iterator(); - - while (true) - { - if (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeInput recipeInput = entry.getKey(); - - if (!recipeInput.matches(fluidInputs1,itemInputs1)) - { - continue; - } - - if (recipeInput.adjustAmounts(fluidInputs1,itemInputs1,true, false)) - { - return recipeInput; - } - } - - return null; - } - } + Iterator var8 = this.recipes.keySet().iterator(); + + while (var8.hasNext()) { + UniversalRecipeInput existingInput = (UniversalRecipeInput) var8.next(); + if (existingInput.matches(input)) { + StringBuffer ssError = new StringBuffer(255); + ssError.append("Ambiguous recipe. \n"); + ssError.append("Existing input: \n"); + Iterator iii1 = existingInput.getItemInputs().iterator(); + Iterator fii1 = existingInput.getFluidInputs().iterator(); + while (iii1 != null && iii1.hasNext()) { + ssError.append(iii1.next().toString()); + ssError.append(" \n"); + } + while (fii1 != null && fii1.hasNext()) { + ssError.append(fii1.next().toString()); + ssError.append(" \n"); + } + ssError.append("New input: \n"); + Iterator iii2 = input.getItemInputs().iterator(); + Iterator fii2 = input.getFluidInputs().iterator(); + while (iii2 != null && iii2.hasNext()) { + ssError.append(iii2.next().toString()); + ssError.append(" \n"); + } + while (fii2 != null && fii2.hasNext()) { + ssError.append(fii2.next().toString()); + ssError.append(" \n"); + } + throw new RuntimeException(ssError.toString()); + } + } + + this.recipes.put(input, output); + } + + public void addRecipe(String keyword, UniversalRecipeInput input, UniversalRecipeOutput output) { + this.addRecipe(input, output); + this.keywordMap.put(keyword, input); + } + + public UniversalRecipeOutput getOutputFor(List fluidInputs, List itemInputs, + boolean adjustInput, boolean inputAffectOutput) { + if (fluidInputs == null && itemInputs == null) { + return null; + } else { + Iterator> i$ = this.recipes.entrySet().iterator(); + + while (true) { + if (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeInput recipeInput = entry.getKey(); + + if (!recipeInput.matches(fluidInputs, itemInputs)) { + continue; + } + + if (recipeInput.adjustAmounts(fluidInputs, itemInputs, true, false)) { + UniversalRecipeOutput output = entry.getValue(); + if (inputAffectOutput) { + int multiplier = recipeInput.getMultiplierAndAdjustAmounts(fluidInputs, itemInputs); + return output.copyWithMultiplier(multiplier); + } else if (adjustInput) { + recipeInput.adjustAmounts(fluidInputs, itemInputs, true, true); + } + return output; + } + } + + return null; + } + } + } + + public Map getRecipes() { + return this.recipes; } + public UniversalRecipeInput getRecipeInput(List fluidInputs1, List itemInputs1) { + { + Iterator> i$ = this.recipes.entrySet().iterator(); + + while (true) { + if (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeInput recipeInput = entry.getKey(); + + if (!recipeInput.matches(fluidInputs1, itemInputs1)) { + continue; + } + + if (recipeInput.adjustAmounts(fluidInputs1, itemInputs1, true, false)) { + return recipeInput; + } + } + + return null; + } + } + } @SuppressWarnings({ "unchecked", "rawtypes" }) - public UniversalRecipeOutput getOutputFor(List[] input, boolean adjustInput, boolean inputAffectOutput) - { + public UniversalRecipeOutput getOutputFor(List[] input, boolean adjustInput, boolean inputAffectOutput) { return this.getOutputFor(input[0], input[1], adjustInput, inputAffectOutput); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public UniversalRecipeInput getRecipeInput(List[] input) - { + public UniversalRecipeInput getRecipeInput(List[] input) { return this.getRecipeInput(input[0], input[1]); } - - public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) - { + public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) { List fluidInputs = IHLUtils.convertRecipeInputToFluidStackList(uRecipeInput.getFluidInputs()); List itemInputs = IHLUtils.convertRecipeInputToItemStackList(uRecipeInput.getItemInputs()); - { - Iterator> i$ = this.recipes.entrySet().iterator(); - while (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeInput recipeInput = entry.getKey(); - if (recipeInput.matches(fluidInputs, itemInputs)) - { - i$.remove(); - break; - } - } - } + { + Iterator> i$ = this.recipes.entrySet().iterator(); + while (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeInput recipeInput = entry.getKey(); + if (recipeInput.matches(fluidInputs, itemInputs)) { + i$.remove(); + break; + } + } + } } - public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) - { + public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) { Iterator> i$ = this.recipes.entrySet().iterator(); - while (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeOutput recipeOutput = entry.getValue(); - if (recipeOutputHasCommonEntries(recipeOutput,uRecipeOutput)) - { - i$.remove(); - } - } + while (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeOutput recipeOutput = entry.getValue(); + if (recipeOutputHasCommonEntries(recipeOutput, uRecipeOutput)) { + i$.remove(); + } + } } - - public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) - { + + public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) { List fluidOutputs = out.getFluidOutputs(); List itemOutputs = out.getItemOutputs(); - if(!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) - { + if (!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) { FluidStack fs1 = out1.getFluidOutputs().get(0); Iterator fi = fluidOutputs.iterator(); - while(fi.hasNext()) - { + while (fi.hasNext()) { FluidStack fs = fi.next(); - if(fs.getFluid()==fs1.getFluid()) - { + if (fs.getFluid() == fs1.getFluid()) { return true; } } } - if(!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) - { + if (!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) { RecipeOutputItemStack is1 = out1.getItemOutputs().get(0); Iterator ii = itemOutputs.iterator(); - while(ii.hasNext()) - { + while (ii.hasNext()) { RecipeOutputItemStack is = ii.next(); - if(is.matches(is1)) - { + if (is.matches(is1)) { return true; } } -- cgit v1.2.3