From dc3df3edd5843bde0c1335d6a8e460b2c832aa48 Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Sat, 17 Jun 2017 08:12:18 +0300 Subject: full project files --- ihl/recipes/IRecipeInputFluid.java | 11 -- ihl/recipes/IronWorkbenchRecipe.java | 214 -------------------------- ihl/recipes/RecipeInputDetonator.java | 73 --------- ihl/recipes/RecipeInputDie.java | 97 ------------ ihl/recipes/RecipeInputFluidDictionary.java | 46 ------ ihl/recipes/RecipeInputFluidStack.java | 45 ------ ihl/recipes/RecipeInputObjectInstance.java | 44 ------ ihl/recipes/RecipeInputOreDictionaryList.java | 122 --------------- ihl/recipes/RecipeInputWire.java | 72 --------- ihl/recipes/RecipeOutputItemStack.java | 52 ------- ihl/recipes/UniversalRecipeInput.java | 205 ------------------------ ihl/recipes/UniversalRecipeManager.java | 195 ----------------------- ihl/recipes/UniversalRecipeOutput.java | 149 ------------------ 13 files changed, 1325 deletions(-) delete mode 100644 ihl/recipes/IRecipeInputFluid.java delete mode 100644 ihl/recipes/IronWorkbenchRecipe.java delete mode 100644 ihl/recipes/RecipeInputDetonator.java delete mode 100644 ihl/recipes/RecipeInputDie.java delete mode 100644 ihl/recipes/RecipeInputFluidDictionary.java delete mode 100644 ihl/recipes/RecipeInputFluidStack.java delete mode 100644 ihl/recipes/RecipeInputObjectInstance.java delete mode 100644 ihl/recipes/RecipeInputOreDictionaryList.java delete mode 100644 ihl/recipes/RecipeInputWire.java delete mode 100644 ihl/recipes/RecipeOutputItemStack.java delete mode 100644 ihl/recipes/UniversalRecipeInput.java delete mode 100644 ihl/recipes/UniversalRecipeManager.java delete mode 100644 ihl/recipes/UniversalRecipeOutput.java (limited to 'ihl/recipes') 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 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 workspaceElements=new ArrayList(); - public List tools=new ArrayList(); - public List materials=new ArrayList(); - public List outputs = new ArrayList(); - - public IronWorkbenchRecipe(List tools1, List materials1, List 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 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 asList3, List 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 i1 = tools.iterator(); - while(i1.hasNext()) - { - IRecipeInput tool = i1.next(); - if(tool.matches(tool1)) - { - return true; - } - } - } - return false; - } - - public boolean isCanBeCrafted(List tools1, List materials1, List workspaceElements1) - { - if(workspaceElements!=null && !workspaceElements.isEmpty()) - { - if(workspaceElements1==null||workspaceElements1.isEmpty()) - { - return false; - } - Iterator 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 i1 = tools.iterator(); - while(i1.hasNext()) - { - IRecipeInput tool = i1.next(); - if(!this.isItemStackInList(tool, tools1)) - { - return false; - } - } - } - if(materials!=null && !materials.isEmpty()) - { - Iterator 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 tools1) { - Iterator 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 tools1) - { - Iterator 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 getInputs() - { - return Arrays.asList(new ItemStack[] {this.input}); - } - - @Override - public String toString() - { - ItemStack stack = this.input.copy(); - return "RInputDice<" + stack + ">"; - } - - public List transformOutput(ItemStack matchedItemStack, List outputs) - { - List newOutputs = new ArrayList(); - 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 getInputs() - { - return Arrays.asList(new ItemStack[] {this.input}); - } - - @Override - public String toString() - { - ItemStack stack = this.input.copy(); - return "RInputDice<" + stack + ">"; - } - - public List transformOutput(ItemStack matchedItemStack, List outputs) - { - List newOutputs = new ArrayList(); - 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 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 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 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 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 inputs = this.getOres(); - boolean useOreStackMeta = this.meta == null; - Item subjectItem = subject.getItem(); - int subjectMeta = subject.getItemDamage(); - Iterator 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 getInputs() { - List ores = this.getOres(); - boolean hasInvalidEntries = false; - Iterator ret = ores.iterator(); - - while (ret.hasNext()) { - ItemStack i$ = ret.next(); - - if (i$.getItem() == null) { - hasInvalidEntries = true; - break; - } - } - - if (!hasInvalidEntries) { - return ores; - } else { - ArrayList ret1 = new ArrayList(ores.size()); - Iterator 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 getOres() { - if (this.ores != null) { - return this.ores; - } else { - this.ores = new ArrayList(); - for (int i = 0; i < this.input.length; i++) { - ArrayList 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 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 fluidInputs = new ArrayList(); - private final List itemInputs = new ArrayList(); - - 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 sortMap = new HashMap(); - int[] keysArray = new int[fluidInputs.size()]; - Iterator 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 newFluidList = new ArrayList(); - 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 fluidInputs1, List itemInputs1) { - return this.matches(fluidInputs1, itemInputs1, false); - } - - public List getFluidInputs() { - return fluidInputs; - } - - public List getItemInputs() { - return itemInputs; - } - - public boolean matches(UniversalRecipeInput input) { - 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.matches(rInputsFluids, rInputsItems); - } - - public boolean matches(List fluidInputs1, List itemInputs1, boolean doCheckAmounts) { - if (incorrectInputAmount(fluidInputs1, itemInputs1)) { - return false; - } - if (fluidInputs1 != null) { - Iterator 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 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 itemInputs1) { - for (ItemStack is1 : itemInputs1) { - if (is1 != null) { - if (is.matches(is1)) { - return is1; - } - } - } - return null; - } - - private FluidStack getMatchedFluidStack(IRecipeInputFluid fs, List 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 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 ii = fluidInputs.iterator(); - while (ii.hasNext()) { - IRecipeInputFluid is = ii.next(); - if (is != null && is.matches(fluidStack)) { - return true; - } - } - return false; - } - - private boolean incorrectInputAmount(List fluidInputs1, List 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 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!"); - } - 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) { - 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.matches(fluidInputs, itemInputs, true)) { - return entry.getValue(); - } - } - - 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.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 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; - } - } - } - } - - 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(); - } - } - } - - public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) { - List fluidOutputs = out.getFluidOutputs(); - List itemOutputs = out.getItemOutputs(); - if (!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) { - FluidStack fs1 = out1.getFluidOutputs().get(0); - Iterator 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 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 fluidOutputs=new ArrayList(); - private final List itemOutputs=new ArrayList(); - 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 recipeOutputsFluids, - List recipeOutputsRecipeOut, int time1) { - this.fluidOutputs.addAll(recipeOutputsFluids); - this.itemOutputs.addAll(recipeOutputsRecipeOut); - this.time=time1; - this.specialConditions=false; - } - - public boolean matches(List fluidOutputs1, List itemOutputs1) - { - if(fluidOutputs.size()!=fluidOutputs1.size()||itemOutputs.size()!=itemOutputs.size()) - { - return false; - } - Iterator fi1 = fluidOutputs1.iterator(); - Iterator ii1 = itemOutputs1.iterator(); - Iterator fi = fluidOutputs.iterator(); - Iterator 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 getFluidOutputs() { - return fluidOutputs; - } - - public List 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