summaryrefslogtreecommitdiff
path: root/ihl/recipes
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2017-06-17 08:12:18 +0300
committerFoghrye4 <foghrye4@gmail.com>2017-06-17 08:12:18 +0300
commitdc3df3edd5843bde0c1335d6a8e460b2c832aa48 (patch)
treeaf13bfeee567f2351e35e1ef176d168fe37c8aac /ihl/recipes
parent1da8dcd58647e34c9af94ceeecaeaf3b0d08c48c (diff)
full project files
Diffstat (limited to 'ihl/recipes')
-rw-r--r--ihl/recipes/IRecipeInputFluid.java11
-rw-r--r--ihl/recipes/IronWorkbenchRecipe.java214
-rw-r--r--ihl/recipes/RecipeInputDetonator.java73
-rw-r--r--ihl/recipes/RecipeInputDie.java97
-rw-r--r--ihl/recipes/RecipeInputFluidDictionary.java46
-rw-r--r--ihl/recipes/RecipeInputFluidStack.java45
-rw-r--r--ihl/recipes/RecipeInputObjectInstance.java44
-rw-r--r--ihl/recipes/RecipeInputOreDictionaryList.java122
-rw-r--r--ihl/recipes/RecipeInputWire.java72
-rw-r--r--ihl/recipes/RecipeOutputItemStack.java52
-rw-r--r--ihl/recipes/UniversalRecipeInput.java205
-rw-r--r--ihl/recipes/UniversalRecipeManager.java195
-rw-r--r--ihl/recipes/UniversalRecipeOutput.java149
13 files changed, 0 insertions, 1325 deletions
diff --git a/ihl/recipes/IRecipeInputFluid.java b/ihl/recipes/IRecipeInputFluid.java
deleted file mode 100644
index 774973c..0000000
--- a/ihl/recipes/IRecipeInputFluid.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package ihl.recipes;
-
-import java.util.List;
-
-import net.minecraftforge.fluids.FluidStack;
-
-public interface IRecipeInputFluid {
- public boolean matches(FluidStack subject);
- public int getAmount();
- public List<FluidStack> getInputs();
-}
diff --git a/ihl/recipes/IronWorkbenchRecipe.java b/ihl/recipes/IronWorkbenchRecipe.java
deleted file mode 100644
index e471811..0000000
--- a/ihl/recipes/IronWorkbenchRecipe.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package ihl.recipes;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import ic2.api.recipe.IRecipeInput;
-import ic2.api.recipe.RecipeInputItemStack;
-import ic2.api.recipe.RecipeInputOreDict;
-import ihl.interfaces.IWire;
-import ihl.utils.IHLUtils;
-import net.minecraft.item.ItemStack;
-
-public class IronWorkbenchRecipe {
- public List<ItemStack> workspaceElements=new ArrayList<ItemStack>();
- public List<IRecipeInput> tools=new ArrayList<IRecipeInput>();
- public List<IRecipeInput> materials=new ArrayList<IRecipeInput>();
- public List<ItemStack> outputs = new ArrayList<ItemStack>();
-
- public IronWorkbenchRecipe(List<?> tools1, List<?> materials1, List<ItemStack> output1_1)
- {
- if(tools1!=null)
- {
- Iterator<?> iTools1 = tools1.iterator();
- while(iTools1.hasNext())
- {
- Object tool = iTools1.next();
- if(tool instanceof ItemStack)
- {
- ItemStack stack = (ItemStack) tool;
- String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack);
- if(!oreDictName.isEmpty() && oreDictName.length()>3)
- {
- tools.add(new RecipeInputOreDict(oreDictName));
- }
- else
- {
- tools.add(new RecipeInputItemStack(stack));
- }
- }
- else
- {
- tools.add((IRecipeInput) tool);
- }
- }
- }
- Iterator<?> iMaterials1 = materials1.iterator();
- while(iMaterials1.hasNext())
- {
- Object material = iMaterials1.next();
- if(material instanceof ItemStack)
- {
- ItemStack stack = (ItemStack) material;
- String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack);
- if(stack.getItem() instanceof IWire)
- {
- materials.add(new RecipeInputWire(stack));
- }
- else if(!oreDictName.isEmpty() && oreDictName.length()>3)
- {
- materials.add(new RecipeInputOreDict(oreDictName,stack.stackSize));
- }
- else
- {
- materials.add(new RecipeInputItemStack(stack));
- }
- }
- else
- {
- materials.add((IRecipeInput) material);
- }
-
- }
- Iterator<ItemStack> iOutput = output1_1.iterator();
- while(iOutput.hasNext())
- {
- ItemStack outputStack = iOutput.next();
- if(outputStack==null)
- throw new NullPointerException("Output shall not contain null.");
- this.outputs.add(outputStack);
- }
- if(tools.size()>8 || materials.size()>12)
- {
- throw new IllegalArgumentException("Iron workbench recipe cannot contain more than 8 tools or more than 12 materials!");
- }
- }
-
- public IronWorkbenchRecipe(List<?> asList, List<?> asList2, List<ItemStack> asList3, List<ItemStack> workspaceElements1) {
- this(asList, asList2, asList3);
- if(workspaceElements1!=null)
- {
- this.workspaceElements.addAll(workspaceElements1);
- }
- }
-
- public boolean isTool(ItemStack tool1)
- {
- if(tools!=null && !tools.isEmpty())
- {
- if(tool1==null)
- {
- return false;
- }
- Iterator<IRecipeInput> i1 = tools.iterator();
- while(i1.hasNext())
- {
- IRecipeInput tool = i1.next();
- if(tool.matches(tool1))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean isCanBeCrafted(List<ItemStack> tools1, List<ItemStack> materials1, List<ItemStack> workspaceElements1)
- {
- if(workspaceElements!=null && !workspaceElements.isEmpty())
- {
- if(workspaceElements1==null||workspaceElements1.isEmpty())
- {
- return false;
- }
- Iterator<ItemStack> i1 = workspaceElements.iterator();
- while(i1.hasNext())
- {
- ItemStack tool = i1.next();
- if(!this.isItemStackInList(tool, workspaceElements1))
- {
- return false;
- }
- }
- }
-
- if(tools!=null && !tools.isEmpty())
- {
- if(tools1==null||tools1.isEmpty())
- {
- return false;
- }
- Iterator<IRecipeInput> i1 = tools.iterator();
- while(i1.hasNext())
- {
- IRecipeInput tool = i1.next();
- if(!this.isItemStackInList(tool, tools1))
- {
- return false;
- }
- }
- }
- if(materials!=null && !materials.isEmpty())
- {
- Iterator<IRecipeInput> i1 = materials.iterator();
- while(i1.hasNext())
- {
- IRecipeInput material = i1.next();
- if(!this.isItemStackInList(material, materials1))
- {
- return false;
- }
- }
- }
- return true;
- }
-
- private boolean isItemStackInList(IRecipeInput tool, List<ItemStack> tools1) {
- Iterator<ItemStack> it = tools1.iterator();
- while(it.hasNext())
- {
- ItemStack tool2 = it.next();
- if(tool.matches(tool2))
- {
- if(tool2.getItem() instanceof IWire)
- {
- if(IHLUtils.getWireLength(tool2)>=tool.getAmount())
- {
- return true;
- }
- }
- else if(tool2.stackSize>=tool.getAmount())
- {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean isItemStackInList(ItemStack tool, List<ItemStack> tools1)
- {
- Iterator<ItemStack> it = tools1.iterator();
- while(it.hasNext())
- {
- ItemStack tool2 = it.next();
- if(IHLUtils.isItemStacksIsEqual(tool,tool2,true))
- {
- if(tool2.getItem() instanceof IWire)
- {
- if(IHLUtils.getWireLength(tool2)>=IHLUtils.getWireLength(tool))
- {
- return true;
- }
- }
- else if(tool2.stackSize>=tool.stackSize)
- {
- return true;
- }
- }
- }
- return false;
- }
-
-}
diff --git a/ihl/recipes/RecipeInputDetonator.java b/ihl/recipes/RecipeInputDetonator.java
deleted file mode 100644
index 15030fd..0000000
--- a/ihl/recipes/RecipeInputDetonator.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package ihl.recipes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import ic2.api.recipe.IRecipeInput;
-import ihl.utils.IHLUtils;
-import net.minecraft.item.ItemStack;
-
-public class RecipeInputDetonator implements IRecipeInput
-{
- public final ItemStack input;
- public final int detonator_delay;
-
- public RecipeInputDetonator(String string, int detonator_delay)
- {
- this(IHLUtils.getItemStackWithTag(string, "detonator_delay", detonator_delay));
- }
-
- public RecipeInputDetonator(ItemStack itemStack)
- {
- input=itemStack;
- detonator_delay=itemStack.stackTagCompound.getInteger("detonator_delay");
- }
-
- @Override
- public boolean matches(ItemStack subject)
- {
- return subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767);
- }
-
- @Override
- public int getAmount()
- {
- return 1;
- }
-
- @Override
- public List<ItemStack> getInputs()
- {
- return Arrays.asList(new ItemStack[] {this.input});
- }
-
- @Override
- public String toString()
- {
- ItemStack stack = this.input.copy();
- return "RInputDice<" + stack + ">";
- }
-
- public List<ItemStack> transformOutput(ItemStack matchedItemStack, List<ItemStack> outputs)
- {
- List<ItemStack> newOutputs = new ArrayList<ItemStack>();
- int misTS = matchedItemStack.stackTagCompound.getInteger("detonator_delay");
- ItemStack material;
- for(ItemStack material1:outputs)
- {
- if(IHLUtils.getFirstOreDictName(material1) == "blockExplosive")
- {
- material=material1.copy();
- material.stackTagCompound.setInteger("detonator_delay", misTS);
- newOutputs.add(material);
- }
- else
- {
- newOutputs.add(material1);
- }
- }
- return newOutputs;
- }
-}
-
diff --git a/ihl/recipes/RecipeInputDie.java b/ihl/recipes/RecipeInputDie.java
deleted file mode 100644
index 8fbd4db..0000000
--- a/ihl/recipes/RecipeInputDie.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package ihl.recipes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import ic2.api.recipe.IRecipeInput;
-import ihl.interfaces.IWire;
-import ihl.utils.IHLUtils;
-import net.minecraft.item.ItemStack;
-
-public class RecipeInputDie implements IRecipeInput
-{
- public final ItemStack input;
- public final int transverseSection;
-
- public RecipeInputDie(String string, int transverseSection)
- {
- this(IHLUtils.getItemStackWithTag(string, "transverseSection", transverseSection));
- }
-
- public RecipeInputDie(ItemStack itemStack)
- {
- input=itemStack;
- transverseSection=itemStack.stackTagCompound.getInteger("transverseSection");
- }
-
- @Override
- public boolean matches(ItemStack subject)
- {
- return subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767);
- }
-
- @Override
- public int getAmount()
- {
- return 1;
- }
-
- @Override
- public List<ItemStack> getInputs()
- {
- return Arrays.asList(new ItemStack[] {this.input});
- }
-
- @Override
- public String toString()
- {
- ItemStack stack = this.input.copy();
- return "RInputDice<" + stack + ">";
- }
-
- public List<ItemStack> transformOutput(ItemStack matchedItemStack, List<ItemStack> outputs)
- {
- List<ItemStack> newOutputs = new ArrayList<ItemStack>();
- int misTS = matchedItemStack.stackTagCompound.getInteger("transverseSection");
- ItemStack material;
- for(ItemStack material1:outputs)
- {
- if(material1.getItem() instanceof IWire)
- {
- material=material1.copy();
- int length = material.stackTagCompound.getInteger("length");
- length = length * transverseSection / misTS;
- material.stackTagCompound.setInteger("length", length);
- material.stackTagCompound.setInteger("fullLength", length);
- material.stackTagCompound.setInteger("transverseSection", misTS);
- newOutputs.add(material);
- }
- else
- {
- newOutputs.add(material1);
- }
- }
- return newOutputs;
- }
-
- public int transformOutput(ItemStack matchedItemStack, ItemStack material)
- {
- int consumeAmountMultiplier=1;
- int misTS = matchedItemStack.stackTagCompound.getInteger("transverseSection");
- if(misTS<=transverseSection)
- {
- int length = material.stackTagCompound.getInteger("length");
- length = length * transverseSection / misTS;
- material.stackTagCompound.setInteger("length", length);
- material.stackTagCompound.setInteger("fullLength", length);
- }
- else
- {
- consumeAmountMultiplier=misTS/transverseSection+1;
- }
- material.stackTagCompound.setInteger("transverseSection", misTS);
- return consumeAmountMultiplier;
- }
-}
-
diff --git a/ihl/recipes/RecipeInputFluidDictionary.java b/ihl/recipes/RecipeInputFluidDictionary.java
deleted file mode 100644
index eb5b057..0000000
--- a/ihl/recipes/RecipeInputFluidDictionary.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package ihl.recipes;
-
-import java.util.List;
-
-import ihl.IHLMod;
-import net.minecraftforge.fluids.FluidStack;
-
-public class RecipeInputFluidDictionary implements IRecipeInputFluid
-{
- private final String input;
- private final int amount;
- public RecipeInputFluidDictionary(String input1, int amount1)
- {
- this.input=input1;
- this.amount=amount1;
- }
-
- @Override
- public boolean matches(FluidStack subject)
- {
- if(subject==null)
- {
- return false;
- }
- String fName = IHLMod.fluidDictionary.getFluidName(subject.getFluid());
- return fName==null?false:fName.equals(input);
- }
-
- @Override
- public int getAmount() {
- return amount;
- }
-
- @Override
- public List<FluidStack> getInputs() {
- return IHLMod.fluidDictionary.getFluids(input);
- }
-
- @Override
- public String toString()
- {
- return "RInputFluidStackDictionary<" + this.amount + "x" + this.input;
- }
-
-
-}
diff --git a/ihl/recipes/RecipeInputFluidStack.java b/ihl/recipes/RecipeInputFluidStack.java
deleted file mode 100644
index e4c116d..0000000
--- a/ihl/recipes/RecipeInputFluidStack.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package ihl.recipes;
-
-import java.util.Arrays;
-import java.util.List;
-
-import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidStack;
-
-public class RecipeInputFluidStack implements IRecipeInputFluid
-{
- private final Fluid fluid;
- private final int amount;
- public RecipeInputFluidStack(FluidStack fstack)
- {
- this.fluid=fstack.getFluid();
- this.amount=fstack.amount;
- }
-
- @Override
- public boolean matches(FluidStack subject)
- {
- if(subject==null || subject.getFluid()==null)
- {
- return false;
- }
- return fluid.getName().equals(subject.getFluid().getName());
- }
-
- @Override
- public int getAmount() {
- return amount;
- }
-
- @Override
- public List<FluidStack> getInputs() {
- return Arrays.asList(new FluidStack[] {new FluidStack(fluid,amount)});
- }
-
- @Override
- public String toString()
- {
- return "RInputFluidStack<" + this.amount + "x" + this.fluid.getName();
- }
-
-}
diff --git a/ihl/recipes/RecipeInputObjectInstance.java b/ihl/recipes/RecipeInputObjectInstance.java
deleted file mode 100644
index 42fdc26..0000000
--- a/ihl/recipes/RecipeInputObjectInstance.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package ihl.recipes;
-
-import java.util.Arrays;
-import java.util.List;
-
-import ic2.api.recipe.IRecipeInput;
-import ihl.utils.IHLUtils;
-import net.minecraft.item.ItemStack;
-
-public class RecipeInputObjectInstance implements IRecipeInput
-{
- public final ItemStack input;
-
- public RecipeInputObjectInstance(ItemStack aInput)
- {
- this.input = aInput;
- }
-
- @Override
- public boolean matches(ItemStack subject)
- {
- return this.input==subject;
- }
-
- @Override
- public int getAmount()
- {
- return IHLUtils.getAmountOf(input);
- }
-
- @Override
- public List<ItemStack> getInputs()
- {
- return Arrays.asList(new ItemStack[] {this.input});
- }
-
- @Override
- public String toString()
- {
- ItemStack stack = this.input.copy();
- return "RInputWireItemStack<" + stack + ">";
- }
-
-}
diff --git a/ihl/recipes/RecipeInputOreDictionaryList.java b/ihl/recipes/RecipeInputOreDictionaryList.java
deleted file mode 100644
index e438d98..0000000
--- a/ihl/recipes/RecipeInputOreDictionaryList.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package ihl.recipes;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import ic2.api.recipe.IRecipeInput;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.oredict.OreDictionary;
-
-public class RecipeInputOreDictionaryList implements IRecipeInput {
-
- public final String[] input;
- public final int amount;
- public final Integer meta;
- private List<ItemStack> ores;
-
- public RecipeInputOreDictionaryList(String[] input1) {
- this(input1, 1);
- }
-
- public RecipeInputOreDictionaryList(String[] input1, int amount1) {
- this(input1, amount1, (Integer) null);
- }
-
- public RecipeInputOreDictionaryList(String[] input1, int amount1, Integer meta) {
- this.input = input1;
- this.amount = amount1;
- this.meta = meta;
- }
-
- @Override
- public boolean matches(ItemStack subject) {
- List<ItemStack> inputs = this.getOres();
- boolean useOreStackMeta = this.meta == null;
- Item subjectItem = subject.getItem();
- int subjectMeta = subject.getItemDamage();
- Iterator<ItemStack> i$ = inputs.iterator();
- Item oreItem;
- int metaRequired;
-
- do {
- do {
- ItemStack oreStack;
-
- do {
- if (!i$.hasNext()) {
- return false;
- }
-
- oreStack = i$.next();
- oreItem = oreStack.getItem();
- } while (oreItem == null);
-
- metaRequired = useOreStackMeta ? oreStack.getItemDamage() : this.meta.intValue();
- } while (subjectItem != oreItem);
- } while (subjectMeta != metaRequired && metaRequired != 32767);
-
- return true;
- }
-
- @Override
- public int getAmount() {
- return this.amount;
- }
-
- @Override
- public List<ItemStack> getInputs() {
- List<ItemStack> ores = this.getOres();
- boolean hasInvalidEntries = false;
- Iterator<ItemStack> ret = ores.iterator();
-
- while (ret.hasNext()) {
- ItemStack i$ = ret.next();
-
- if (i$.getItem() == null) {
- hasInvalidEntries = true;
- break;
- }
- }
-
- if (!hasInvalidEntries) {
- return ores;
- } else {
- ArrayList<ItemStack> ret1 = new ArrayList<ItemStack>(ores.size());
- Iterator<ItemStack> i$1 = ores.iterator();
-
- while (i$1.hasNext()) {
- ItemStack stack = i$1.next();
-
- if (stack.getItem() != null) {
- ret1.add(stack);
- }
- }
-
- return Collections.unmodifiableList(ret1);
- }
- }
-
- @Override
- public String toString() {
- return this.meta == null ? "RInputOreDict<" + this.amount + "x" + this.input + ">"
- : "RInputOreDict<" + this.amount + "x" + this.input + "@" + this.meta + ">";
- }
-
- private List<ItemStack> getOres() {
- if (this.ores != null) {
- return this.ores;
- } else {
- this.ores = new ArrayList<ItemStack>();
- for (int i = 0; i < this.input.length; i++) {
- ArrayList<ItemStack> ret = OreDictionary.getOres(this.input[i]);
- if (ret != OreDictionary.EMPTY_LIST) {
- this.ores.addAll(ret);
- }
- }
- return this.ores;
- }
- }
-}
diff --git a/ihl/recipes/RecipeInputWire.java b/ihl/recipes/RecipeInputWire.java
deleted file mode 100644
index a7d5310..0000000
--- a/ihl/recipes/RecipeInputWire.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package ihl.recipes;
-
-import java.util.Arrays;
-import java.util.List;
-
-import ic2.api.recipe.IRecipeInput;
-import ihl.interfaces.IWire;
-import ihl.items_blocks.FlexibleCableItem;
-import ihl.utils.IHLUtils;
-import net.minecraft.item.ItemStack;
-
-public class RecipeInputWire implements IRecipeInput {
- public final ItemStack input;
- public final int amount;
-
- public RecipeInputWire(final ItemStack aInput) {
- this(aInput, IHLUtils.getWireLength(aInput));
- }
-
- public RecipeInputWire(final ItemStack aInput, int aAmount) {
- if (aInput.getItem() == null || !(aInput.getItem() instanceof IWire)) {
- throw new IllegalArgumentException("Invalid item stack specfied");
- } else {
- this.input = aInput;
- this.amount = aAmount;
- }
- }
-
- public RecipeInputWire(String string, int i) {
- this(IHLUtils.getThisModWireItemStackWithLength(string, i), i);
- }
-
- public RecipeInputWire(String material, int length, int transverseSection) {
- this(IHLUtils.getUninsulatedWire(material, length, transverseSection), length);
- }
-
- public RecipeInputWire(String material, int length, int transverseSection, String insulationMaterial,
- int insulationThickness, int insulationBreakdownVoltage) {
- this(IHLUtils.getInsulatedWire(material, length, transverseSection, insulationMaterial, insulationThickness),
- length);
- }
-
- @Override
- public boolean matches(ItemStack subject) {
- if (subject.getItem() == this.input.getItem()
- && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767)) {
- if (subject.getItem() instanceof FlexibleCableItem) {
- FlexibleCableItem item = (FlexibleCableItem) subject.getItem();
- return item.isSameWire(this.input, subject);
- } else {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int getAmount() {
- return this.amount;
- }
-
- @Override
- public List<ItemStack> getInputs() {
- return Arrays.asList(new ItemStack[] { this.input });
- }
-
- @Override
- public String toString() {
- ItemStack stack = this.input.copy();
- return "RInputWireItemStack<" + stack + ">";
- }
-}
diff --git a/ihl/recipes/RecipeOutputItemStack.java b/ihl/recipes/RecipeOutputItemStack.java
deleted file mode 100644
index 480d1f8..0000000
--- a/ihl/recipes/RecipeOutputItemStack.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package ihl.recipes;
-
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.oredict.OreDictionary;
-
-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) {
- this(itemStack1, itemStack1.stackSize);
- }
-
- 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()) {
- return false;
- }
- return true;
- }
-
- public RecipeOutputItemStack copy(int mulipier) {
- return new RecipeOutputItemStack(itemStack, quantity * mulipier);
- }
-
- public RecipeOutputItemStack copy() {
- return new RecipeOutputItemStack(itemStack, quantity);
- }
-
- @Override
- public String toString() {
- return this.itemStack.getUnlocalizedName() + ":" + this.quantity;
- }
-
- 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()) {
- return false;
- }
- return true;
- }
-}
diff --git a/ihl/recipes/UniversalRecipeInput.java b/ihl/recipes/UniversalRecipeInput.java
deleted file mode 100644
index 7cdb386..0000000
--- a/ihl/recipes/UniversalRecipeInput.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package ihl.recipes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import ic2.api.recipe.IRecipeInput;
-import ic2.api.recipe.RecipeInputItemStack;
-import ic2.api.recipe.RecipeInputOreDict;
-import ihl.interfaces.IWire;
-import ihl.utils.IHLUtils;
-import ihl.worldgen.ores.IHLFluid;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidStack;
-
-public class UniversalRecipeInput {
-
- private final List<IRecipeInputFluid> fluidInputs = new ArrayList<IRecipeInputFluid>();
- private final List<IRecipeInput> itemInputs = new ArrayList<IRecipeInput>();
-
- public UniversalRecipeInput(Object[] fluidStacks, Object[] iRecipeInputs) {
- if (fluidStacks != null) {
- for (Object material : fluidStacks) {
- if (material == null) {
- throw new NullPointerException("Recipe input cannot be null!");
- }
- if (material instanceof FluidStack) {
- fluidInputs.add(new RecipeInputFluidStack((FluidStack) material));
- } else {
- fluidInputs.add((IRecipeInputFluid) material);
- }
- }
- }
- sortFluidsByDensity();
- if (iRecipeInputs != null) {
- for (Object material : iRecipeInputs) {
- if (material == null) {
- throw new NullPointerException("Recipe input cannot be null!");
- }
- if (material instanceof ItemStack) {
- ItemStack stack = (ItemStack) material;
- String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack);
- if (stack.getItem() instanceof IWire) {
- itemInputs.add(new RecipeInputWire(stack));
- } else if (!oreDictName.isEmpty() && oreDictName.length() > 3) {
- itemInputs.add(new RecipeInputOreDict(oreDictName, stack.stackSize));
- } else {
- itemInputs.add(new RecipeInputItemStack(stack));
- }
- } else {
- itemInputs.add((IRecipeInput) material);
- }
- }
- }
- }
-
- public void sortFluidsByDensity()
- {
- Map<Integer, IRecipeInputFluid> sortMap = new HashMap<Integer, IRecipeInputFluid>();
- int[] keysArray = new int[fluidInputs.size()];
- Iterator<IRecipeInputFluid> fli = fluidInputs.iterator();
- while(fli.hasNext())
- {
- IRecipeInputFluid rinput = fli.next();
- FluidStack fluid=rinput.getInputs().get(0);
- if(fluid==null)
- {
- return;
- }
- int key = Math.round(IHLFluid.getRealDensity(fluid.getFluid())*100F);
- while(sortMap.containsKey(key))
- {
- key++;
- }
- sortMap.put(key, rinput);
- keysArray[fluidInputs.indexOf(rinput)]=key;
- }
- Arrays.sort(keysArray);
- List<IRecipeInputFluid> newFluidList = new ArrayList<IRecipeInputFluid>();
- for(int i=keysArray.length-1;i>=0;i--)
- {
- newFluidList.add(sortMap.get(keysArray[i]));
- }
- this.fluidInputs.clear();
- this.fluidInputs.addAll(newFluidList);
- }
-
- public boolean matches(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
- return this.matches(fluidInputs1, itemInputs1, false);
- }
-
- public List<IRecipeInputFluid> getFluidInputs() {
- return fluidInputs;
- }
-
- public List<IRecipeInput> getItemInputs() {
- return itemInputs;
- }
-
- public boolean matches(UniversalRecipeInput input) {
- 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.matches(rInputsFluids, rInputsItems);
- }
-
- public boolean matches(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1, boolean doCheckAmounts) {
- if (incorrectInputAmount(fluidInputs1, itemInputs1)) {
- return false;
- }
- if (fluidInputs1 != null) {
- Iterator<IRecipeInputFluid> fi = fluidInputs.iterator();
- while (fi.hasNext()) {
- IRecipeInputFluid fs = fi.next();
- FluidStack fs1 = getMatchedFluidStack(fs, fluidInputs1);
- if (fs1 == null || !fs.matches(fs1)) {
- return false;
- } else if (doCheckAmounts && fs1.amount < fs.getAmount()) {
- return false;
- }
- }
- }
- if (itemInputs1 != null) {
- Iterator<IRecipeInput> ii = itemInputs.iterator();
- while (ii.hasNext()) {
- IRecipeInput is = ii.next();
- ItemStack is1 = getMatchedItemStack(is, itemInputs1);
- if (is1 == null || !is.matches(is1)) {
- return false;
- } else if (doCheckAmounts && IHLUtils.getAmountOf(is1) < is.getAmount()) {
- return false;
- }
- }
- }
- return true;
- }
-
- private ItemStack getMatchedItemStack(IRecipeInput is, List<ItemStack> itemInputs1) {
- for (ItemStack is1 : itemInputs1) {
- if (is1 != null) {
- if (is.matches(is1)) {
- return is1;
- }
- }
- }
- return null;
- }
-
- private FluidStack getMatchedFluidStack(IRecipeInputFluid fs, List<FluidStack> fluidInputs1) {
- for (FluidStack fs1 : fluidInputs1) {
- if (fs.matches(fs1)) {
- return fs1;
- }
- }
- return null;
- }
-
- public boolean containItemStack(ItemStack ingredient) {
- if (itemInputs == null || itemInputs.isEmpty()) {
- return false;
- }
- Iterator<IRecipeInput> ii = itemInputs.iterator();
- while (ii.hasNext()) {
- IRecipeInput is = ii.next();
- if (is.matches(ingredient)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean containFluidStack(FluidStack fluidStack) {
- if (fluidInputs == null || fluidInputs.isEmpty()) {
- return false;
- }
- Iterator<IRecipeInputFluid> ii = fluidInputs.iterator();
- while (ii.hasNext()) {
- IRecipeInputFluid is = ii.next();
- if (is != null && is.matches(fluidStack)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean incorrectInputAmount(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
- return (fluidInputs.size() > 0 && fluidInputs1 == null) || (itemInputs.size() > 0 && itemInputs1 == null)
- || (fluidInputs1 != null && fluidInputs.size() > fluidInputs1.size())
- || (itemInputs1 != null && itemInputs.size() > itemInputs1.size());
- }
-}
diff --git a/ihl/recipes/UniversalRecipeManager.java b/ihl/recipes/UniversalRecipeManager.java
deleted file mode 100644
index cddc252..0000000
--- a/ihl/recipes/UniversalRecipeManager.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package ihl.recipes;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import ic2.api.recipe.IRecipeInput;
-import ihl.utils.IHLUtils;
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidStack;
-
-public class UniversalRecipeManager {
-
- public static Map<String, UniversalRecipeManager> machineRecipeManagers = new HashMap<String, UniversalRecipeManager>();
- public final String machine;
-
- 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<UniversalRecipeInput, UniversalRecipeOutput> recipes = new HashMap<UniversalRecipeInput, UniversalRecipeOutput>();
- private final Map<String, UniversalRecipeInput> keywordMap = new HashMap<String, UniversalRecipeInput>();
-
- 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<UniversalRecipeInput> 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<IRecipeInput> iii1 = existingInput.getItemInputs().iterator();
- Iterator<IRecipeInputFluid> 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<IRecipeInput> iii2 = input.getItemInputs().iterator();
- Iterator<IRecipeInputFluid> 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<FluidStack> fluidInputs, List<ItemStack> itemInputs) {
- if (fluidInputs == null && itemInputs == null) {
- return null;
- } else {
- Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
-
- while (true) {
- if (i$.hasNext()) {
- Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
- UniversalRecipeInput recipeInput = entry.getKey();
-
- if (!recipeInput.matches(fluidInputs, itemInputs)) {
- continue;
- }
-
- if (recipeInput.matches(fluidInputs, itemInputs, true)) {
- return entry.getValue();
- }
- }
-
- return null;
- }
- }
- }
-
- public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
- return this.recipes;
- }
-
- public UniversalRecipeInput getRecipeInput(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
- {
- Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
-
- while (true) {
- if (i$.hasNext()) {
- Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
- UniversalRecipeInput recipeInput = entry.getKey();
-
- if (!recipeInput.matches(fluidInputs1, itemInputs1)) {
- continue;
- }
-
- if (recipeInput.matches(fluidInputs1, itemInputs1, true)) {
- return recipeInput;
- }
- }
-
- return null;
- }
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public UniversalRecipeOutput getOutputFor(List[] input) {
- return this.getOutputFor(input[0], input[1]);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public UniversalRecipeInput getRecipeInput(List[] input) {
- return this.getRecipeInput(input[0], input[1]);
- }
-
- public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) {
- List<FluidStack> fluidInputs = IHLUtils.convertRecipeInputToFluidStackList(uRecipeInput.getFluidInputs());
- List<ItemStack> itemInputs = IHLUtils.convertRecipeInputToItemStackList(uRecipeInput.getItemInputs());
- {
- Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
- while (i$.hasNext()) {
- Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
- UniversalRecipeInput recipeInput = entry.getKey();
- if (recipeInput.matches(fluidInputs, itemInputs)) {
- i$.remove();
- break;
- }
- }
- }
- }
-
- public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) {
- Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
- while (i$.hasNext()) {
- Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
- UniversalRecipeOutput recipeOutput = entry.getValue();
- if (recipeOutputHasCommonEntries(recipeOutput, uRecipeOutput)) {
- i$.remove();
- }
- }
- }
-
- public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) {
- List<FluidStack> fluidOutputs = out.getFluidOutputs();
- List<RecipeOutputItemStack> itemOutputs = out.getItemOutputs();
- if (!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) {
- FluidStack fs1 = out1.getFluidOutputs().get(0);
- Iterator<FluidStack> fi = fluidOutputs.iterator();
- while (fi.hasNext()) {
- FluidStack fs = fi.next();
- if (fs.getFluid() == fs1.getFluid()) {
- return true;
- }
- }
- }
- if (!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) {
- RecipeOutputItemStack is1 = out1.getItemOutputs().get(0);
- Iterator<RecipeOutputItemStack> ii = itemOutputs.iterator();
- while (ii.hasNext()) {
- RecipeOutputItemStack is = ii.next();
- if (is.matches(is1)) {
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/ihl/recipes/UniversalRecipeOutput.java b/ihl/recipes/UniversalRecipeOutput.java
deleted file mode 100644
index 17c20e4..0000000
--- a/ihl/recipes/UniversalRecipeOutput.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package ihl.recipes;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import net.minecraft.item.ItemStack;
-import net.minecraftforge.fluids.FluidStack;
-
-public class UniversalRecipeOutput{
-
- private final List<FluidStack> fluidOutputs=new ArrayList<FluidStack>();
- private final List<RecipeOutputItemStack> itemOutputs=new ArrayList<RecipeOutputItemStack>();
- private final int time;
- public final boolean specialConditions;
-
- public UniversalRecipeOutput(FluidStack[] fluidOutputs1, Object[] itemOutputs1, int time1)
- {
- this(fluidOutputs1, itemOutputs1, time1,false);
- }
-
- public UniversalRecipeOutput(FluidStack[] fluidStacks, Object[] recipeOutputItemStacks, int time1, boolean specialConditions1)
- {
- if(fluidStacks!=null)
- {
- for(FluidStack fStack:fluidStacks)
- {
- if(fStack==null)
- {
- throw new NullPointerException("Recipe cannot contain null elements!");
- }
- fluidOutputs.add(fStack);
- }
- }
- if(recipeOutputItemStacks!=null)
- {
- for(Object io:recipeOutputItemStacks)
- {
- if(io==null)
- {
- throw new NullPointerException("Recipe output cannot be null!");
- }
- if(io instanceof ItemStack)
- {
- this.itemOutputs.add(new RecipeOutputItemStack((ItemStack) io));
- }
- else
- {
- this.itemOutputs.add((RecipeOutputItemStack) io);
- }
- }
- }
- specialConditions=specialConditions1;
- time=time1;
- }
-
- public UniversalRecipeOutput(List<FluidStack> recipeOutputsFluids,
- List<RecipeOutputItemStack> recipeOutputsRecipeOut, int time1) {
- this.fluidOutputs.addAll(recipeOutputsFluids);
- this.itemOutputs.addAll(recipeOutputsRecipeOut);
- this.time=time1;
- this.specialConditions=false;
- }
-
- public boolean matches(List<FluidStack> fluidOutputs1, List<ItemStack> itemOutputs1)
- {
- if(fluidOutputs.size()!=fluidOutputs1.size()||itemOutputs.size()!=itemOutputs.size())
- {
- return false;
- }
- Iterator<FluidStack> fi1 = fluidOutputs1.iterator();
- Iterator<ItemStack> ii1 = itemOutputs1.iterator();
- Iterator<FluidStack> fi = fluidOutputs.iterator();
- Iterator<RecipeOutputItemStack> ii = itemOutputs.iterator();
- while(fi.hasNext())
- {
- FluidStack fs = fi.next();
- FluidStack fs1 = fi1.next();
- if(fs.getFluid()!=fs1.getFluid())
- {
- return false;
- }
- }
- while(ii.hasNext())
- {
- RecipeOutputItemStack is = ii.next();
- ItemStack is1 = ii1.next();
- if(!is.matches(is1))
- {
- return false;
- }
- }
- return true;
- }
-
- public List<FluidStack> getFluidOutputs() {
- return fluidOutputs;
- }
-
- public List<RecipeOutputItemStack> getItemOutputs() {
- return itemOutputs;
- }
-
- public UniversalRecipeOutput copyWithMultiplier(int mulipier) {
- FluidStack[] fluidStacks = null;
- RecipeOutputItemStack[] itemStacks = null;
- if(fluidOutputs!=null && !fluidOutputs.isEmpty())
- {
- fluidStacks = new FluidStack[fluidOutputs.size()];
- for(int i=0;i<fluidOutputs.size();i++)
- {
- FluidStack fs = fluidOutputs.get(i);
- FluidStack newFs = fs.copy();
- newFs.amount*=mulipier;
- fluidStacks[i]=fs;
- }
- }
- if(itemOutputs!=null && !itemOutputs.isEmpty())
- {
- itemStacks = new RecipeOutputItemStack[itemOutputs.size()];
- for(int i=0;i<itemOutputs.size();i++)
- {
- RecipeOutputItemStack is = itemOutputs.get(i);
- RecipeOutputItemStack newIs = is.copy(mulipier);
- itemStacks[i]=newIs;
- }
- }
- return new UniversalRecipeOutput(fluidStacks,itemStacks, getTime(),false);
- }
-
- public int getTime() {
- return time;
- }
-
- @Override
- public String toString()
- {
- StringBuffer out = new StringBuffer();
- for(FluidStack fluid: this.fluidOutputs)
- {
- out.append(fluid.getLocalizedName()+": "+fluid.amount+"/n");
- }
- for(RecipeOutputItemStack stack: this.itemOutputs)
- {
- out.append(stack.itemStack.getDisplayName()+": "+stack.quantity+"/n");
- }
- return out.toString();
- }
-}