From 7305ba719930ea3fbf8aa987aeec48b33cdbd82e Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Tue, 21 Mar 2017 17:34:07 +0300 Subject: Oregen --- ihl/recipes/RecipeOutputItemStack.java | 63 +++++++++++++-------------------- ihl/recipes/UniversalRecipeInput.java | 60 ++----------------------------- ihl/recipes/UniversalRecipeManager.java | 20 ++++------- 3 files changed, 33 insertions(+), 110 deletions(-) (limited to 'ihl/recipes') diff --git a/ihl/recipes/RecipeOutputItemStack.java b/ihl/recipes/RecipeOutputItemStack.java index c765b1d..480d1f8 100644 --- a/ihl/recipes/RecipeOutputItemStack.java +++ b/ihl/recipes/RecipeOutputItemStack.java @@ -3,63 +3,50 @@ package ihl.recipes; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public class RecipeOutputItemStack -{ +public class RecipeOutputItemStack { public final ItemStack itemStack; public final float quantity; - public RecipeOutputItemStack(ItemStack itemStack1, float quantity1) - { - itemStack=itemStack1; - quantity=quantity1; - itemStack.stackSize=1; + + public RecipeOutputItemStack(ItemStack itemStack1, float quantity1) { + itemStack = itemStack1; + quantity = quantity1; + itemStack.stackSize = 1; } - - public RecipeOutputItemStack(ItemStack itemStack1) - { + + public RecipeOutputItemStack(ItemStack itemStack1) { this(itemStack1, itemStack1.stackSize); } - - public boolean matches(RecipeOutputItemStack is1) - { - if(is1==null||(itemStack.getItem()!=is1.itemStack.getItem())) - { + + public boolean matches(RecipeOutputItemStack is1) { + if (is1 == null || (itemStack.getItem() != is1.itemStack.getItem())) { return false; - } - else if(is1.itemStack.getItemDamage()!=OreDictionary.WILDCARD_VALUE && - itemStack.getItemDamage()!=is1.itemStack.getItemDamage()) - { + } else if (is1.itemStack.getItemDamage() != OreDictionary.WILDCARD_VALUE + && itemStack.getItemDamage() != is1.itemStack.getItemDamage()) { return false; } return true; } - public RecipeOutputItemStack copy(int mulipier) - { - return new RecipeOutputItemStack(itemStack, quantity*mulipier); + public RecipeOutputItemStack copy(int mulipier) { + return new RecipeOutputItemStack(itemStack, quantity * mulipier); } - - public RecipeOutputItemStack copy() - { + + public RecipeOutputItemStack copy() { return new RecipeOutputItemStack(itemStack, quantity); } - + @Override - public String toString() - { - return this.itemStack.getUnlocalizedName()+":"+this.quantity; + public String toString() { + return this.itemStack.getUnlocalizedName() + ":" + this.quantity; } - public boolean matches(ItemStack is1) - { - if(is1==null||(itemStack.getItem()!=is1.getItem())) - { + public boolean matches(ItemStack is1) { + if (is1 == null || (itemStack.getItem() != is1.getItem())) { return false; - } - else if(is1.getItemDamage()!=OreDictionary.WILDCARD_VALUE && - itemStack.getItemDamage()!=is1.getItemDamage()) - { + } else if (is1.getItemDamage() != OreDictionary.WILDCARD_VALUE + && itemStack.getItemDamage() != is1.getItemDamage()) { return false; } - return false; + return true; } } diff --git a/ihl/recipes/UniversalRecipeInput.java b/ihl/recipes/UniversalRecipeInput.java index a654c2e..d2c25b6 100644 --- a/ihl/recipes/UniversalRecipeInput.java +++ b/ihl/recipes/UniversalRecipeInput.java @@ -17,7 +17,6 @@ public class UniversalRecipeInput { private final List fluidInputs = new ArrayList(); private final List itemInputs = new ArrayList(); - private int multiplier = Integer.MAX_VALUE; public UniversalRecipeInput(Object[] fluidStacks, Object[] iRecipeInputs) { if (fluidStacks != null) { @@ -55,7 +54,7 @@ public class UniversalRecipeInput { } public boolean matches(List fluidInputs1, List itemInputs1) { - return this.adjustAmounts(fluidInputs1, itemInputs1, false, false); + return this.matches(fluidInputs1, itemInputs1, false); } public List getFluidInputs() { @@ -84,9 +83,7 @@ public class UniversalRecipeInput { return this.matches(rInputsFluids, rInputsItems); } - public boolean adjustAmounts(List fluidInputs1, List itemInputs1, boolean doCheckAmounts, - boolean doAdjustAmounts) { - this.multiplier = Integer.MAX_VALUE; + public boolean matches(List fluidInputs1, List itemInputs1, boolean doCheckAmounts) { if (incorrectInputAmount(fluidInputs1, itemInputs1)) { return false; } @@ -96,21 +93,9 @@ public class UniversalRecipeInput { IRecipeInputFluid fs = fi.next(); FluidStack fs1 = getMatchedFluidStack(fs, fluidInputs1); if (fs1 == null || !fs.matches(fs1)) { - multiplier = 0; return false; } else if (doCheckAmounts && fs1.amount < fs.getAmount()) { - multiplier = 0; return false; - } else if (doAdjustAmounts) { - if (fs.getAmount() > 0) { - int multiplier1 = fs1.amount / fs.getAmount(); - if (multiplier1 < multiplier) { - multiplier = multiplier1; - } - } - fs1.amount -= fs.getAmount(); - if (fs1.amount <= 0) - fs1 = null; } } } @@ -120,21 +105,9 @@ public class UniversalRecipeInput { IRecipeInput is = ii.next(); ItemStack is1 = getMatchedItemStack(is, itemInputs1); if (is1 == null || !is.matches(is1)) { - multiplier = 0; return false; } else if (doCheckAmounts && is1.stackSize < is.getAmount()) { - multiplier = 0; return false; - } else if (doAdjustAmounts) { - if (is.getAmount() > 0) { - int multiplier1 = is1.stackSize / is.getAmount(); - if (multiplier1 < multiplier) { - multiplier = multiplier1; - } - } - if (IHLUtils.reduceItemStackAmountUsingIRecipeInput(is, is1, multiplier)) { - is1 = null; - } } } } @@ -161,35 +134,6 @@ public class UniversalRecipeInput { return null; } - public boolean adjustAmounts(UniversalRecipeInput input, boolean doAdjustAmounts) { - List rInputs = input.getItemInputs(); - Iterator ii = rInputs.iterator(); - List rInputsItems = new ArrayList(); - while (ii.hasNext()) { - IRecipeInput is = ii.next(); - rInputsItems.add(is.getInputs().get(0)); - } - List rInputsFluids = new ArrayList(); - List rInputsF = input.getFluidInputs(); - Iterator iiF = rInputsF.iterator(); - while (iiF.hasNext()) { - IRecipeInputFluid is = iiF.next(); - rInputsFluids.add(is.getInputs().get(0)); - } - return this.adjustAmounts(rInputsFluids, rInputsItems, true, doAdjustAmounts); - } - - public int getMultiplierAndAdjustAmounts(List fluidInputs1, List itemInputs1) { - if (this.adjustAmounts(fluidInputs1, itemInputs1, true, true)) { - if (multiplier < Integer.MAX_VALUE) { - return multiplier; - } else - return 1; - } else { - return 0; - } - } - public boolean containItemStack(ItemStack ingredient) { if (itemInputs == null || itemInputs.isEmpty()) { return false; diff --git a/ihl/recipes/UniversalRecipeManager.java b/ihl/recipes/UniversalRecipeManager.java index 169d6f6..6c09bb1 100644 --- a/ihl/recipes/UniversalRecipeManager.java +++ b/ihl/recipes/UniversalRecipeManager.java @@ -78,8 +78,7 @@ public class UniversalRecipeManager { this.keywordMap.put(keyword, input); } - public UniversalRecipeOutput getOutputFor(List fluidInputs, List itemInputs, - boolean adjustInput, boolean inputAffectOutput) { + public UniversalRecipeOutput getOutputFor(List fluidInputs, List itemInputs) { if (fluidInputs == null && itemInputs == null) { return null; } else { @@ -94,15 +93,8 @@ public class UniversalRecipeManager { 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; + if (recipeInput.matches(fluidInputs, itemInputs, true)) { + return entry.getValue(); } } @@ -128,7 +120,7 @@ public class UniversalRecipeManager { continue; } - if (recipeInput.adjustAmounts(fluidInputs1, itemInputs1, true, false)) { + if (recipeInput.matches(fluidInputs1, itemInputs1, true)) { return recipeInput; } } @@ -139,8 +131,8 @@ public class UniversalRecipeManager { } @SuppressWarnings({ "unchecked", "rawtypes" }) - public UniversalRecipeOutput getOutputFor(List[] input, boolean adjustInput, boolean inputAffectOutput) { - return this.getOutputFor(input[0], input[1], adjustInput, inputAffectOutput); + public UniversalRecipeOutput getOutputFor(List[] input) { + return this.getOutputFor(input[0], input[1]); } @SuppressWarnings({ "unchecked", "rawtypes" }) -- cgit v1.2.3