diff --git a/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml b/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml index 177d3331..127aa41f 100644 --- a/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml +++ b/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml @@ -145,25 +145,6 @@ - - - - - - - - - - - - - - - - - - - @@ -172,25 +153,6 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 3d1480c3..51459066 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -108,6 +108,7 @@ public final class Config { public static boolean useHardRecipes = false; public static boolean addPeacefulRecipes = false; public static boolean allowExternalTickSpeedup = true; + public static boolean crateSyntheticRecipes = true; public static boolean useSteelInChassi = false; @@ -622,6 +623,13 @@ public final class Config { "The number of conduits crafted per recipe.").getInt(numConduitsPerRecipe); transceiverUseEasyRecipe= config.get(sectionRecipe.name, "transceiverUseEasyRecipe", transceiverUseEasyRecipe, "When enabled the dim trans. will use a cheaper recipe") .getBoolean(useHardRecipes); + crateSyntheticRecipes = config + .get( + sectionRecipe.name, + "crateSyntheticRecipes", + crateSyntheticRecipes, + "Automatically create alloy smelter recipes with double and tripple inputs and different slot allocations (1+1+1, 2+1, 1+2, 3 and 2) for single-input recipes.") + .getBoolean(crateSyntheticRecipes); allowExternalTickSpeedup = config.get(sectionMisc.name, "allowExternalTickSpeedup", allowExternalTickSpeedup, "Allows machines to run faster if another mod speeds up the tickrate. Running at higher tickrates is " diff --git a/src/main/java/crazypants/enderio/machine/MachineRecipeRegistry.java b/src/main/java/crazypants/enderio/machine/MachineRecipeRegistry.java index 793111b8..4fea088e 100644 --- a/src/main/java/crazypants/enderio/machine/MachineRecipeRegistry.java +++ b/src/main/java/crazypants/enderio/machine/MachineRecipeRegistry.java @@ -3,6 +3,7 @@ package crazypants.enderio.machine; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -19,7 +20,7 @@ public class MachineRecipeRegistry { public Map getRecipesForMachine(String machineName) { Map res = machineRecipes.get(machineName); if(res == null) { - res = new HashMap(); + res = new LinkedHashMap(); machineRecipes.put(machineName, res); } return res; diff --git a/src/main/java/crazypants/enderio/machine/recipe/ManyToOneRecipeManager.java b/src/main/java/crazypants/enderio/machine/recipe/ManyToOneRecipeManager.java index fc92da7d..f41e2e96 100644 --- a/src/main/java/crazypants/enderio/machine/recipe/ManyToOneRecipeManager.java +++ b/src/main/java/crazypants/enderio/machine/recipe/ManyToOneRecipeManager.java @@ -77,7 +77,45 @@ public class ManyToOneRecipeManager { List newRecipes = config.getRecipes(false); Log.info("Found " + newRecipes.size() + " valid " + managerName + " recipes in config."); for (Recipe rec : newRecipes) { - addRecipe(new BasicManyToOneRecipe(rec)); + if (Config.crateSyntheticRecipes // + && rec.getInputs().length == 1 && !rec.getInputs()[0].isFluid() + && rec.getInputs()[0].getInput().stackSize <= 21 + && rec.getOutputs().length == 1 && !rec.getOutputs()[0].isFluid() // + && rec.getOutputs()[0].getOutput().stackSize <= 21) { + + IRecipe dupe = getRecipeForInputs(rec.getInputStacks()); + if (dupe != null) { + // do it here because we will add "dupes" and the check need to be + // done on the supplied recipe---which is added last + Log.warn("The supplied recipe " + rec + " for " + managerName + " may be a duplicate to: " + dupe); + } + + int er = rec.getEnergyRequired(); + RecipeBonusType bns = rec.getBonusType(); + RecipeOutput out = rec.getOutputs()[0]; + RecipeInput in = rec.getInputs()[0]; + + RecipeInput in2 = in.copy(); + in2.getInput().stackSize *= 2; + RecipeOutput out2 = new RecipeOutput(out.getOutput(), out.getChance(), out.getExperiance()); + out2.getOutput().stackSize *= 2; + + RecipeInput in3 = in.copy(); + in3.getInput().stackSize *= 3; + RecipeOutput out3 = new RecipeOutput(out.getOutput(), out.getChance(), out.getExperiance()); + out3.getOutput().stackSize *= 3; + + recipes.add(new BasicManyToOneRecipe(new Recipe(out3, er * 3, bns, new RecipeInput[] { in.copy(), in.copy(), in.copy() }))); + recipes.add(new BasicManyToOneRecipe(new Recipe(out3, er * 3, bns, new RecipeInput[] { in.copy(), in2.copy() }))); + recipes.add(new BasicManyToOneRecipe(new Recipe(out3, er * 3, bns, new RecipeInput[] { in2.copy(), in.copy() }))); + recipes.add(new BasicManyToOneRecipe(new Recipe(out2, er * 2, bns, new RecipeInput[] { in.copy(), in.copy() }))); + recipes.add(new BasicManyToOneRecipe(new Recipe(out3, er * 3, bns, new RecipeInput[] { in3.copy() }))); + recipes.add(new BasicManyToOneRecipe(new Recipe(out2, er * 2, bns, new RecipeInput[] { in2.copy() }))); + recipes.add(new BasicManyToOneRecipe(rec)); + Log.info("Created 6 synthetic recipes for " + in.getInput() + " => " + out.getOutput()); + } else { + addRecipe(new BasicManyToOneRecipe(rec)); + } } Log.info("Finished processing " + managerName + " recipes. " + recipes.size() + " recipes avaliable."); } @@ -89,8 +127,7 @@ public class ManyToOneRecipeManager { } IRecipe rec = getRecipeForInputs(recipe.getInputStacks()); if(rec != null) { - Log.warn("Not adding supplied recipe to " + managerName + " as a recipe already exists for the inputs: " + recipe); - return; + Log.warn("The supplied recipe " + recipe + " for " + managerName + " may be a duplicate to: " + rec); } recipes.add(recipe); } diff --git a/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java b/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java index cb269c50..9f7b04b6 100644 --- a/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java +++ b/src/main/java/crazypants/enderio/machine/recipe/OreDictionaryRecipeInput.java @@ -64,7 +64,8 @@ public class OreDictionaryRecipeInput extends RecipeInput { @Override public String toString() { - return "OreDictionaryRecipeInput [oreId=" + oreId + " name=" + OreDictionary.getOreName(oreId) + "]"; + return "OreDictionaryRecipeInput [oreId=" + oreId + " name=" + OreDictionary.getOreName(oreId) + " amount=" + + getInput().stackSize + "]"; } } diff --git a/src/main/java/crazypants/enderio/machine/recipe/RecipeConfig.java b/src/main/java/crazypants/enderio/machine/recipe/RecipeConfig.java index c174e6a8..8b321f04 100644 --- a/src/main/java/crazypants/enderio/machine/recipe/RecipeConfig.java +++ b/src/main/java/crazypants/enderio/machine/recipe/RecipeConfig.java @@ -11,6 +11,7 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -217,7 +218,7 @@ public class RecipeConfig { private final String name; - private Map recipes = new HashMap(); + private Map recipes = new LinkedHashMap(); private boolean enabled = true; @@ -288,6 +289,8 @@ public class RecipeConfig { private String name; + private boolean invalidated = false; + private RecipeElement(String name) { this.name = name; } @@ -322,7 +325,7 @@ public class RecipeConfig { } public boolean isValid() { - return !inputs.isEmpty() && !outputs.isEmpty(); + return !invalidated && !inputs.isEmpty() && !outputs.isEmpty(); } public float getEnergyRequired() { @@ -341,9 +344,14 @@ public class RecipeConfig { this.bonusType = bonusType; } + public void invalidate() { + invalidated = true; + } + @Override public String toString() { - return "Recipe [input=" + inputs + ", outputs=" + outputs + ", energyRequired=" + energyRequired + ", bonusType=" + bonusType + "]"; + return "Recipe [" + (invalidated ? "INVALID " : "") + "input=" + inputs + ", outputs=" + outputs + ", energyRequired=" + + energyRequired + ", bonusType=" + bonusType + "]"; } } diff --git a/src/main/java/crazypants/enderio/machine/recipe/RecipeConfigParser.java b/src/main/java/crazypants/enderio/machine/recipe/RecipeConfigParser.java index cffd72ab..fd31f38b 100644 --- a/src/main/java/crazypants/enderio/machine/recipe/RecipeConfigParser.java +++ b/src/main/java/crazypants/enderio/machine/recipe/RecipeConfigParser.java @@ -342,6 +342,7 @@ public class RecipeConfigParser extends DefaultHandler { private void addInputStack(Attributes attributes) { RecipeInput stack = getItemStack(attributes); if(stack == null) { + recipe.invalidate(); return; } recipe.addInput(stack); diff --git a/src/main/java/crazypants/enderio/nei/AlloySmelterRecipeHandler.java b/src/main/java/crazypants/enderio/nei/AlloySmelterRecipeHandler.java index b873a009..61d3d28d 100644 --- a/src/main/java/crazypants/enderio/nei/AlloySmelterRecipeHandler.java +++ b/src/main/java/crazypants/enderio/nei/AlloySmelterRecipeHandler.java @@ -7,12 +7,15 @@ import java.util.List; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; +import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; import com.enderio.core.client.render.EnderWidget; +import com.enderio.core.common.util.ItemUtil; import codechicken.lib.gui.GuiDraw; +import codechicken.nei.ItemList; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; import crazypants.enderio.gui.IconEIO; @@ -122,11 +125,39 @@ public class AlloySmelterRecipeHandler extends TemplateRecipeHandler { result.add(input.getInput()); ItemStack[] equivs = input.getEquivelentInputs(); if(equivs != null) { - for (ItemStack st : equivs) { - result.add(st); + for (ItemStack item : equivs) { + if (item.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + List permutations = ItemList.itemMap.get(item.getItem()); + if (permutations.isEmpty()) { + ItemStack base = new ItemStack(item.getItem(), item.stackSize); + base.stackTagCompound = item.stackTagCompound; + result.add(base); + } else { + for (ItemStack stack : permutations) { + ItemStack perm = stack.copy(); + perm.stackSize = item.stackSize; + result.add(perm); + } + } + } else { + result.add(item.copy()); + } } + List result2 = new ArrayList(); + for (ItemStack candidate : result) { + boolean skip = false; + for (ItemStack existing : result2) { + skip = skip || ItemUtil.areStacksEqual(candidate, existing); + } + if (!skip) { + System.out.println("Adding " + candidate + " for " + input); + result2.add(candidate); + } + } + return result2; + } else { + return result; } - return result; } public class AlloySmelterRecipe extends TemplateRecipeHandler.CachedRecipe {