diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-03-21 17:34:07 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-03-21 17:34:07 +0300 |
| commit | 7305ba719930ea3fbf8aa987aeec48b33cdbd82e (patch) | |
| tree | 2307517925d965cd9228c8649013b07639987846 /ihl/recipes | |
| parent | 5cb4c6e24033cf337812390d99a6817d24d21eab (diff) | |
Oregen
Diffstat (limited to 'ihl/recipes')
| -rw-r--r-- | ihl/recipes/RecipeOutputItemStack.java | 63 | ||||
| -rw-r--r-- | ihl/recipes/UniversalRecipeInput.java | 60 | ||||
| -rw-r--r-- | ihl/recipes/UniversalRecipeManager.java | 20 |
3 files changed, 33 insertions, 110 deletions
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<IRecipeInputFluid> fluidInputs = new ArrayList<IRecipeInputFluid>();
private final List<IRecipeInput> itemInputs = new ArrayList<IRecipeInput>();
- 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<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
- return this.adjustAmounts(fluidInputs1, itemInputs1, false, false);
+ return this.matches(fluidInputs1, itemInputs1, false);
}
public List<IRecipeInputFluid> getFluidInputs() {
@@ -84,9 +83,7 @@ public class UniversalRecipeInput { return this.matches(rInputsFluids, rInputsItems);
}
- public boolean adjustAmounts(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1, boolean doCheckAmounts,
- boolean doAdjustAmounts) {
- this.multiplier = Integer.MAX_VALUE;
+ public boolean matches(List<FluidStack> fluidInputs1, List<ItemStack> 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<IRecipeInput> rInputs = input.getItemInputs();
- Iterator<IRecipeInput> ii = rInputs.iterator();
- List<ItemStack> rInputsItems = new ArrayList<ItemStack>();
- while (ii.hasNext()) {
- IRecipeInput is = ii.next();
- rInputsItems.add(is.getInputs().get(0));
- }
- List<FluidStack> rInputsFluids = new ArrayList<FluidStack>();
- List<IRecipeInputFluid> rInputsF = input.getFluidInputs();
- Iterator<IRecipeInputFluid> 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<FluidStack> fluidInputs1, List<ItemStack> 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<FluidStack> fluidInputs, List<ItemStack> itemInputs,
- boolean adjustInput, boolean inputAffectOutput) {
+ public UniversalRecipeOutput getOutputFor(List<FluidStack> fluidInputs, List<ItemStack> 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" })
|
