From ce6946c669943f17afd49ca8b043687f159c20d2 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Thu, 4 Sep 2014 04:26:55 +0100 Subject: [PATCH] Massive recipe system overhaul. They should be much more efficient now (this reduced the tick time of the CI Chamber by 3-4x in my testing), due to being able to just use the HashMap's get() instead of being limited to iterating through entries. NEI integration code now a lot more readable and type-safe as well. --- src/main/java/mekanism/api/gas/GasStack.java | 6 + .../mekanism/api/recipe/AdvancedInput.java | 29 -- .../api/recipe/PressurizedRecipe.java | 25 -- .../mekanism/api/recipe/RecipeHelper.java | 77 ++-- .../java/mekanism/api/util/StackUtils.java | 10 + .../nei/AdvancedMachineRecipeHandler.java | 36 +- .../nei/ChanceMachineRecipeHandler.java | 23 +- .../ChemicalCrystallizerRecipeHandler.java | 20 +- ...emicalDissolutionChamberRecipeHandler.java | 20 +- .../nei/ChemicalInfuserRecipeHandler.java | 26 +- ...ChemicalInjectionChamberRecipeHandler.java | 6 +- .../nei/ChemicalOxidizerRecipeHandler.java | 20 +- .../nei/ChemicalWasherRecipeHandler.java | 22 +- .../client/nei/CombinerRecipeHandler.java | 6 +- .../client/nei/CrusherRecipeHandler.java | 6 +- .../ElectrolyticSeparatorRecipeHandler.java | 14 +- .../nei/EnrichmentChamberRecipeHandler.java | 6 +- .../client/nei/MachineRecipeHandler.java | 18 +- .../nei/MetallurgicInfuserRecipeHandler.java | 4 +- .../nei/OsmiumCompressorRecipeHandler.java | 6 +- .../mekanism/client/nei/PRCRecipeHandler.java | 42 +- .../nei/PrecisionSawmillRecipeHandler.java | 7 +- .../nei/PurificationChamberRecipeHandler.java | 6 +- src/main/java/mekanism/common/Mekanism.java | 80 ++-- .../java/mekanism/common/base/IFactory.java | 8 +- .../mekanism/common/block/BlockBasic.java | 22 +- .../common/integration/OreDictManager.java | 51 ++- .../ContainerAdvancedElectricMachine.java | 4 +- .../ContainerChemicalDissolutionChamber.java | 2 +- .../container/ContainerChemicalOxidizer.java | 2 +- .../ContainerMetallurgicInfuser.java | 2 +- .../mekanism/common/recipe/RecipeHandler.java | 368 ++++++++++++------ .../recipe/inputs/AdvancedMachineInput.java | 41 ++ .../recipe/inputs/ChemicalPairInput.java | 134 +++++++ .../common/recipe/inputs/FluidInput.java | 25 ++ .../common/recipe/inputs/GasInput.java | 25 ++ .../recipe/inputs}/InfusionInput.java | 24 +- .../common/recipe/inputs/IntegerInput.java | 24 ++ .../common/recipe/inputs/ItemStackInput.java | 27 ++ .../common/recipe/inputs/MachineInput.java | 34 ++ .../recipe/inputs}/PressurizedReactants.java | 23 +- .../machines/AdvancedMachineRecipe.java | 21 + .../recipe/machines/AmbientGasRecipe.java | 14 + .../recipe/machines/BasicMachineRecipe.java | 14 + .../recipe/machines/ChanceMachineRecipe.java | 12 + .../machines/ChemicalInfuserRecipe.java | 13 + .../recipe/machines/CombinerRecipe.java | 11 + .../common/recipe/machines/CrusherRecipe.java | 11 + .../recipe/machines/CrystallizerRecipe.java | 15 + .../recipe/machines/DissolutionRecipe.java | 15 + .../recipe/machines/EnrichmentRecipe.java | 11 + .../recipe/machines/InjectionRecipe.java | 11 + .../common/recipe/machines/MachineRecipe.java | 26 ++ .../machines/MetallurgicInfuserRecipe.java | 14 + .../machines/OsmiumCompressorRecipe.java | 11 + .../recipe/machines/OxidationRecipe.java | 15 + .../recipe/machines/PressurizedRecipe.java | 33 ++ .../recipe/machines/PurificationRecipe.java | 11 + .../common/recipe/machines/SawmillRecipe.java | 19 + .../recipe/machines/SeparatorRecipe.java | 15 + .../common/recipe/machines/WasherRecipe.java | 13 + .../recipe/outputs}/ChanceOutput.java | 4 +- .../recipe/outputs/ChemicalPairOutput.java} | 22 +- .../common/recipe/outputs/GasOutput.java | 13 + .../recipe/outputs}/InfusionOutput.java | 6 +- .../recipe/outputs/ItemStackOutput.java | 13 + .../common/recipe/outputs/MachineOutput.java | 5 + .../recipe/outputs}/PressurizedProducts.java | 4 +- .../common/recipe/outputs/StringOutput.java | 5 + .../TileEntityAdvancedElectricMachine.java | 10 +- .../tile/TileEntityAmbientAccumulator.java | 24 +- .../common/tile/TileEntityChanceMachine.java | 2 +- .../TileEntityChemicalDissolutionChamber.java | 6 +- .../tile/TileEntityChemicalOxidizer.java | 6 +- .../tile/TileEntityElectrolyticSeparator.java | 8 +- .../tile/TileEntityMetallurgicInfuser.java | 4 +- .../mekanism/common/tile/TileEntityPRC.java | 12 +- 77 files changed, 1294 insertions(+), 486 deletions(-) delete mode 100644 src/main/java/mekanism/api/recipe/AdvancedInput.java delete mode 100644 src/main/java/mekanism/api/recipe/PressurizedRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java create mode 100644 src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java create mode 100644 src/main/java/mekanism/common/recipe/inputs/FluidInput.java create mode 100644 src/main/java/mekanism/common/recipe/inputs/GasInput.java rename src/main/java/mekanism/{api/infuse => common/recipe/inputs}/InfusionInput.java (55%) create mode 100644 src/main/java/mekanism/common/recipe/inputs/IntegerInput.java create mode 100644 src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java create mode 100644 src/main/java/mekanism/common/recipe/inputs/MachineInput.java rename src/main/java/mekanism/{api/recipe => common/recipe/inputs}/PressurizedReactants.java (85%) create mode 100644 src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/MachineRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java create mode 100644 src/main/java/mekanism/common/recipe/machines/WasherRecipe.java rename src/main/java/mekanism/{api/recipe => common/recipe/outputs}/ChanceOutput.java (90%) rename src/main/java/mekanism/{api/recipe/ChemicalPair.java => common/recipe/outputs/ChemicalPairOutput.java} (79%) create mode 100644 src/main/java/mekanism/common/recipe/outputs/GasOutput.java rename src/main/java/mekanism/{api/infuse => common/recipe/outputs}/InfusionOutput.java (83%) create mode 100644 src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java create mode 100644 src/main/java/mekanism/common/recipe/outputs/MachineOutput.java rename src/main/java/mekanism/{api/recipe => common/recipe/outputs}/PressurizedProducts.java (89%) create mode 100644 src/main/java/mekanism/common/recipe/outputs/StringOutput.java diff --git a/src/main/java/mekanism/api/gas/GasStack.java b/src/main/java/mekanism/api/gas/GasStack.java index 8002139f6..ec1549163 100644 --- a/src/main/java/mekanism/api/gas/GasStack.java +++ b/src/main/java/mekanism/api/gas/GasStack.java @@ -116,4 +116,10 @@ public class GasStack { return "[" + type + ", " + amount + "]"; } + + @Override + public int hashCode() + { + return type == null ? 0 : type.getID(); + } } diff --git a/src/main/java/mekanism/api/recipe/AdvancedInput.java b/src/main/java/mekanism/api/recipe/AdvancedInput.java deleted file mode 100644 index 240b76e45..000000000 --- a/src/main/java/mekanism/api/recipe/AdvancedInput.java +++ /dev/null @@ -1,29 +0,0 @@ -package mekanism.api.recipe; - -import mekanism.api.gas.Gas; -import mekanism.api.util.StackUtils; - -import net.minecraft.item.ItemStack; - -public class AdvancedInput -{ - public ItemStack itemStack; - - public Gas gasType; - - public AdvancedInput(ItemStack item, Gas gas) - { - itemStack = item; - gasType = gas; - } - - public boolean isValid() - { - return itemStack != null && gasType != null; - } - - public boolean matches(AdvancedInput input) - { - return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize; - } -} diff --git a/src/main/java/mekanism/api/recipe/PressurizedRecipe.java b/src/main/java/mekanism/api/recipe/PressurizedRecipe.java deleted file mode 100644 index 0478efcc1..000000000 --- a/src/main/java/mekanism/api/recipe/PressurizedRecipe.java +++ /dev/null @@ -1,25 +0,0 @@ -package mekanism.api.recipe; - -public class PressurizedRecipe -{ - public PressurizedReactants reactants; - - public double extraEnergy; - - public PressurizedProducts products; - - public int ticks; - - public PressurizedRecipe(PressurizedReactants pressurizedReactants, double energy, PressurizedProducts pressurizedProducts, int duration) - { - reactants = pressurizedReactants; - extraEnergy = energy; - products = pressurizedProducts; - ticks = duration; - } - - public PressurizedRecipe copy() - { - return new PressurizedRecipe(reactants.copy(), extraEnergy, products.copy(), ticks); - } -} diff --git a/src/main/java/mekanism/api/recipe/RecipeHelper.java b/src/main/java/mekanism/api/recipe/RecipeHelper.java index f40aa746b..a9c59e23d 100644 --- a/src/main/java/mekanism/api/recipe/RecipeHelper.java +++ b/src/main/java/mekanism/api/recipe/RecipeHelper.java @@ -3,7 +3,7 @@ package mekanism.api.recipe; import java.lang.reflect.Method; import mekanism.api.gas.GasStack; -import mekanism.api.infuse.InfusionInput; +import mekanism.api.infuse.InfuseType; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -113,15 +113,16 @@ public final class RecipeHelper /** * Add a Chemical Infuser recipe. - * @param input - input ChemicalInput + * @param leftInput - left input GasStack + * @param rightInput - right input GasStack * @param output - output GasStack */ - public static void addChemicalInfuserRecipe(ChemicalPair input, GasStack output) + public static void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) { try { Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInfuserRecipe", ChemicalPair.class, GasStack.class); - m.invoke(null, input, output); + Method m = recipeClass.getMethod("addChemicalInfuserRecipe", GasStack.class, GasStack.class, GasStack.class); + m.invoke(null, leftInput, rightInput, output); } catch(Exception e) { System.err.println("Error while adding recipe: " + e.getMessage()); } @@ -130,14 +131,32 @@ public final class RecipeHelper /** * Add a Precision Sawmill recipe. * @param input - input ItemStack - * @param output - output ChanceOutput + * @param primaryOutput - guaranteed output + * @param secondaryOutput - possible extra output + * @param chance - probability of obtaining extra output */ - public static void addPrecisionSawmillRecipe(ItemStack input, ChanceOutput output) + public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) { try { Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ChanceOutput.class); - m.invoke(null, input, output); + Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class, ItemStack.class, Double.TYPE); + m.invoke(null, input, primaryOutput, secondaryOutput, chance); + } catch(Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Precision Sawmill recipe with no chance output + * @param input - input ItemStack + * @param primaryOutput - guaranteed output + */ + public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) + { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class); + m.invoke(null, input, primaryOutput); } catch(Exception e) { System.err.println("Error while adding recipe: " + e.getMessage()); } @@ -148,12 +167,12 @@ public final class RecipeHelper * @param input - input AdvancedInput * @param output - output ItemStack */ - public static void addChemicalInjectionChamberRecipe(AdvancedInput input, ItemStack output) + public static void addChemicalInjectionChamberRecipe(ItemStack input, String gasName, ItemStack output) { try { Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInjectionChamberRecipe", AdvancedInput.class, ItemStack.class); - m.invoke(null, input, output); + Method m = recipeClass.getMethod("addChemicalInjectionChamberRecipe", ItemStack.class, String.class, ItemStack.class); + m.invoke(null, input, gasName, output); } catch(Exception e) { System.err.println("Error while adding recipe: " + e.getMessage()); } @@ -162,14 +181,15 @@ public final class RecipeHelper /** * Add an Electrolytic Separator recipe. * @param input - input FluidStack - * @param output - output ChemicalPair + * @param leftOutput - left output GasStack + * @param rightOutput - right output GasStack */ - public static void addElectrolyticSeparatorRecipe(FluidStack input, ChemicalPair output) + public static void addElectrolyticSeparatorRecipe(FluidStack input, GasStack leftOutput, GasStack rightOutput) { try { Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addElectrolyticSeparatorRecipe", FluidStack.class, ChemicalPair.class); - m.invoke(null, input, output); + Method m = recipeClass.getMethod("addElectrolyticSeparatorRecipe", FluidStack.class, GasStack.class, GasStack.class); + m.invoke(null, input, leftOutput, rightOutput); } catch(Exception e) { System.err.println("Error while adding recipe: " + e.getMessage()); } @@ -225,33 +245,38 @@ public final class RecipeHelper /** * Add a Metallurgic Infuser recipe. - * @param input - input Infusion + * @param infuse - which Infuse to use + * @param amount - how much Infuse to use + * @param input - input ItemStack * @param output - output ItemStack */ - public static void addMetallurgicInfuserRecipe(InfusionInput input, ItemStack output) + public static void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) { try { Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfusionInput.class, ItemStack.class); - m.invoke(null, input, output); + Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfuseType.class, Integer.TYPE, ItemStack.class, ItemStack.class); + m.invoke(null, infuse, amount, input, output); } catch(Exception e) { System.err.println("Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Pressurized Reaction Chamber recipe. - * @param input - input PressurizedReactants - * @param output - output PressurizedProducts + * @param inputSolid - input ItemStack + * @param inputFluid - input FluidStack + * @param inputGas - input GasStack + * @param outputSolid - output ItemStack + * @param outputGas - output GasStack * @param extraEnergy - extra energy needed by the recipe * @param ticks - amount of ticks it takes for this recipe to complete */ - public static void addPRCRecipe(PressurizedReactants input, PressurizedProducts output, double extraEnergy, int ticks) + public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) { try { Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPRCRecipe", PressurizedReactants.class, PressurizedProducts.class, Double.TYPE, Integer.TYPE); - m.invoke(null, input, output); + Method m = recipeClass.getMethod("addPRCRecipe", ItemStack.class, FluidStack.class, GasStack.class, ItemStack.class, GasStack.class, Double.TYPE, Integer.TYPE); + m.invoke(null, inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks); } catch(Exception e) { System.err.println("Error while adding recipe: " + e.getMessage()); } diff --git a/src/main/java/mekanism/api/util/StackUtils.java b/src/main/java/mekanism/api/util/StackUtils.java index 00d743d61..885bf3449 100644 --- a/src/main/java/mekanism/api/util/StackUtils.java +++ b/src/main/java/mekanism/api/util/StackUtils.java @@ -58,6 +58,11 @@ public final class StackUtils return wild.getItem() == check.getItem() && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check.getItemDamage()); } + public static boolean equalsWildcardWithNBT(ItemStack wild, ItemStack check) + { + return equalsWildcard(wild, check) && (wild.stackTagCompound == null ? check.stackTagCompound == null : (wild.stackTagCompound == check.stackTagCompound || wild.stackTagCompound.equals(check.stackTagCompound))); + } + public static List even(ItemStack stack1, ItemStack stack2) { ArrayList ret = new ArrayList(); @@ -225,4 +230,9 @@ public final class StackUtils return StackUtils.size(orig, newSize); } } + + public static int hashItemStack(ItemStack stack) + { + return Item.getIdFromItem(stack.getItem()) << 8 | stack.getItemDamage(); + } } diff --git a/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java b/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java index 11750ba02..54ddece84 100644 --- a/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -8,7 +9,7 @@ import java.util.Set; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; -import mekanism.api.recipe.AdvancedInput; +import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.client.gui.GuiElement; import mekanism.client.gui.GuiPowerBar; import mekanism.client.gui.GuiPowerBar.IPowerInfoHandler; @@ -19,6 +20,7 @@ import mekanism.client.gui.GuiSlot; import mekanism.client.gui.GuiSlot.SlotOverlay; import mekanism.client.gui.GuiSlot.SlotType; import mekanism.common.ObfuscatedNames; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -43,7 +45,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler public abstract String getRecipeId(); - public abstract Set> getRecipes(); + public abstract Collection getRecipes(); public abstract List getFuelStacks(Gas gasType); @@ -117,9 +119,9 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(AdvancedMachineRecipe irecipe : getRecipes()) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); } } else { @@ -130,11 +132,11 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler @Override public void loadCraftingRecipes(ItemStack result) { - for(Map.Entry irecipe : getRecipes()) + for(AdvancedMachineRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); } } } @@ -150,11 +152,11 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(AdvancedMachineRecipe irecipe : getRecipes()) { - if(irecipe.getKey().gasType == ((GasStack)ingredients[0]).getGas()) + if(irecipe.getInput().gasType == ((GasStack)ingredients[0]).getGas()) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); } } } @@ -166,11 +168,11 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler @Override public void loadUsageRecipes(ItemStack ingredient) { - for(Map.Entry irecipe : getRecipes()) + for(AdvancedMachineRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getKey().itemStack, ingredient)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().itemStack, ingredient)) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); } } } @@ -270,7 +272,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { public List fuelStacks; - public AdvancedInput input; + public AdvancedMachineInput input; public PositionedStack outputStack; @@ -292,16 +294,16 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler return new PositionedStack(fuelStacks.get(cycleticks/40 % fuelStacks.size()), 40, 48); } - public CachedIORecipe(AdvancedInput adv, ItemStack output, List fuels) + public CachedIORecipe(AdvancedMachineInput adv, ItemStack output, List fuels) { input = adv; outputStack = new PositionedStack(output, 100, 30); fuelStacks = fuels; } - public CachedIORecipe(Map.Entry recipe, List fuels) + public CachedIORecipe(AdvancedMachineRecipe recipe, List fuels) { - this((AdvancedInput)recipe.getKey(), (ItemStack)recipe.getValue(), fuels); + this(recipe.getInput(), recipe.getOutput().output, fuels); } } } diff --git a/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java b/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java index 483fcff28..c558f428a 100644 --- a/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java @@ -1,11 +1,14 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import mekanism.api.recipe.ChanceOutput; +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.machines.ChanceMachineRecipe; +import mekanism.common.recipe.outputs.ChanceOutput; import mekanism.client.gui.GuiElement; import mekanism.client.gui.GuiPowerBar; import mekanism.client.gui.GuiPowerBar.IPowerInfoHandler; @@ -36,7 +39,7 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler public abstract String getRecipeId(); - public abstract Set> getRecipes(); + public abstract Collection getRecipes(); public abstract ProgressBar getProgressType(); @@ -106,7 +109,7 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(ChanceMachineRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -119,13 +122,13 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler @Override public void loadCraftingRecipes(ItemStack result) { - for(Map.Entry irecipe : getRecipes()) + for(ChanceMachineRecipe irecipe : getRecipes()) { - if(irecipe.getValue().hasPrimary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().primaryOutput, result)) + if(irecipe.getOutput().hasPrimary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().primaryOutput, result)) { arecipes.add(new CachedIORecipe(irecipe)); } - else if(irecipe.getValue().hasSecondary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().secondaryOutput, result)) + else if(irecipe.getOutput().hasSecondary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().secondaryOutput, result)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -141,9 +144,9 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler @Override public void loadUsageRecipes(ItemStack ingredient) { - for(Map.Entry irecipe : getRecipes()) + for(ChanceMachineRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) + if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getInput().ingredient, ingredient)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -189,9 +192,9 @@ public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler output = chance; } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(ChanceMachineRecipe recipe) { - this((ItemStack)recipe.getKey(), (ChanceOutput)recipe.getValue()); + this(recipe.getInput().ingredient, recipe.getOutput()); } } } diff --git a/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java index 9798418ad..7e809e17c 100644 --- a/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -10,6 +11,7 @@ import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalCrystallizer; import mekanism.common.ObfuscatedNames; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.CrystallizerRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; @@ -63,9 +65,9 @@ public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler return "mekanism.chemicalcrystallizer"; } - public Set> getRecipes() + public Collection getRecipes() { - return Recipe.CHEMICAL_CRYSTALLIZER.get().entrySet(); + return Recipe.CHEMICAL_CRYSTALLIZER.get().values(); } @Override @@ -109,7 +111,7 @@ public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(CrystallizerRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -122,9 +124,9 @@ public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler @Override public void loadCraftingRecipes(ItemStack result) { - for(Map.Entry irecipe : getRecipes()) + for(CrystallizerRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -230,9 +232,9 @@ public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler { if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(CrystallizerRecipe irecipe : getRecipes()) { - if(irecipe.getKey().isGasEqual((GasStack)ingredients[0])) + if(irecipe.getInput().ingredient.isGasEqual((GasStack)ingredients[0])) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -266,9 +268,9 @@ public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler outputStack = new PositionedStack(output, 131-xOffset, 57-yOffset); } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(CrystallizerRecipe recipe) { - this((GasStack)recipe.getKey(), (ItemStack)recipe.getValue()); + this(recipe.getInput().ingredient, recipe.getOutput().output); } } } diff --git a/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java index 2262797fe..9d78132d3 100644 --- a/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -11,6 +12,7 @@ import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalDissolutionChamber; import mekanism.common.ObfuscatedNames; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.DissolutionRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; @@ -64,9 +66,9 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler return "mekanism.chemicaldissolutionchamber"; } - public Set> getRecipes() + public Collection getRecipes() { - return Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().entrySet(); + return Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().values(); } @Override @@ -112,16 +114,16 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(DissolutionRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } } else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(DissolutionRecipe irecipe : getRecipes()) { - if(((GasStack)results[0]).isGasEqual(irecipe.getValue())) + if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -241,9 +243,9 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler @Override public void loadUsageRecipes(ItemStack ingredient) { - for(Map.Entry irecipe : getRecipes()) + for(DissolutionRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) + if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getInput().ingredient, ingredient)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -279,9 +281,9 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler outputStack = output; } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(DissolutionRecipe recipe) { - this((ItemStack)recipe.getKey(), (GasStack)recipe.getValue()); + this(recipe.getInput().ingredient, recipe.getOutput().output); } } } diff --git a/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java index 1e0d60eb0..3de0afeac 100644 --- a/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java @@ -1,16 +1,18 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import mekanism.api.gas.GasStack; -import mekanism.api.recipe.ChemicalPair; +import mekanism.common.recipe.inputs.ChemicalPairInput; import mekanism.client.gui.GuiChemicalInfuser; import mekanism.common.ObfuscatedNames; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; @@ -62,9 +64,9 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler return "mekanism.chemicalinfuser"; } - public Set> getRecipes() + public Collection getRecipes() { - return Recipe.CHEMICAL_INFUSER.get().entrySet(); + return Recipe.CHEMICAL_INFUSER.get().values(); } @Override @@ -119,16 +121,16 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(ChemicalInfuserRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } } else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(ChemicalInfuserRecipe irecipe : getRecipes()) { - if(((GasStack)results[0]).isGasEqual(irecipe.getValue())) + if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -144,9 +146,9 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(ChemicalInfuserRecipe irecipe : getRecipes()) { - if(irecipe.getKey().containsType((GasStack)ingredients[0])) + if(irecipe.getInput().containsType((GasStack)ingredients[0])) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -283,7 +285,7 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { - public ChemicalPair chemicalInput; + public ChemicalPairInput chemicalInput; public GasStack outputStack; @Override @@ -292,15 +294,15 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler return null; } - public CachedIORecipe(ChemicalPair input, GasStack output) + public CachedIORecipe(ChemicalPairInput input, GasStack output) { chemicalInput = input; outputStack = output; } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(ChemicalInfuserRecipe recipe) { - this((ChemicalPair)recipe.getKey(), (GasStack)recipe.getValue()); + this(recipe.getInput(), recipe.getOutput().output); } } } diff --git a/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java index 7ccc736a4..5a74ae3b3 100644 --- a/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -10,6 +11,7 @@ import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiChemicalInjectionChamber; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.InjectionRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; @@ -36,9 +38,9 @@ public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipe } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.CHEMICAL_INJECTION_CHAMBER.get().entrySet(); + return Recipe.CHEMICAL_INJECTION_CHAMBER.get().values(); } @Override diff --git a/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java index c76772352..d42c4b2d1 100644 --- a/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -19,6 +20,7 @@ import mekanism.client.gui.GuiSlot.SlotOverlay; import mekanism.client.gui.GuiSlot.SlotType; import mekanism.common.ObfuscatedNames; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.OxidationRecipe; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -94,9 +96,9 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler return "mekanism.chemicaloxidizer"; } - public Set> getRecipes() + public Collection getRecipes() { - return Recipe.CHEMICAL_OXIDIZER.get().entrySet(); + return Recipe.CHEMICAL_OXIDIZER.get().values(); } @Override @@ -143,16 +145,16 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(OxidationRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } } else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(OxidationRecipe irecipe : getRecipes()) { - if(((GasStack)results[0]).isGasEqual(irecipe.getValue())) + if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -253,9 +255,9 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler @Override public void loadUsageRecipes(ItemStack ingredient) { - for(Map.Entry irecipe : getRecipes()) + for(OxidationRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().ingredient, ingredient)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -285,9 +287,9 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler outputStack = output; } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(OxidationRecipe recipe) { - this((ItemStack)recipe.getKey(), (GasStack)recipe.getValue()); + this(recipe.getInput().ingredient, recipe.getOutput().output); } } } diff --git a/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java index df2d77892..7028835d5 100644 --- a/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -10,6 +11,7 @@ import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalWasher; import mekanism.common.ObfuscatedNames; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.WasherRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; @@ -63,9 +65,9 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler return "mekanism.chemicalwasher"; } - public Set> getRecipes() + public Collection getRecipes() { - return Recipe.CHEMICAL_WASHER.get().entrySet(); + return Recipe.CHEMICAL_WASHER.get().values(); } @Override @@ -115,16 +117,16 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(WasherRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } } else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(WasherRecipe irecipe : getRecipes()) { - if(((GasStack)results[0]).isGasEqual(irecipe.getValue())) + if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -142,7 +144,7 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { if(((FluidStack)ingredients[0]).getFluid() == FluidRegistry.WATER) { - for(Map.Entry irecipe : getRecipes()) + for(WasherRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -150,9 +152,9 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler } else if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(WasherRecipe irecipe : getRecipes()) { - if(irecipe.getKey().isGasEqual((GasStack)ingredients[0])) + if(irecipe.getOutput().output.isGasEqual((GasStack)ingredients[0])) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -340,9 +342,9 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler outputStack = output; } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(WasherRecipe recipe) { - this((GasStack)recipe.getKey(), (GasStack)recipe.getValue()); + this(recipe.getInput().ingredient, recipe.getOutput().output); } } } diff --git a/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java b/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java index 2769fc8bc..3763ec59f 100644 --- a/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java @@ -1,5 +1,6 @@ package mekanism.client.nei; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -8,6 +9,7 @@ import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiCombiner; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.CombinerRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.init.Blocks; @@ -34,9 +36,9 @@ public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.COMBINER.get().entrySet(); + return Recipe.COMBINER.get().values(); } @Override diff --git a/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java b/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java index a292e27b8..b98fc7c7f 100644 --- a/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java @@ -1,10 +1,12 @@ package mekanism.client.nei; +import java.util.Collection; import java.util.Set; import mekanism.client.gui.GuiCrusher; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.CrusherRecipe; import mekanism.common.util.MekanismUtils; public class CrusherRecipeHandler extends MachineRecipeHandler @@ -34,9 +36,9 @@ public class CrusherRecipeHandler extends MachineRecipeHandler } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.CRUSHER.get().entrySet(); + return Recipe.CRUSHER.get().values(); } @Override diff --git a/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java b/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java index a79ab3b4e..3a93a7a1b 100644 --- a/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java @@ -7,7 +7,7 @@ import java.util.Map.Entry; import java.util.Set; import mekanism.api.gas.GasStack; -import mekanism.api.recipe.ChemicalPair; +import mekanism.common.recipe.inputs.ChemicalPairInput; import mekanism.client.gui.GuiElectrolyticSeparator; import mekanism.client.gui.GuiElement; import mekanism.client.gui.GuiFluidGauge; @@ -110,7 +110,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler return "mekanism.electrolyticseparator"; } - public Set> getRecipes() + public Set> getRecipes() { return Recipe.ELECTROLYTIC_SEPARATOR.get().entrySet(); } @@ -180,7 +180,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler } else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { - for(Map.Entry irecipe : getRecipes()) + for(Map.Entry irecipe : getRecipes()) { if(irecipe.getValue().containsType((GasStack)results[0])) { @@ -198,7 +198,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler { if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) { - for(Map.Entry irecipe : getRecipes()) + for(Map.Entry irecipe : getRecipes()) { if(irecipe.getKey().isFluidEqual((FluidStack)ingredients[0])) { @@ -368,7 +368,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { public FluidStack fluidInput; - public ChemicalPair outputPair; + public ChemicalPairInput outputPair; @Override public PositionedStack getResult() @@ -376,7 +376,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler return null; } - public CachedIORecipe(FluidStack input, ChemicalPair pair) + public CachedIORecipe(FluidStack input, ChemicalPairInput pair) { fluidInput = input; outputPair = pair; @@ -384,7 +384,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler public CachedIORecipe(Map.Entry recipe) { - this((FluidStack)recipe.getKey(), (ChemicalPair)recipe.getValue()); + this((FluidStack)recipe.getKey(), (ChemicalPairInput)recipe.getValue()); } } } diff --git a/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java index 3bc0989d7..103eb6d20 100644 --- a/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java @@ -1,10 +1,12 @@ package mekanism.client.nei; +import java.util.Collection; import java.util.Set; import mekanism.client.gui.GuiEnrichmentChamber; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.EnrichmentRecipe; import mekanism.common.util.MekanismUtils; public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler @@ -34,9 +36,9 @@ public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.ENRICHMENT_CHAMBER.get().entrySet(); + return Recipe.ENRICHMENT_CHAMBER.get().values(); } @Override diff --git a/src/main/java/mekanism/client/nei/MachineRecipeHandler.java b/src/main/java/mekanism/client/nei/MachineRecipeHandler.java index 97290f8f3..03f6f29d4 100644 --- a/src/main/java/mekanism/client/nei/MachineRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/MachineRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.awt.*; +import java.util.Collection; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -14,6 +15,7 @@ import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.client.gui.GuiSlot; import mekanism.client.gui.GuiSlot.SlotOverlay; import mekanism.client.gui.GuiSlot.SlotType; +import mekanism.common.recipe.machines.BasicMachineRecipe; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -34,7 +36,7 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler public abstract String getRecipeId(); - public abstract Set> getRecipes(); + public abstract Collection getRecipes(); public abstract ProgressBar getProgressType(); @@ -93,7 +95,7 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(BasicMachineRecipe irecipe : getRecipes()) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -106,9 +108,9 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler @Override public void loadCraftingRecipes(ItemStack result) { - for(Map.Entry irecipe : getRecipes()) + for(BasicMachineRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -124,9 +126,9 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler @Override public void loadUsageRecipes(ItemStack ingredient) { - for(Map.Entry irecipe : getRecipes()) + for(BasicMachineRecipe irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().ingredient, ingredient)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -158,9 +160,9 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler output = new PositionedStack(itemstack1, 100, 30); } - public CachedIORecipe(Map.Entry recipe) + public CachedIORecipe(BasicMachineRecipe recipe) { - this((ItemStack)recipe.getKey(), (ItemStack)recipe.getValue()); + this(recipe.getInput().ingredient, recipe.getOutput().output); } } } diff --git a/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java b/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java index c95dc40bc..1509b02fc 100644 --- a/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java @@ -10,8 +10,8 @@ import java.util.Set; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; -import mekanism.api.infuse.InfusionInput; -import mekanism.api.infuse.InfusionOutput; +import mekanism.common.recipe.inputs.InfusionInput; +import mekanism.common.recipe.outputs.InfusionOutput; import mekanism.client.gui.GuiElement; import mekanism.client.gui.GuiMetallurgicInfuser; import mekanism.client.gui.GuiPowerBar; diff --git a/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java b/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java index 7f5bd7330..fe75aa86e 100644 --- a/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java @@ -1,5 +1,6 @@ package mekanism.client.nei; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -9,6 +10,7 @@ import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.MekanismItems; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.OsmiumCompressorRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; @@ -34,9 +36,9 @@ public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.OSMIUM_COMPRESSOR.get().entrySet(); + return Recipe.OSMIUM_COMPRESSOR.get().values(); } @Override diff --git a/src/main/java/mekanism/client/nei/PRCRecipeHandler.java b/src/main/java/mekanism/client/nei/PRCRecipeHandler.java index d21981a97..58c7fb953 100644 --- a/src/main/java/mekanism/client/nei/PRCRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/PRCRecipeHandler.java @@ -7,8 +7,8 @@ import java.util.Map.Entry; import java.util.Set; import mekanism.api.gas.GasStack; -import mekanism.api.recipe.PressurizedReactants; -import mekanism.api.recipe.PressurizedRecipe; +import mekanism.common.recipe.inputs.PressurizedReactants; +import mekanism.common.recipe.machines.PressurizedRecipe; import mekanism.client.gui.GuiElement; import mekanism.client.gui.GuiFluidGauge; import mekanism.client.gui.GuiGasGauge; @@ -159,21 +159,21 @@ public class PRCRecipeHandler extends BaseRecipeHandler { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - if(recipe.pressurizedRecipe.reactants.getFluid() != null) + if(recipe.pressurizedRecipe.getInput().getFluid() != null) { - fluidInput.setDummyType(recipe.pressurizedRecipe.reactants.getFluid().getFluid()); + fluidInput.setDummyType(recipe.pressurizedRecipe.getInput().getFluid().getFluid()); fluidInput.renderScale(0, 0, -xOffset, -yOffset); } - if(recipe.pressurizedRecipe.reactants.getGas() != null) + if(recipe.pressurizedRecipe.getInput().getGas() != null) { - gasInput.setDummyType(recipe.pressurizedRecipe.reactants.getGas().getGas()); + gasInput.setDummyType(recipe.pressurizedRecipe.getInput().getGas().getGas()); gasInput.renderScale(0, 0, -xOffset, -yOffset); } - if(recipe.pressurizedRecipe.products.getGasOutput() != null) + if(recipe.pressurizedRecipe.getOutput().getGasOutput() != null) { - gasOutput.setDummyType(recipe.pressurizedRecipe.products.getGasOutput().getGas()); + gasOutput.setDummyType(recipe.pressurizedRecipe.getOutput().getGasOutput().getGas()); gasOutput.renderScale(0, 0, -xOffset, -yOffset); } } @@ -192,7 +192,7 @@ public class PRCRecipeHandler extends BaseRecipeHandler { for(Map.Entry irecipe : getRecipes()) { - if(irecipe.getValue().reactants.containsType((GasStack)results[0])) + if(irecipe.getValue().getInput().containsType((GasStack)results[0])) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -208,7 +208,7 @@ public class PRCRecipeHandler extends BaseRecipeHandler { for(Map.Entry irecipe : getRecipes()) { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().products.getItemOutput(), result)) + if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().getOutput().getItemOutput(), result)) { arecipes.add(new CachedIORecipe(irecipe)); } @@ -266,15 +266,15 @@ public class PRCRecipeHandler extends BaseRecipeHandler if(xAxis >= 6-5 && xAxis <= 22-5 && yAxis >= 11-10 && yAxis <= 69-10) { - currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getFluid())); + currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getFluid())); } else if(xAxis >= 29-5 && xAxis <= 45-5 && yAxis >= 11-10 && yAxis <= 69-10) { - currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getGas().getGas().getLocalizedName()); + currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getGas().getGas().getLocalizedName()); } else if(xAxis >= 141-5 && xAxis <= 157-5 && yAxis >= 41-10 && yAxis <= 69-10) { - currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.products.getGasOutput().getGas().getLocalizedName()); + currenttip.add(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getOutput().getGasOutput().getGas().getLocalizedName()); } return super.handleTooltip(gui, currenttip, recipe); @@ -294,15 +294,15 @@ public class PRCRecipeHandler extends BaseRecipeHandler if(xAxis >= 6-5 && xAxis <= 22-5 && yAxis >= 11-10 && yAxis <= 69-10) { - fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getFluid(); + fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getFluid(); } else if(xAxis >= 29-5 && xAxis <= 45-5 && yAxis >= 11-10 && yAxis <= 69-10) { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getGas(); + gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getGas(); } else if(xAxis >= 141-5 && xAxis <= 157-5 && yAxis >= 41-10 && yAxis <= 69-10) { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.products.getGasOutput(); + gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getOutput().getGasOutput(); } if(gas != null) @@ -357,15 +357,15 @@ public class PRCRecipeHandler extends BaseRecipeHandler if(xAxis >= 6-5 && xAxis <= 22-5 && yAxis >= 11-10 && yAxis <= 69-10) { - fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getFluid(); + fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getFluid(); } else if(xAxis >= 29-5 && xAxis <= 45-5 && yAxis >= 11-10 && yAxis <= 69-10) { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.reactants.getGas(); + gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getGas(); } else if(xAxis >= 141-5 && xAxis <= 157-5 && yAxis >= 41-10 && yAxis <= 69-10) { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.products.getGasOutput(); + gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getOutput().getGasOutput(); } if(gas != null) @@ -431,8 +431,8 @@ public class PRCRecipeHandler extends BaseRecipeHandler pressurizedRecipe = recipe; - input = new PositionedStack(recipe.reactants.getSolid(), 54-xOffset, 35-yOffset); - output = new PositionedStack(recipe.products.getItemOutput(), 116-xOffset, 35-yOffset); + input = new PositionedStack(recipe.getInput().getSolid(), 54-xOffset, 35-yOffset); + output = new PositionedStack(recipe.getOutput().getItemOutput(), 116-xOffset, 35-yOffset); } public CachedIORecipe(Map.Entry recipe) diff --git a/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java b/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java index 407b698db..3e17443c0 100644 --- a/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java @@ -1,10 +1,13 @@ package mekanism.client.nei; +import java.util.Collection; import java.util.Set; import mekanism.client.gui.GuiPrecisionSawmill; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.ChanceMachineRecipe; +import mekanism.common.recipe.machines.SawmillRecipe; import mekanism.common.util.MekanismUtils; public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler @@ -28,9 +31,9 @@ public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.PRECISION_SAWMILL.get().entrySet(); + return Recipe.PRECISION_SAWMILL.get().values(); } @Override diff --git a/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java index b70c40129..7b782061c 100644 --- a/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java @@ -1,6 +1,7 @@ package mekanism.client.nei; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -10,6 +11,7 @@ import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiProgress.ProgressBar; import mekanism.client.gui.GuiPurificationChamber; import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.recipe.machines.PurificationRecipe; import mekanism.common.util.MekanismUtils; import net.minecraft.init.Items; @@ -36,9 +38,9 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl } @Override - public Set getRecipes() + public Collection getRecipes() { - return Recipe.PURIFICATION_CHAMBER.get().entrySet(); + return Recipe.PURIFICATION_CHAMBER.get().values(); } @Override diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 1af080539..6c0b0350f 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -22,12 +22,12 @@ import mekanism.api.gas.OreGas; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; -import mekanism.api.infuse.InfusionInput; -import mekanism.api.recipe.AdvancedInput; -import mekanism.api.recipe.ChanceOutput; -import mekanism.api.recipe.ChemicalPair; -import mekanism.api.recipe.PressurizedProducts; -import mekanism.api.recipe.PressurizedReactants; +import mekanism.common.recipe.inputs.InfusionInput; +import mekanism.common.recipe.inputs.ChemicalPairInput; +import mekanism.common.recipe.outputs.ChanceOutput; +import mekanism.common.recipe.outputs.ChemicalPairOutput; +import mekanism.common.recipe.outputs.PressurizedProducts; +import mekanism.common.recipe.inputs.PressurizedReactants; import mekanism.api.transmitters.DynamicNetwork.ClientTickUpdate; import mekanism.api.transmitters.DynamicNetwork.NetworkClientRequest; import mekanism.api.transmitters.TransmitterNetworkRegistry; @@ -680,44 +680,44 @@ public class Mekanism RecipeHandler.addPurificationChamberRecipe(new ItemStack(Blocks.gravel), new ItemStack(Items.flint)); //Chemical Injection Chamber Recipes - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Blocks.obsidian), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 6)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Blocks.dirt), GasRegistry.getGas("water")), new ItemStack(Blocks.clay)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Items.gunpowder), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Dust, 1, 10)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.obsidian), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 6)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.dirt), "water", new ItemStack(Blocks.clay)); + RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.gunpowder), "hydrogenChloride", new ItemStack(MekanismItems.Dust, 1, 10)); //Precision Sawmill Recipes - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ladder, 3), new ChanceOutput(new ItemStack(Items.stick, 7))); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.chest), new ChanceOutput(new ItemStack(Blocks.planks, 8))); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.trapdoor), new ChanceOutput(new ItemStack(Blocks.planks, 3))); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.boat), new ChanceOutput(new ItemStack(Blocks.planks, 5))); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.bed), new ChanceOutput(new ItemStack(Blocks.planks, 3), new ItemStack(Blocks.wool, 3), 1)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.jukebox), new ChanceOutput(new ItemStack(Blocks.planks, 8), new ItemStack(Items.diamond), 1)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.bookshelf), new ChanceOutput(new ItemStack(Blocks.planks, 6), new ItemStack(Items.book, 3), 1)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.wooden_pressure_plate), new ChanceOutput(new ItemStack(Blocks.planks, 2))); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.fence), new ChanceOutput(new ItemStack(Items.stick, 3))); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.fence_gate), new ChanceOutput(new ItemStack(Blocks.planks, 2), new ItemStack(Items.stick, 4), 1)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.noteblock), new ChanceOutput(new ItemStack(Blocks.planks, 8), new ItemStack(Items.redstone, 1), 1)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.redstone_torch), new ChanceOutput(new ItemStack(Items.stick, 1), new ItemStack(Items.redstone), 1)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.crafting_table), new ChanceOutput(new ItemStack(Blocks.planks, 4))); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ladder, 3), new ItemStack(Items.stick, 7)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.chest), new ItemStack(Blocks.planks, 8)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.trapdoor), new ItemStack(Blocks.planks, 3)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.boat), new ItemStack(Blocks.planks, 5)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.bed), new ItemStack(Blocks.planks, 3), new ItemStack(Blocks.wool, 3), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.jukebox), new ItemStack(Blocks.planks, 8), new ItemStack(Items.diamond), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.bookshelf), new ItemStack(Blocks.planks, 6), new ItemStack(Items.book, 3), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.wooden_pressure_plate), new ItemStack(Blocks.planks, 2)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.fence), new ItemStack(Items.stick, 3)); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.fence_gate), new ItemStack(Blocks.planks, 2), new ItemStack(Items.stick, 4), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.noteblock), new ItemStack(Blocks.planks, 8), new ItemStack(Items.redstone), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.redstone_torch), new ItemStack(Items.stick), new ItemStack(Items.redstone), 1); + RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.crafting_table), new ItemStack(Blocks.planks, 4)); //Metallurgic Infuser Recipes - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(Items.iron_ingot)), new ItemStack(MekanismItems.EnrichedIron)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(MekanismItems.EnrichedIron)), new ItemStack(MekanismItems.Dust, 1, 5)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("REDSTONE"), 10, new ItemStack(Items.iron_ingot)), new ItemStack(MekanismItems.EnrichedAlloy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Blocks.dirt)), new ItemStack(Blocks.mycelium)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.cobblestone)), new ItemStack(Blocks.mossy_cobblestone)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.stonebrick, 1, 0)), new ItemStack(Blocks.stonebrick, 1, 1)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.sand)), new ItemStack(Blocks.dirt)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("DIAMOND"), 10, new ItemStack(MekanismItems.EnrichedAlloy)), new ItemStack(MekanismItems.ReinforcedAlloy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("OBSIDIAN"), 10, new ItemStack(MekanismItems.ReinforcedAlloy)), new ItemStack(MekanismItems.AtomicAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(Items.iron_ingot), new ItemStack(MekanismItems.EnrichedIron)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(MekanismItems.EnrichedIron), new ItemStack(MekanismItems.Dust, 1, 5)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("REDSTONE"), 10, new ItemStack(Items.iron_ingot), new ItemStack(MekanismItems.EnrichedAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Blocks.dirt), new ItemStack(Blocks.mycelium)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.mossy_cobblestone)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 1)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.sand), new ItemStack(Blocks.dirt)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, new ItemStack(MekanismItems.EnrichedAlloy), new ItemStack(MekanismItems.ReinforcedAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("OBSIDIAN"), 10, new ItemStack(MekanismItems.ReinforcedAlloy), new ItemStack(MekanismItems.AtomicAlloy)); //Chemical Infuser Recipes - RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2)), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2)); - RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new GasStack(GasRegistry.getGas("water"), 1)), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); - RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1)), new GasStack(GasRegistry.getGas("hydrogenChloride"), 1)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new GasStack(GasRegistry.getGas("water"), 1), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); + RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1), new GasStack(GasRegistry.getGas("hydrogenChloride"), 1)); //Electrolytic Separator Recipes - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), new ChemicalPair(new GasStack(GasRegistry.getGas("hydrogen"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1))); - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("brine", 10), new ChemicalPair(new GasStack(GasRegistry.getGas("sodium"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1))); + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), new GasStack(GasRegistry.getGas("hydrogen"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1)); + RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("brine", 10), new GasStack(GasRegistry.getGas("sodium"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1)); //T4 Processing Recipes for(Gas gas : GasRegistry.getRegisteredGasses()) @@ -736,15 +736,15 @@ public class Mekanism //Pressurized Reaction Chamber Recipes RecipeHandler.addPRCRecipe( - new PressurizedReactants(new ItemStack(MekanismItems.BioFuel, 2), new FluidStack(FluidRegistry.WATER, 10), new GasStack(GasRegistry.getGas("hydrogen"), 100)), - new PressurizedProducts(new ItemStack(MekanismItems.Substrate), new GasStack(GasRegistry.getGas("ethene"), 100)), + new ItemStack(MekanismItems.BioFuel, 2), new FluidStack(FluidRegistry.WATER, 10), new GasStack(GasRegistry.getGas("hydrogen"), 100), + new ItemStack(MekanismItems.Substrate), new GasStack(GasRegistry.getGas("ethene"), 100), 0, 100 ); RecipeHandler.addPRCRecipe( - new PressurizedReactants(new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.getFluid("ethene"), 50), new GasStack(GasRegistry.getGas("oxygen"), 10)), - new PressurizedProducts(new ItemStack(MekanismItems.Polyethene), new GasStack(GasRegistry.getGas("oxygen"), 5)), + new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.getFluid("ethene"), 50), new GasStack(GasRegistry.getGas("oxygen"), 10), + new ItemStack(MekanismItems.Polyethene), new GasStack(GasRegistry.getGas("oxygen"), 5), 1000, 60 ); diff --git a/src/main/java/mekanism/common/base/IFactory.java b/src/main/java/mekanism/common/base/IFactory.java index 7e03c9662..65855adc0 100644 --- a/src/main/java/mekanism/common/base/IFactory.java +++ b/src/main/java/mekanism/common/base/IFactory.java @@ -4,7 +4,7 @@ import java.util.Map; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; -import mekanism.api.recipe.AdvancedInput; +import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.api.util.StackUtils; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.recipe.RecipeHandler; @@ -82,7 +82,7 @@ public interface IFactory if(usesFuel()) { - return RecipeHandler.getOutput(new AdvancedInput(input, gas), stackDecrease, recipe.get()); + return RecipeHandler.getOutput(new AdvancedMachineInput(input, gas), stackDecrease, recipe.get()); } else { return RecipeHandler.getOutput(input, stackDecrease, recipe.get()); @@ -148,11 +148,11 @@ public interface IFactory for(Object obj : recipe.get().entrySet()) { - if(((Map.Entry)obj).getKey() instanceof AdvancedInput) + if(((Map.Entry)obj).getKey() instanceof AdvancedMachineInput) { Map.Entry entry = (Map.Entry)obj; - ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack; + ItemStack stack = ((AdvancedMachineInput)entry.getKey()).itemStack; if(StackUtils.equalsWildcard(stack, itemStack)) { diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index db627e492..18798a2ef 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -261,26 +261,14 @@ public class BlockBasic extends Block implements IBlockCTM case BASIC_BLOCK_1: for(int i = 0; i < 16; i++) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - list.add(new ItemStack(item, 1, 3)); - list.add(new ItemStack(item, 1, 4)); - list.add(new ItemStack(item, 1, 5)); - list.add(new ItemStack(item, 1, 6)); - list.add(new ItemStack(item, 1, 7)); - list.add(new ItemStack(item, 1, 8)); - list.add(new ItemStack(item, 1, 9)); - list.add(new ItemStack(item, 1, 10)); - list.add(new ItemStack(item, 1, 11)); - list.add(new ItemStack(item, 1, 12)); - list.add(new ItemStack(item, 1, 13)); - list.add(new ItemStack(item, 1, 14)); - list.add(new ItemStack(item, 1, 15)); + list.add(new ItemStack(item, 1, i)); } break; case BASIC_BLOCK_2: - list.add(new ItemStack(item, 1, 0)); + for(int i = 0; i < 1; i++) + { + list.add(new ItemStack(item, 1, i)); + } break; } } diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 8d795da1d..8c67de265 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -6,9 +6,8 @@ import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; -import mekanism.api.infuse.InfusionInput; -import mekanism.api.recipe.AdvancedInput; -import mekanism.api.recipe.ChanceOutput; +import mekanism.common.recipe.inputs.InfusionInput; +import mekanism.common.recipe.outputs.ChanceOutput; import mekanism.api.util.StackUtils; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; @@ -45,11 +44,11 @@ public final class OreDictManager if(!Recipe.PRECISION_SAWMILL.containsRecipe(wildStack)) { - RecipeHandler.addPrecisionSawmillRecipe(wildStack, new ChanceOutput(new ItemStack(Items.stick, 6), new ItemStack(MekanismItems.Sawdust), 0.25)); + RecipeHandler.addPrecisionSawmillRecipe(wildStack, new ItemStack(Items.stick, 6), new ItemStack(MekanismItems.Sawdust), 0.25); } } else { - RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(ore, 1), new ChanceOutput(new ItemStack(Items.stick, 6), new ItemStack(MekanismItems.Sawdust), 0.25)); + RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(ore, 1), new ItemStack(Items.stick, 6), new ItemStack(MekanismItems.Sawdust), 0.25); } } @@ -62,7 +61,7 @@ public final class OreDictManager { for(ItemStack ore : OreDictionary.getOres("woodRubber")) { - RecipeHandler.addPrecisionSawmillRecipe(MekanismUtils.size(ore, 1), new ChanceOutput(new ItemStack(Blocks.planks, 4), MekanismUtils.size(OreDictionary.getOres("itemRubber").get(0), 1), 1F)); + RecipeHandler.addPrecisionSawmillRecipe(MekanismUtils.size(ore, 1), new ItemStack(Blocks.planks, 4), MekanismUtils.size(OreDictionary.getOres("itemRubber").get(0), 1), 1F); } } @@ -167,42 +166,42 @@ public final class OreDictManager for(ItemStack ore : OreDictionary.getOres("crystalIron")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 0)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 0)); } for(ItemStack ore : OreDictionary.getOres("crystalGold")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 1)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 1)); } for(ItemStack ore : OreDictionary.getOres("crystalOsmium")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 2)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 2)); } for(ItemStack ore : OreDictionary.getOres("crystalCopper")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 3)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 3)); } for(ItemStack ore : OreDictionary.getOres("crystalTin")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 4)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 4)); } for(ItemStack ore : OreDictionary.getOres("crystalSilver")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 5)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 5)); } for(ItemStack ore : OreDictionary.getOres("crystalObsidian")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 6)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 6)); } for(ItemStack ore : OreDictionary.getOres("crystalLead")) { - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 1, 7)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, 7)); } for(ItemStack ore : OreDictionary.getOres("dustDirtyIron")) @@ -244,7 +243,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 6)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 3)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 3)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 3)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("copper"), 1000)); } @@ -252,7 +251,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 7)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 4)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 4)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 4)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("tin"), 1000)); } @@ -260,7 +259,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 2)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 2)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 2)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 2)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("osmium"), 1000)); } @@ -268,7 +267,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 0)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 0)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 0)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 0)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("iron"), 1000)); } @@ -276,7 +275,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 1)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 1)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 1)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 1)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("gold"), 1000)); } @@ -284,7 +283,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 8)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 5)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 5)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 5)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("silver"), 1000)); } @@ -292,7 +291,7 @@ public final class OreDictManager { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, 9)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, 7)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(MekanismItems.Shard, 4, 7)); + RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, 7)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("lead"), 1000)); } @@ -392,7 +391,7 @@ public final class OreDictManager for(ItemStack ore : OreDictionary.getOres("ingotOsmium")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 1, 2)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("REDSTONE"), 10, MekanismUtils.size(ore, 1)), new ItemStack(MekanismItems.ControlCircuit, 1, 0)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("REDSTONE"), 10, MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.ControlCircuit, 1, 0)); } for(ItemStack ore : OreDictionary.getOres("ingotRedstone")) @@ -467,7 +466,7 @@ public final class OreDictManager for(ItemStack ore : OreDictionary.getOres("dustObsidian")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 4), new ItemStack(Blocks.obsidian)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("DIAMOND"), 10, MekanismUtils.size(ore, 1)), new ItemStack(MekanismItems.Dust, 1, 3)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 1, 3)); } for(ItemStack ore : OreDictionary.getOres("dustOsmium")) @@ -488,7 +487,7 @@ public final class OreDictManager for(ItemStack ore : OreDictionary.getOres("ingotCopper")) { - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("TIN"), 10, MekanismUtils.size(ore, 1)), new ItemStack(MekanismItems.Ingot, 1, 2)); + RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("TIN"), 10, MekanismUtils.size(ore, 1), new ItemStack(MekanismItems.Ingot, 1, 2)); } for(ItemStack ore : OreDictionary.getOres("dustTin")) @@ -568,7 +567,7 @@ public final class OreDictManager if(resultEntry != null) { - RecipeHandler.addPrecisionSawmillRecipe(log, new ChanceOutput(StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1)); + RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1); } } } @@ -579,7 +578,7 @@ public final class OreDictManager if(resultEntry != null) { - RecipeHandler.addPrecisionSawmillRecipe(log, new ChanceOutput(StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1)); + RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1); } } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java index 9f4bdf5f2..b38c85f3a 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java @@ -2,7 +2,7 @@ package mekanism.common.inventory.container; import java.util.Map; -import mekanism.api.recipe.AdvancedInput; +import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotOutput; import mekanism.common.tile.TileEntityAdvancedElectricMachine; @@ -170,7 +170,7 @@ public class ContainerAdvancedElectricMachine extends Container private boolean isInputItem(ItemStack itemstack) { - for(Map.Entry entry : ((Map)tileEntity.getRecipes()).entrySet()) + for(Map.Entry entry : ((Map)tileEntity.getRecipes()).entrySet()) { if(entry.getKey().itemStack.isItemEqual(itemstack)) { diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java index aed3f3689..69f5dc6f0 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java @@ -71,7 +71,7 @@ public class ContainerChemicalDissolutionChamber extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()) != null) + if(RecipeHandler.getDissolutionOutput(slotStack, false) != null) { if(slotID != 1) { diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java index 8f0cde358..7218be849 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java @@ -70,7 +70,7 @@ public class ContainerChemicalOxidizer extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_OXIDIZER.get()) != null) + if(RecipeHandler.getOxidizerOutput(slotStack, false) != null) { if(slotID != 0) { diff --git a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index e671865b4..bd5d32fc4 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -1,7 +1,7 @@ package mekanism.common.inventory.container; import mekanism.api.infuse.InfuseRegistry; -import mekanism.api.infuse.InfusionInput; +import mekanism.common.recipe.inputs.InfusionInput; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotOutput; import mekanism.common.recipe.RecipeHandler; diff --git a/src/main/java/mekanism/common/recipe/RecipeHandler.java b/src/main/java/mekanism/common/recipe/RecipeHandler.java index 34c001ddb..498ee4087 100644 --- a/src/main/java/mekanism/common/recipe/RecipeHandler.java +++ b/src/main/java/mekanism/common/recipe/RecipeHandler.java @@ -4,18 +4,43 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; -import mekanism.api.infuse.InfusionInput; -import mekanism.api.infuse.InfusionOutput; -import mekanism.api.recipe.AdvancedInput; -import mekanism.api.recipe.ChanceOutput; -import mekanism.api.recipe.ChemicalPair; -import mekanism.api.recipe.PressurizedProducts; -import mekanism.api.recipe.PressurizedReactants; -import mekanism.api.recipe.PressurizedRecipe; +import mekanism.api.infuse.InfuseType; +import mekanism.common.recipe.inputs.AdvancedMachineInput; +import mekanism.common.recipe.inputs.ChemicalPairInput; +import mekanism.common.recipe.inputs.FluidInput; +import mekanism.common.recipe.inputs.GasInput; +import mekanism.common.recipe.inputs.InfusionInput; +import mekanism.common.recipe.inputs.IntegerInput; +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.inputs.MachineInput; +import mekanism.common.recipe.inputs.PressurizedReactants; +import mekanism.common.recipe.outputs.ChanceOutput; +import mekanism.common.recipe.outputs.ChemicalPairOutput; +import mekanism.common.recipe.outputs.InfusionOutput; +import mekanism.common.recipe.outputs.MachineOutput; import mekanism.api.util.StackUtils; +import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.recipe.machines.AmbientGasRecipe; +import mekanism.common.recipe.machines.BasicMachineRecipe; +import mekanism.common.recipe.machines.ChanceMachineRecipe; +import mekanism.common.recipe.machines.ChemicalInfuserRecipe; +import mekanism.common.recipe.machines.CombinerRecipe; +import mekanism.common.recipe.machines.CrusherRecipe; +import mekanism.common.recipe.machines.CrystallizerRecipe; +import mekanism.common.recipe.machines.DissolutionRecipe; +import mekanism.common.recipe.machines.EnrichmentRecipe; +import mekanism.common.recipe.machines.InjectionRecipe; +import mekanism.common.recipe.machines.MachineRecipe; +import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; +import mekanism.common.recipe.machines.OsmiumCompressorRecipe; +import mekanism.common.recipe.machines.OxidationRecipe; +import mekanism.common.recipe.machines.PressurizedRecipe; +import mekanism.common.recipe.machines.PurificationRecipe; +import mekanism.common.recipe.machines.SawmillRecipe; +import mekanism.common.recipe.machines.SeparatorRecipe; +import mekanism.common.recipe.machines.WasherRecipe; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -29,9 +54,9 @@ import net.minecraftforge.fluids.FluidTank; */ public final class RecipeHandler { - public static void addRecipe(Recipe recipe, Object input, Object output) + public static void addRecipe(Recipe recipeMap, MachineRecipe recipe) { - recipe.put(input, output); + recipeMap.put(recipe); } /** @@ -41,7 +66,7 @@ public final class RecipeHandler */ public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) { - Recipe.ENRICHMENT_CHAMBER.put(input, output); + addRecipe(Recipe.ENRICHMENT_CHAMBER, new EnrichmentRecipe(input, output)); } /** @@ -51,7 +76,7 @@ public final class RecipeHandler */ public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) { - Recipe.OSMIUM_COMPRESSOR.put(new AdvancedInput(input, GasRegistry.getGas("liquidOsmium")), output); + addRecipe(Recipe.OSMIUM_COMPRESSOR, new OsmiumCompressorRecipe(input, output)); } /** @@ -61,7 +86,7 @@ public final class RecipeHandler */ public static void addCombinerRecipe(ItemStack input, ItemStack output) { - Recipe.COMBINER.put(new AdvancedInput(input, GasRegistry.getGas("liquidStone")), output); + addRecipe(Recipe.COMBINER, new CombinerRecipe(input, output)); } /** @@ -71,7 +96,7 @@ public final class RecipeHandler */ public static void addCrusherRecipe(ItemStack input, ItemStack output) { - Recipe.CRUSHER.put(input, output); + addRecipe(Recipe.CRUSHER, new CrusherRecipe(input, output)); } /** @@ -81,27 +106,30 @@ public final class RecipeHandler */ public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) { - Recipe.PURIFICATION_CHAMBER.put(new AdvancedInput(input, GasRegistry.getGas("oxygen")), output); + addRecipe(Recipe.PURIFICATION_CHAMBER, new PurificationRecipe(input, output)); } /** * Add a Metallurgic Infuser recipe. - * @param input - input Infusion + * @param infuse - which Infuse to use + * @param amount - how much of the Infuse to use + * @param input - input ItemStack * @param output - output ItemStack */ - public static void addMetallurgicInfuserRecipe(InfusionInput input, ItemStack output) + public static void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) { - Recipe.METALLURGIC_INFUSER.put(input, InfusionOutput.getInfusion(input, output)); + addRecipe(Recipe.METALLURGIC_INFUSER, new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, input), output)); } /** * Add a Chemical Infuser recipe. - * @param input - input ChemicalPair + * @param leftInput - left GasStack to input + * @param rightInput - right GasStack to input * @param output - output GasStack */ - public static void addChemicalInfuserRecipe(ChemicalPair input, GasStack output) + public static void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) { - Recipe.CHEMICAL_INFUSER.put(input, output); + addRecipe(Recipe.CHEMICAL_INFUSER, new ChemicalInfuserRecipe(leftInput, rightInput, output)); } /** @@ -111,7 +139,7 @@ public final class RecipeHandler */ public static void addChemicalOxidizerRecipe(ItemStack input, GasStack output) { - Recipe.CHEMICAL_OXIDIZER.put(input, output); + addRecipe(Recipe.CHEMICAL_OXIDIZER, new OxidationRecipe(input, output)); } /** @@ -119,29 +147,42 @@ public final class RecipeHandler * @param input - input ItemStack * @param output - output ItemStack */ - public static void addChemicalInjectionChamberRecipe(AdvancedInput input, ItemStack output) + public static void addChemicalInjectionChamberRecipe(ItemStack input, String gasName, ItemStack output) { - Recipe.CHEMICAL_INJECTION_CHAMBER.put(input, output); + addRecipe(Recipe.CHEMICAL_INJECTION_CHAMBER, new InjectionRecipe(input, gasName, output)); } /** * Add an Electrolytic Separator recipe. * @param fluid - FluidStack to electrolyze - * @param products - Pair of gases to produce when the fluid is electrolyzed + * @param leftOutput - left gas to produce when the fluid is electrolyzed + * @param rightOutput - right gas to produce when the fluid is electrolyzed */ - public static void addElectrolyticSeparatorRecipe(FluidStack fluid, ChemicalPair products) + public static void addElectrolyticSeparatorRecipe(FluidStack fluid, GasStack leftOutput, GasStack rightOutput) { - Recipe.ELECTROLYTIC_SEPARATOR.put(fluid, products); + addRecipe(Recipe.ELECTROLYTIC_SEPARATOR, new SeparatorRecipe(fluid, leftOutput, rightOutput)); } /** - * Add an Precision Sawmill recipe. + * Add a Precision Sawmill recipe. * @param input - input ItemStack - * @param output - output ChanceOutput + * @param primaryOutput - guaranteed output + * @param secondaryOutput - possible extra output + * @param chance - probability of obtaining extra output */ - public static void addPrecisionSawmillRecipe(ItemStack input, ChanceOutput output) + public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) { - Recipe.PRECISION_SAWMILL.put(input, output); + addRecipe(Recipe.PRECISION_SAWMILL, new SawmillRecipe(input, primaryOutput, secondaryOutput, chance)); + } + + /** + * Add a Precision Sawmill recipe with no chance output + * @param input - input ItemStack + * @param primaryOutput - guaranteed output + */ + public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) + { + addRecipe(Recipe.PRECISION_SAWMILL, new SawmillRecipe(input, primaryOutput)); } /** @@ -151,7 +192,7 @@ public final class RecipeHandler */ public static void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) { - Recipe.CHEMICAL_DISSOLUTION_CHAMBER.put(input, output); + addRecipe(Recipe.CHEMICAL_DISSOLUTION_CHAMBER, new DissolutionRecipe(input, output)); } /** @@ -161,7 +202,7 @@ public final class RecipeHandler */ public static void addChemicalWasherRecipe(GasStack input, GasStack output) { - Recipe.CHEMICAL_WASHER.put(input, output); + addRecipe(Recipe.CHEMICAL_WASHER, new WasherRecipe(input, output)); } /** @@ -171,20 +212,27 @@ public final class RecipeHandler */ public static void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) { - Recipe.CHEMICAL_CRYSTALLIZER.put(input, output); + addRecipe(Recipe.CHEMICAL_CRYSTALLIZER, new CrystallizerRecipe(input, output)); } /** * Add a Pressurized Reaction Chamber recipe. - * @param input - input PressurizedReactants - * @param output - output PressurizedProducts + * @param inputSolid - input ItemStack + * @param inputFluid - input FluidStack + * @param inputGas - input GasStack + * @param outputSolid - output ItemStack + * @param outputGas - output GasStack * @param extraEnergy - extra energy needed by the recipe * @param ticks - amount of ticks it takes for this recipe to complete */ - public static void addPRCRecipe(PressurizedReactants input, PressurizedProducts output, double extraEnergy, int ticks) + public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) { - PressurizedRecipe recipe = new PressurizedRecipe(input, extraEnergy, output, ticks); - Recipe.PRESSURIZED_REACTION_CHAMBER.put(input, recipe); + addRecipe(Recipe.PRESSURIZED_REACTION_CHAMBER, new PressurizedRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks)); + } + + public static void addAmbientGas(int dimensionID, String ambientGasName) + { + addRecipe(Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName)); } /** @@ -197,22 +245,22 @@ public final class RecipeHandler { if(infusion != null && infusion.inputStack != null) { - HashMap recipes = Recipe.METALLURGIC_INFUSER.get(); + HashMap recipes = Recipe.METALLURGIC_INFUSER.get(); - for(Map.Entry entry : recipes.entrySet()) + MetallurgicInfuserRecipe recipe = recipes.get(infusion); + + if(recipe != null) { - InfusionInput input = (InfusionInput)entry.getKey(); - - if(StackUtils.equalsWildcard(input.inputStack, infusion.inputStack) && infusion.inputStack.stackSize >= input.inputStack.stackSize) + if(StackUtils.equalsWildcard(recipe.getInput().inputStack, infusion.inputStack) && infusion.inputStack.stackSize >= recipe.getInput().inputStack.stackSize) { - if(infusion.infusionType == input.infusionType) + if(infusion.infusionType == recipe.getInput().infusionType) { if(stackDecrease) { - infusion.inputStack.stackSize -= ((InfusionInput)entry.getKey()).inputStack.stackSize; + infusion.inputStack.stackSize -= recipe.getInput().inputStack.stackSize; } - return ((InfusionOutput)entry.getValue()).copy(); + return recipe.getOutput().copy(); } } } @@ -230,24 +278,26 @@ public final class RecipeHandler */ public static GasStack getChemicalInfuserOutput(GasTank leftTank, GasTank rightTank, boolean doRemove) { - ChemicalPair input = new ChemicalPair(leftTank.getGas(), rightTank.getGas()); + ChemicalPairInput input = new ChemicalPairInput(leftTank.getGas(), rightTank.getGas()); if(input.isValid()) { - HashMap recipes = Recipe.CHEMICAL_INFUSER.get(); + HashMap recipes = Recipe.CHEMICAL_INFUSER.get(); - for(Map.Entry entry : recipes.entrySet()) + ChemicalInfuserRecipe recipe = recipes.get(input); + + if(recipe != null) { - ChemicalPair key = (ChemicalPair)entry.getKey(); + ChemicalPairInput required = recipe.getInput(); - if(key.meetsInput(input)) + if(required.meetsInput(input)) { if(doRemove) { - key.draw(leftTank, rightTank); + required.draw(leftTank, rightTank); } - return entry.getValue().copy(); + return recipe.getOutput().output.copy(); } } } @@ -263,21 +313,23 @@ public final class RecipeHandler */ public static ItemStack getChemicalCrystallizerOutput(GasTank gasTank, boolean removeGas) { - GasStack gas = gasTank.getGas(); + GasInput input = new GasInput(gasTank.getGas()); - if(gas != null) + if(input.ingredient != null) { - HashMap recipes = Recipe.CHEMICAL_CRYSTALLIZER.get(); + HashMap recipes = Recipe.CHEMICAL_CRYSTALLIZER.get(); - for(Map.Entry entry : recipes.entrySet()) + CrystallizerRecipe recipe = recipes.get(input); + + if(recipe != null) { - GasStack key = (GasStack)entry.getKey(); + GasStack key = recipe.getInput().ingredient; - if(key != null && key.getGas() == gas.getGas() && gas.amount >= key.amount) + if(key != null && key.getGas() == input.ingredient.getGas() && input.ingredient.amount >= key.amount) { gasTank.draw(key.amount, removeGas); - return entry.getValue().copy(); + return recipe.getOutput().output.copy(); } } } @@ -293,21 +345,23 @@ public final class RecipeHandler */ public static GasStack getChemicalWasherOutput(GasTank gasTank, boolean removeGas) { - GasStack gas = gasTank.getGas(); + GasInput input = new GasInput(gasTank.getGas()); - if(gas != null) + if(input.ingredient != null) { - HashMap recipes = Recipe.CHEMICAL_WASHER.get(); + HashMap recipes = Recipe.CHEMICAL_WASHER.get(); - for(Map.Entry entry : recipes.entrySet()) + WasherRecipe recipe = recipes.get(input); + + if(recipe != null) { - GasStack key = (GasStack)entry.getKey(); + GasStack key = recipe.getInput().ingredient; - if(key != null && key.getGas() == gas.getGas() && gas.amount >= key.amount) + if(key != null && key.getGas() == input.ingredient.getGas() && input.ingredient.amount >= key.amount) { gasTank.draw(key.amount, removeGas); - return entry.getValue().copy(); + return recipe.getOutput().output.copy(); } } } @@ -321,13 +375,19 @@ public final class RecipeHandler * @param stackDecrease - whether or not to decrease the input slot's stack size * @return output GasStack */ - public static GasStack getItemToGasOutput(ItemStack itemstack, boolean stackDecrease, HashMap recipes) + public static GasStack getDissolutionOutput(ItemStack itemstack, boolean stackDecrease) { if(itemstack != null) { - for(Map.Entry entry : recipes.entrySet()) + ItemStackInput input = new ItemStackInput(itemstack); + + HashMap recipes = Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(); + + DissolutionRecipe recipe = recipes.get(input); + + if(recipe != null) { - ItemStack stack = (ItemStack)entry.getKey(); + ItemStack stack = recipe.getInput().ingredient; if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) { @@ -336,7 +396,42 @@ public final class RecipeHandler itemstack.stackSize -= stack.stackSize; } - return entry.getValue().copy(); + return recipe.getOutput().output.copy(); + } + } + } + + return null; + } + + /** + * Gets the GasStack of the ItemStack in the parameters using a defined map. + * @param itemstack - input ItemStack + * @param stackDecrease - whether or not to decrease the input slot's stack size + * @return output GasStack + */ + public static GasStack getOxidizerOutput(ItemStack itemstack, boolean stackDecrease) + { + if(itemstack != null) + { + ItemStackInput input = new ItemStackInput(itemstack); + + HashMap recipes = Recipe.CHEMICAL_OXIDIZER.get(); + + OxidationRecipe recipe = recipes.get(input); + + if(recipe != null) + { + ItemStack stack = recipe.getInput().ingredient; + + if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) + { + if(stackDecrease) + { + itemstack.stackSize -= stack.stackSize; + } + + return recipe.getOutput().output.copy(); } } } @@ -351,13 +446,17 @@ public final class RecipeHandler * @param recipes - Map of recipes * @return output ChanceOutput */ - public static ChanceOutput getChanceOutput(ItemStack itemstack, boolean stackDecrease, Map recipes) + public static ChanceOutput getChanceOutput(ItemStack itemstack, boolean stackDecrease, Map recipes) { if(itemstack != null) { - for(Map.Entry entry : recipes.entrySet()) + ItemStackInput input = new ItemStackInput(itemstack); + + ChanceMachineRecipe recipe = recipes.get(input); + + if(recipe != null) { - ItemStack stack = (ItemStack)entry.getKey(); + ItemStack stack = recipe.getInput().ingredient; if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) { @@ -366,7 +465,7 @@ public final class RecipeHandler itemstack.stackSize -= stack.stackSize; } - return ((ChanceOutput)entry.getValue()).copy(); + return recipe.getOutput().copy(); } } } @@ -381,13 +480,17 @@ public final class RecipeHandler * @param recipes - Map of recipes * @return output ItemStack */ - public static ItemStack getOutput(ItemStack itemstack, boolean stackDecrease, Map recipes) + public static ItemStack getOutput(ItemStack itemstack, boolean stackDecrease, Map recipes) { if(itemstack != null) { - for(Map.Entry entry : recipes.entrySet()) + ItemStackInput input = new ItemStackInput(itemstack); + + BasicMachineRecipe recipe = recipes.get(input); + + if(recipe != null) { - ItemStack stack = (ItemStack)entry.getKey(); + ItemStack stack = recipe.getInput().ingredient; if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) { @@ -396,7 +499,7 @@ public final class RecipeHandler itemstack.stackSize -= stack.stackSize; } - return ((ItemStack)entry.getValue()).copy(); + return recipe.getOutput().output.copy(); } } } @@ -410,21 +513,20 @@ public final class RecipeHandler * @param recipes - Map of recipes * @return output ItemStack */ - public static ItemStack getOutput(AdvancedInput input, boolean stackDecrease, Map recipes) + public static ItemStack getOutput(AdvancedMachineInput input, boolean stackDecrease, Map recipes) { if(input != null && input.isValid()) { - for(Map.Entry entry : recipes.entrySet()) - { - if(entry.getKey().matches(input)) - { - if(stackDecrease) - { - input.itemStack.stackSize -= entry.getKey().itemStack.stackSize; - } + AdvancedMachineRecipe recipe = recipes.get(input); - return entry.getValue().copy(); + if(recipe != null && recipe.getInput().matches(input)) + { + if(stackDecrease) + { + input.itemStack.stackSize -= recipe.getInput().itemStack.stackSize; } + + return recipe.getOutput().output.copy(); } } @@ -435,23 +537,27 @@ public final class RecipeHandler * Get the result of electrolysing a given fluid * @param fluidTank - the FluidTank to electrolyse fluid from */ - public static ChemicalPair getElectrolyticSeparatorOutput(FluidTank fluidTank, boolean doRemove) + public static ChemicalPairOutput getElectrolyticSeparatorOutput(FluidTank fluidTank, boolean doRemove) { FluidStack fluid = fluidTank.getFluid(); if(fluid != null) { - HashMap recipes = Recipe.ELECTROLYTIC_SEPARATOR.get(); + FluidInput input = new FluidInput(fluid); - for(Map.Entry entry : recipes.entrySet()) + HashMap recipes = Recipe.ELECTROLYTIC_SEPARATOR.get(); + + SeparatorRecipe recipe = recipes.get(input); + + if(recipe != null) { - FluidStack key = (FluidStack)entry.getKey(); + FluidStack key = recipe.getInput().ingredient; if(fluid.containsFluid(key)) { fluidTank.drain(key.amount, doRemove); - return entry.getValue().copy(); + return recipe.getOutput().copy(); } } } @@ -464,24 +570,29 @@ public final class RecipeHandler FluidStack inputFluid = inputFluidTank.getFluid(); GasStack inputGas = inputGasTank.getGas(); - if(inputFluid != null && inputGas != null) + if(inputItem != null && inputFluid != null && inputGas != null) { + PressurizedReactants input = new PressurizedReactants(inputItem, inputFluid, inputGas); + HashMap recipes = Recipe.PRESSURIZED_REACTION_CHAMBER.get(); - for(PressurizedRecipe recipe : recipes.values()) - { - PressurizedReactants reactants = recipe.reactants; + PressurizedRecipe recipe = recipes.get(input); - if(reactants.meetsInput(inputItem, inputFluid, inputGas)) - { - return recipe.copy(); - } + if(recipe.getInput().meets(input)) + { + return recipe.copy(); } } return null; } + public static GasStack getDimensionGas(Integer dimensionID) + { + HashMap recipes = Recipe.AMBIENT_ACCUMULATOR.get(); + return recipes.get(new IntegerInput(dimensionID)).getOutput().output; + } + /** * Gets the output ItemStack of the ItemStack in the parameters. * @param itemstack - input ItemStack @@ -524,32 +635,33 @@ public final class RecipeHandler public static enum Recipe { - ENRICHMENT_CHAMBER(new HashMap()), - OSMIUM_COMPRESSOR(new HashMap()), - COMBINER(new HashMap()), - CRUSHER(new HashMap()), - PURIFICATION_CHAMBER(new HashMap()), - METALLURGIC_INFUSER(new HashMap()), - CHEMICAL_INFUSER(new HashMap()), - CHEMICAL_OXIDIZER(new HashMap()), - CHEMICAL_INJECTION_CHAMBER(new HashMap()), - ELECTROLYTIC_SEPARATOR(new HashMap()), - PRECISION_SAWMILL(new HashMap()), - CHEMICAL_DISSOLUTION_CHAMBER(new HashMap()), - CHEMICAL_WASHER(new HashMap()), - CHEMICAL_CRYSTALLIZER(new HashMap()), - PRESSURIZED_REACTION_CHAMBER(new HashMap()); + ENRICHMENT_CHAMBER(new HashMap()), + OSMIUM_COMPRESSOR(new HashMap()), + COMBINER(new HashMap()), + CRUSHER(new HashMap()), + PURIFICATION_CHAMBER(new HashMap()), + METALLURGIC_INFUSER(new HashMap()), + CHEMICAL_INFUSER(new HashMap()), + CHEMICAL_OXIDIZER(new HashMap()), + CHEMICAL_INJECTION_CHAMBER(new HashMap()), + ELECTROLYTIC_SEPARATOR(new HashMap()), + PRECISION_SAWMILL(new HashMap()), + CHEMICAL_DISSOLUTION_CHAMBER(new HashMap()), + CHEMICAL_WASHER(new HashMap()), + CHEMICAL_CRYSTALLIZER(new HashMap()), + PRESSURIZED_REACTION_CHAMBER(new HashMap()), + AMBIENT_ACCUMULATOR(new HashMap()); private HashMap recipes; - private Recipe(HashMap map) + private Recipe(HashMap map) { recipes = map; } - public void put(Object input, Object output) + public void put(MachineRecipe recipe) { - recipes.put(input, output); + recipes.put(recipe.getInput(), recipe); } public boolean containsRecipe(ItemStack input) @@ -560,25 +672,25 @@ public final class RecipeHandler { Map.Entry entry = (Map.Entry)obj; - if(entry.getKey() instanceof ItemStack) + if(entry.getKey() instanceof ItemStackInput) { - ItemStack stack = (ItemStack)entry.getKey(); + ItemStack stack = ((ItemStackInput)entry.getKey()).ingredient; if(StackUtils.equalsWildcard(stack, input)) { return true; } } - else if(entry.getKey() instanceof FluidStack) + else if(entry.getKey() instanceof FluidInput) { - if(((FluidStack)entry.getKey()).isFluidEqual(input)) + if(((FluidInput)entry.getKey()).ingredient.isFluidEqual(input)) { return true; } } - else if(entry.getKey() instanceof AdvancedInput) + else if(entry.getKey() instanceof AdvancedMachineInput) { - ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack; + ItemStack stack = ((AdvancedMachineInput)entry.getKey()).itemStack; if(StackUtils.equalsWildcard(stack, input)) { diff --git a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java new file mode 100644 index 000000000..ab2a8f741 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java @@ -0,0 +1,41 @@ +package mekanism.common.recipe.inputs; + +import mekanism.api.gas.Gas; +import mekanism.api.util.StackUtils; + +import net.minecraft.item.ItemStack; + +public class AdvancedMachineInput extends MachineInput +{ + public ItemStack itemStack; + + public Gas gasType; + + public AdvancedMachineInput(ItemStack item, Gas gas) + { + itemStack = item; + gasType = gas; + } + + public boolean isValid() + { + return itemStack != null && gasType != null; + } + + public boolean matches(AdvancedMachineInput input) + { + return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize; + } + + @Override + public int hashIngredients() + { + return StackUtils.hashItemStack(itemStack) << 8 | gasType.getID(); + } + + @Override + public boolean testEquality(MachineInput other) + { + return other instanceof AdvancedMachineInput && StackUtils.equalsWildcardWithNBT(itemStack, ((AdvancedMachineInput)other).itemStack) && gasType.getID() == ((AdvancedMachineInput)other).gasType.getID(); + } +} diff --git a/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java b/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java new file mode 100644 index 000000000..4ca3b8bda --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java @@ -0,0 +1,134 @@ +package mekanism.common.recipe.inputs; + +import mekanism.api.gas.GasStack; +import mekanism.api.gas.GasTank; + +/** + * An input of gasses for recipe use. + * @author aidancbrady + * + */ +public class ChemicalPairInput extends MachineInput +{ + /** The left gas of this chemical input */ + public GasStack leftGas; + + /** The right gas of this chemical input */ + public GasStack rightGas; + + /** + * Creates a chemical input with two defined gasses. + * @param left - left gas + * @param right - right gas + */ + public ChemicalPairInput(GasStack left, GasStack right) + { + leftGas = left; + rightGas = right; + } + + /** + * If this is a valid ChemicalPair + * @return + */ + public boolean isValid() + { + return leftGas != null && rightGas != null; + } + + /** + * Whether or not the defined input contains the same gasses and at least the required amount of the defined gasses as this input. + * @param input - input to check + * @return if the input meets this input's requirements + */ + public boolean meetsInput(ChemicalPairInput input) + { + return meets(input) || meets(input.swap()); + } + + /** + * Swaps the right gas and left gas of this input. + * @return a swapped ChemicalInput + */ + public ChemicalPairInput swap() + { + return new ChemicalPairInput(rightGas, leftGas); + } + + /** + * Draws the needed amount of gas from each tank. + * @param leftTank - left tank to draw from + * @param rightTank - right tank to draw from + */ + public void draw(GasTank leftTank, GasTank rightTank) + { + if(meets(new ChemicalPairInput(leftTank.getGas(), rightTank.getGas()))) + { + leftTank.draw(leftGas.amount, true); + rightTank.draw(rightGas.amount, true); + } + else if(meets(new ChemicalPairInput(rightTank.getGas(), leftTank.getGas()))) + { + leftTank.draw(rightGas.amount, true); + rightTank.draw(leftGas.amount, true); + } + } + + /** + * Whether or not one of this ChemicalInput's GasStack entry's gas type is equal to the gas type of the given gas. + * @param stack - stack to check + * @return if the stack's gas type is contained in this ChemicalInput + */ + public boolean containsType(GasStack stack) + { + if(stack == null || stack.amount == 0) + { + return false; + } + + return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); + } + + /** + * Actual implementation of meetsInput(), performs the checks. + * @param input - input to check + * @return if the input meets this input's requirements + */ + private boolean meets(ChemicalPairInput input) + { + if(input == null || !input.isValid()) + { + return false; + } + + if(input.leftGas.getGas() != leftGas.getGas() || input.rightGas.getGas() != rightGas.getGas()) + { + return false; + } + + return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; + } + + public ChemicalPairInput copy() + { + return new ChemicalPairInput(leftGas.copy(), rightGas.copy()); + } + + @Override + public int hashIngredients() + { + return (leftGas.hashCode() << 8 | rightGas.hashCode()) + (rightGas.hashCode() << 8 | leftGas.hashCode()); + } + + @Override + public boolean testEquality(MachineInput other) + { + if(other instanceof ChemicalPairInput) + { + int leftID = ((ChemicalPairInput)other).leftGas.hashCode(); + int rightID = ((ChemicalPairInput)other).rightGas.hashCode(); + return (leftID == leftGas.hashCode() && rightID == rightGas.hashCode()) || (leftID == rightGas.hashCode() && rightID == leftGas.hashCode()); + } + return false; + } +} diff --git a/src/main/java/mekanism/common/recipe/inputs/FluidInput.java b/src/main/java/mekanism/common/recipe/inputs/FluidInput.java new file mode 100644 index 000000000..6909c0466 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/FluidInput.java @@ -0,0 +1,25 @@ +package mekanism.common.recipe.inputs; + +import net.minecraftforge.fluids.FluidStack; + +public class FluidInput extends MachineInput +{ + public FluidStack ingredient; + + public FluidInput(FluidStack stack) + { + ingredient = stack; + } + + @Override + public int hashIngredients() + { + return ingredient.hashCode(); + } + + @Override + public boolean testEquality(MachineInput other) + { + return other instanceof FluidInput && ingredient.equals(((FluidInput)other).ingredient); + } +} diff --git a/src/main/java/mekanism/common/recipe/inputs/GasInput.java b/src/main/java/mekanism/common/recipe/inputs/GasInput.java new file mode 100644 index 000000000..f9fd26939 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/GasInput.java @@ -0,0 +1,25 @@ +package mekanism.common.recipe.inputs; + +import mekanism.api.gas.GasStack; + +public class GasInput extends MachineInput +{ + public GasStack ingredient; + + public GasInput(GasStack stack) + { + ingredient = stack; + } + + @Override + public int hashIngredients() + { + return ingredient.hashCode(); + } + + @Override + public boolean testEquality(MachineInput other) + { + return other instanceof GasInput && ((GasInput)other).ingredient.hashCode() == ingredient.hashCode(); + } +} diff --git a/src/main/java/mekanism/api/infuse/InfusionInput.java b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java similarity index 55% rename from src/main/java/mekanism/api/infuse/InfusionInput.java rename to src/main/java/mekanism/common/recipe/inputs/InfusionInput.java index edbad48cd..03064a4f9 100644 --- a/src/main/java/mekanism/api/infuse/InfusionInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java @@ -1,4 +1,7 @@ -package mekanism.api.infuse; +package mekanism.common.recipe.inputs; + +import mekanism.api.infuse.InfuseType; +import mekanism.api.util.StackUtils; import net.minecraft.item.ItemStack; @@ -7,7 +10,7 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public class InfusionInput +public class InfusionInput extends MachineInput { /** The type of this infusion */ public InfuseType infusionType; @@ -29,4 +32,21 @@ public class InfusionInput { return new InfusionInput(type, stored, itemstack); } + + @Override + public int hashIngredients() + { + return infusionType.unlocalizedName.hashCode() << 8 | StackUtils.hashItemStack(inputStack); + } + + @Override + public boolean testEquality(MachineInput other) + { + if(other instanceof InfusionInput) + { + InfusionInput ii = (InfusionInput)other; + return infusionType == ii.infusionType && StackUtils.equalsWildcardWithNBT(inputStack, ii.inputStack); + } + return false; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java b/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java new file mode 100644 index 000000000..37f92b038 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java @@ -0,0 +1,24 @@ +package mekanism.common.recipe.inputs; + +public class IntegerInput extends MachineInput +{ + public int ingredient; + + public IntegerInput(int integer) + { + ingredient = integer; + } + + + @Override + public int hashIngredients() + { + return ingredient; + } + + @Override + public boolean testEquality(MachineInput other) + { + return other instanceof IntegerInput && ingredient == ((IntegerInput)other).ingredient; + } +} diff --git a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java new file mode 100644 index 000000000..8bfdd0e79 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java @@ -0,0 +1,27 @@ +package mekanism.common.recipe.inputs; + +import mekanism.api.util.StackUtils; + +import net.minecraft.item.ItemStack; + +public class ItemStackInput extends MachineInput +{ + public ItemStack ingredient; + + public ItemStackInput(ItemStack stack) + { + ingredient = stack; + } + + @Override + public int hashIngredients() + { + return StackUtils.hashItemStack(ingredient); + } + + @Override + public boolean testEquality(MachineInput other) + { + return other instanceof ItemStackInput && StackUtils.equalsWildcardWithNBT(ingredient, ((ItemStackInput)other).ingredient); + } +} diff --git a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java new file mode 100644 index 000000000..e0eabe445 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java @@ -0,0 +1,34 @@ +package mekanism.common.recipe.inputs; + +public abstract class MachineInput +{ + public abstract int hashIngredients(); + + /** + * Test equality to another input. + * This should return true if the input matches this one, + * IGNORING AMOUNTS. + * Allows usage of HashMap optimisation to get recipes. + * @param other + * @return + */ + public abstract boolean testEquality(MachineInput other); + + @Override + public int hashCode() + { + return hashIngredients(); + } + + @Override + public boolean equals(Object other) + { + if(other instanceof MachineInput) + { + return testEquality((MachineInput)other); + } + return false; + } + + +} diff --git a/src/main/java/mekanism/api/recipe/PressurizedReactants.java b/src/main/java/mekanism/common/recipe/inputs/PressurizedReactants.java similarity index 85% rename from src/main/java/mekanism/api/recipe/PressurizedReactants.java rename to src/main/java/mekanism/common/recipe/inputs/PressurizedReactants.java index a34f95643..91380991a 100644 --- a/src/main/java/mekanism/api/recipe/PressurizedReactants.java +++ b/src/main/java/mekanism/common/recipe/inputs/PressurizedReactants.java @@ -1,4 +1,4 @@ -package mekanism.api.recipe; +package mekanism.common.recipe.inputs; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; @@ -11,7 +11,7 @@ import net.minecraftforge.fluids.FluidTank; /** * An input of a gas, a fluid and an item for the pressurized reaction chamber */ -public class PressurizedReactants +public class PressurizedReactants extends MachineInput { private ItemStack theSolid; private FluidStack theFluid; @@ -103,7 +103,7 @@ public class PressurizedReactants * @param input - input to check * @return if the input meets this input's requirements */ - private boolean meets(PressurizedReactants input) + public boolean meets(PressurizedReactants input) { if(input == null || !input.isValid()) { @@ -137,4 +137,21 @@ public class PressurizedReactants { return theGas; } + + @Override + public int hashIngredients() + { + return StackUtils.hashItemStack(theSolid) << 16 | theFluid.hashCode() << 8 | theGas.hashCode(); + } + + @Override + public boolean testEquality(MachineInput other) + { + if(other instanceof PressurizedReactants) + { + PressurizedReactants pr = (PressurizedReactants)other; + return pr.containsType(theSolid) && pr.containsType(theFluid) && pr.containsType(theGas); + } + return false; + } } diff --git a/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java new file mode 100644 index 000000000..abf8b0f49 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java @@ -0,0 +1,21 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasRegistry; +import mekanism.common.recipe.inputs.AdvancedMachineInput; +import mekanism.common.recipe.outputs.ItemStackOutput; + +import net.minecraft.item.ItemStack; + +public class AdvancedMachineRecipe extends MachineRecipe +{ + public AdvancedMachineRecipe(ItemStack input, String gasName, ItemStack output) + { + super(new AdvancedMachineInput(input, GasRegistry.getGas(gasName)), new ItemStackOutput(output)); + } + + public AdvancedMachineRecipe(ItemStack input, Gas gas, ItemStack output) + { + super(new AdvancedMachineInput(input, gas), new ItemStackOutput(output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java b/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java new file mode 100644 index 000000000..416251a41 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java @@ -0,0 +1,14 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasRegistry; +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.IntegerInput; +import mekanism.common.recipe.outputs.GasOutput; + +public class AmbientGasRecipe extends MachineRecipe +{ + public AmbientGasRecipe(int input, String output) + { + super(new IntegerInput(input), new GasOutput(new GasStack(GasRegistry.getGas(output), 1))); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java new file mode 100644 index 000000000..af5f982c6 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java @@ -0,0 +1,14 @@ +package mekanism.common.recipe.machines; + +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.outputs.ItemStackOutput; + +import net.minecraft.item.ItemStack; + +public class BasicMachineRecipe extends MachineRecipe +{ + public BasicMachineRecipe(ItemStack input, ItemStack output) + { + super(new ItemStackInput(input), new ItemStackOutput(output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java new file mode 100644 index 000000000..742833388 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java @@ -0,0 +1,12 @@ +package mekanism.common.recipe.machines; + +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.outputs.ChanceOutput; + +public class ChanceMachineRecipe extends MachineRecipe +{ + public ChanceMachineRecipe(ItemStackInput input, ChanceOutput output) + { + super(input, output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java b/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java new file mode 100644 index 000000000..b75933948 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java @@ -0,0 +1,13 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.ChemicalPairInput; +import mekanism.common.recipe.outputs.GasOutput; + +public class ChemicalInfuserRecipe extends MachineRecipe +{ + public ChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) + { + super(new ChemicalPairInput(leftInput, rightInput), new GasOutput(output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java b/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java new file mode 100644 index 000000000..fb9a27b4b --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java @@ -0,0 +1,11 @@ +package mekanism.common.recipe.machines; + +import net.minecraft.item.ItemStack; + +public class CombinerRecipe extends AdvancedMachineRecipe +{ + public CombinerRecipe(ItemStack input, ItemStack output) + { + super(input, "liquidStone", output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java b/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java new file mode 100644 index 000000000..ac20ceeb7 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java @@ -0,0 +1,11 @@ +package mekanism.common.recipe.machines; + +import net.minecraft.item.ItemStack; + +public class CrusherRecipe extends BasicMachineRecipe +{ + public CrusherRecipe(ItemStack input, ItemStack output) + { + super(input, output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java b/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java new file mode 100644 index 000000000..297577db4 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java @@ -0,0 +1,15 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.GasInput; +import mekanism.common.recipe.outputs.ItemStackOutput; + +import net.minecraft.item.ItemStack; + +public class CrystallizerRecipe extends MachineRecipe +{ + public CrystallizerRecipe(GasStack input, ItemStack output) + { + super(new GasInput(input), new ItemStackOutput(output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java b/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java new file mode 100644 index 000000000..82ad7e10b --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java @@ -0,0 +1,15 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.outputs.GasOutput; + +import net.minecraft.item.ItemStack; + +public class DissolutionRecipe extends MachineRecipe +{ + public DissolutionRecipe(ItemStack input, GasStack output) + { + super(new ItemStackInput(input), new GasOutput(output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java b/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java new file mode 100644 index 000000000..f46110290 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java @@ -0,0 +1,11 @@ +package mekanism.common.recipe.machines; + +import net.minecraft.item.ItemStack; + +public class EnrichmentRecipe extends BasicMachineRecipe +{ + public EnrichmentRecipe(ItemStack input, ItemStack output) + { + super(input, output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java b/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java new file mode 100644 index 000000000..dfc27ed58 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java @@ -0,0 +1,11 @@ +package mekanism.common.recipe.machines; + +import net.minecraft.item.ItemStack; + +public class InjectionRecipe extends AdvancedMachineRecipe +{ + public InjectionRecipe(ItemStack input, String gasName, ItemStack output) + { + super(input, gasName, output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java new file mode 100644 index 000000000..f1cfaf579 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java @@ -0,0 +1,26 @@ +package mekanism.common.recipe.machines; + +import mekanism.common.recipe.inputs.MachineInput; +import mekanism.common.recipe.outputs.MachineOutput; + +public abstract class MachineRecipe +{ + public INPUT recipeInput; + public OUTPUT recipeOutput; + + public MachineRecipe(INPUT input, OUTPUT output) + { + recipeInput = input; + recipeOutput = output; + } + + public INPUT getInput() + { + return recipeInput; + } + + public OUTPUT getOutput() + { + return recipeOutput; + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java b/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java new file mode 100644 index 000000000..6303fe1eb --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java @@ -0,0 +1,14 @@ +package mekanism.common.recipe.machines; + +import mekanism.common.recipe.inputs.InfusionInput; +import mekanism.common.recipe.outputs.InfusionOutput; + +import net.minecraft.item.ItemStack; + +public class MetallurgicInfuserRecipe extends MachineRecipe +{ + public MetallurgicInfuserRecipe(InfusionInput input, ItemStack output) + { + super(input, InfusionOutput.getInfusion(input, output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java b/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java new file mode 100644 index 000000000..e867be224 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java @@ -0,0 +1,11 @@ +package mekanism.common.recipe.machines; + +import net.minecraft.item.ItemStack; + +public class OsmiumCompressorRecipe extends AdvancedMachineRecipe +{ + public OsmiumCompressorRecipe(ItemStack input, ItemStack output) + { + super(input, "liquidOsmium", output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java b/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java new file mode 100644 index 000000000..e3893c25a --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java @@ -0,0 +1,15 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.outputs.GasOutput; + +import net.minecraft.item.ItemStack; + +public class OxidationRecipe extends MachineRecipe +{ + public OxidationRecipe(ItemStack input, GasStack output) + { + super(new ItemStackInput(input), new GasOutput(output)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java b/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java new file mode 100644 index 000000000..a13cb5192 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java @@ -0,0 +1,33 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.outputs.PressurizedProducts; +import mekanism.common.recipe.inputs.PressurizedReactants; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class PressurizedRecipe extends MachineRecipe +{ + public double extraEnergy; + + public int ticks; + + public PressurizedRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double energy, int duration) + { + this(new PressurizedReactants(inputSolid, inputFluid, inputGas), new PressurizedProducts(outputSolid, outputGas), energy, duration); + } + + public PressurizedRecipe(PressurizedReactants pressurizedReactants, PressurizedProducts pressurizedProducts, double energy, int duration) + { + super(pressurizedReactants, pressurizedProducts); + + extraEnergy = energy; + ticks = duration; + } + + public PressurizedRecipe copy() + { + return new PressurizedRecipe(getInput().copy(), getOutput().copy(), extraEnergy, ticks); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java b/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java new file mode 100644 index 000000000..26b538b04 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java @@ -0,0 +1,11 @@ +package mekanism.common.recipe.machines; + +import net.minecraft.item.ItemStack; + +public class PurificationRecipe extends AdvancedMachineRecipe +{ + public PurificationRecipe(ItemStack input, ItemStack output) + { + super(input, "oxygen", output); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java b/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java new file mode 100644 index 000000000..f6c0d4709 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java @@ -0,0 +1,19 @@ +package mekanism.common.recipe.machines; + +import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.outputs.ChanceOutput; + +import net.minecraft.item.ItemStack; + +public class SawmillRecipe extends ChanceMachineRecipe +{ + public SawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) + { + super(new ItemStackInput(input), new ChanceOutput(primaryOutput, secondaryOutput, chance)); + } + + public SawmillRecipe(ItemStack input, ItemStack primaryOutput) + { + super(new ItemStackInput(input), new ChanceOutput(primaryOutput)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java b/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java new file mode 100644 index 000000000..cbc763895 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java @@ -0,0 +1,15 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.FluidInput; +import mekanism.common.recipe.outputs.ChemicalPairOutput; + +import net.minecraftforge.fluids.FluidStack; + +public class SeparatorRecipe extends MachineRecipe +{ + public SeparatorRecipe(FluidStack input, GasStack left, GasStack right) + { + super(new FluidInput(input), new ChemicalPairOutput(left, right)); + } +} diff --git a/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java b/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java new file mode 100644 index 000000000..3d0153ac3 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java @@ -0,0 +1,13 @@ +package mekanism.common.recipe.machines; + +import mekanism.api.gas.GasStack; +import mekanism.common.recipe.inputs.GasInput; +import mekanism.common.recipe.outputs.GasOutput; + +public class WasherRecipe extends MachineRecipe +{ + public WasherRecipe(GasStack input, GasStack output) + { + super(new GasInput(input), new GasOutput(output)); + } +} diff --git a/src/main/java/mekanism/api/recipe/ChanceOutput.java b/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java similarity index 90% rename from src/main/java/mekanism/api/recipe/ChanceOutput.java rename to src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java index b1f6f0269..dc9023238 100644 --- a/src/main/java/mekanism/api/recipe/ChanceOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java @@ -1,4 +1,4 @@ -package mekanism.api.recipe; +package mekanism.common.recipe.outputs; import java.util.Random; @@ -6,7 +6,7 @@ import mekanism.api.util.StackUtils; import net.minecraft.item.ItemStack; -public class ChanceOutput +public class ChanceOutput extends MachineOutput { private static Random rand = new Random(); diff --git a/src/main/java/mekanism/api/recipe/ChemicalPair.java b/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java similarity index 79% rename from src/main/java/mekanism/api/recipe/ChemicalPair.java rename to src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java index 64e06002c..17d6fbae7 100644 --- a/src/main/java/mekanism/api/recipe/ChemicalPair.java +++ b/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java @@ -1,4 +1,4 @@ -package mekanism.api.recipe; +package mekanism.common.recipe.outputs; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; @@ -8,7 +8,7 @@ import mekanism.api.gas.GasTank; * @author aidancbrady * */ -public class ChemicalPair +public class ChemicalPairOutput extends MachineOutput { /** The left gas of this chemical input */ public GasStack leftGas; @@ -21,7 +21,7 @@ public class ChemicalPair * @param left - left gas * @param right - right gas */ - public ChemicalPair(GasStack left, GasStack right) + public ChemicalPairOutput(GasStack left, GasStack right) { leftGas = left; rightGas = right; @@ -41,7 +41,7 @@ public class ChemicalPair * @param input - input to check * @return if the input meets this input's requirements */ - public boolean meetsInput(ChemicalPair input) + public boolean meetsInput(ChemicalPairOutput input) { return meets(input) || meets(input.swap()); } @@ -50,9 +50,9 @@ public class ChemicalPair * Swaps the right gas and left gas of this input. * @return a swapped ChemicalInput */ - public ChemicalPair swap() + public ChemicalPairOutput swap() { - return new ChemicalPair(rightGas, leftGas); + return new ChemicalPairOutput(rightGas, leftGas); } /** @@ -62,12 +62,12 @@ public class ChemicalPair */ public void draw(GasTank leftTank, GasTank rightTank) { - if(meets(new ChemicalPair(leftTank.getGas(), rightTank.getGas()))) + if(meets(new ChemicalPairOutput(leftTank.getGas(), rightTank.getGas()))) { leftTank.draw(leftGas.amount, true); rightTank.draw(rightGas.amount, true); } - else if(meets(new ChemicalPair(rightTank.getGas(), leftTank.getGas()))) + else if(meets(new ChemicalPairOutput(rightTank.getGas(), leftTank.getGas()))) { leftTank.draw(rightGas.amount, true); rightTank.draw(leftGas.amount, true); @@ -94,7 +94,7 @@ public class ChemicalPair * @param input - input to check * @return if the input meets this input's requirements */ - private boolean meets(ChemicalPair input) + private boolean meets(ChemicalPairOutput input) { if(input == null || !input.isValid()) { @@ -109,8 +109,8 @@ public class ChemicalPair return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; } - public ChemicalPair copy() + public ChemicalPairOutput copy() { - return new ChemicalPair(leftGas.copy(), rightGas.copy()); + return new ChemicalPairOutput(leftGas.copy(), rightGas.copy()); } } diff --git a/src/main/java/mekanism/common/recipe/outputs/GasOutput.java b/src/main/java/mekanism/common/recipe/outputs/GasOutput.java new file mode 100644 index 000000000..f80eeb658 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/outputs/GasOutput.java @@ -0,0 +1,13 @@ +package mekanism.common.recipe.outputs; + +import mekanism.api.gas.GasStack; + +public class GasOutput extends MachineOutput +{ + public GasStack output; + + public GasOutput(GasStack stack) + { + output = stack; + } +} diff --git a/src/main/java/mekanism/api/infuse/InfusionOutput.java b/src/main/java/mekanism/common/recipe/outputs/InfusionOutput.java similarity index 83% rename from src/main/java/mekanism/api/infuse/InfusionOutput.java rename to src/main/java/mekanism/common/recipe/outputs/InfusionOutput.java index ad6d79a62..323479bf5 100644 --- a/src/main/java/mekanism/api/infuse/InfusionOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/InfusionOutput.java @@ -1,4 +1,6 @@ -package mekanism.api.infuse; +package mekanism.common.recipe.outputs; + +import mekanism.common.recipe.inputs.InfusionInput; import net.minecraft.item.ItemStack; @@ -7,7 +9,7 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public class InfusionOutput +public class InfusionOutput extends MachineOutput { /** The input infusion */ public InfusionInput infusionInput; diff --git a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java new file mode 100644 index 000000000..9d12fd629 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java @@ -0,0 +1,13 @@ +package mekanism.common.recipe.outputs; + +import net.minecraft.item.ItemStack; + +public class ItemStackOutput extends MachineOutput +{ + public ItemStack output; + + public ItemStackOutput(ItemStack stack) + { + output = stack; + } +} diff --git a/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java b/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java new file mode 100644 index 000000000..33720d4a3 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java @@ -0,0 +1,5 @@ +package mekanism.common.recipe.outputs; + +public class MachineOutput +{ +} diff --git a/src/main/java/mekanism/api/recipe/PressurizedProducts.java b/src/main/java/mekanism/common/recipe/outputs/PressurizedProducts.java similarity index 89% rename from src/main/java/mekanism/api/recipe/PressurizedProducts.java rename to src/main/java/mekanism/common/recipe/outputs/PressurizedProducts.java index 7eff80806..f9da94cfa 100644 --- a/src/main/java/mekanism/api/recipe/PressurizedProducts.java +++ b/src/main/java/mekanism/common/recipe/outputs/PressurizedProducts.java @@ -1,11 +1,11 @@ -package mekanism.api.recipe; +package mekanism.common.recipe.outputs; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import net.minecraft.item.ItemStack; -public class PressurizedProducts +public class PressurizedProducts extends MachineOutput { private ItemStack itemOutput; private GasStack gasOutput; diff --git a/src/main/java/mekanism/common/recipe/outputs/StringOutput.java b/src/main/java/mekanism/common/recipe/outputs/StringOutput.java new file mode 100644 index 000000000..07a1f52b0 --- /dev/null +++ b/src/main/java/mekanism/common/recipe/outputs/StringOutput.java @@ -0,0 +1,5 @@ +package mekanism.common.recipe.outputs; + +public class StringOutput extends MachineOutput +{ +} diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java index c0a025db4..703b0d5f0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java @@ -9,7 +9,7 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; -import mekanism.api.recipe.AdvancedInput; +import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.api.util.StackUtils; import mekanism.common.Mekanism; import mekanism.common.MekanismItems; @@ -140,11 +140,11 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM for(Object obj : getRecipes().entrySet()) { - if(((Map.Entry)obj).getKey() instanceof AdvancedInput) + if(((Map.Entry)obj).getKey() instanceof AdvancedMachineInput) { Map.Entry entry = (Map.Entry)obj; - ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack; + ItemStack stack = ((AdvancedMachineInput)entry.getKey()).itemStack; if(StackUtils.equalsWildcard(stack, itemStack)) { @@ -207,7 +207,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM @Override public void operate() { - ItemStack itemstack = RecipeHandler.getOutput(new AdvancedInput(inventory[0], gasTank.getGas().getGas()), true, getRecipes()); + ItemStack itemstack = RecipeHandler.getOutput(new AdvancedMachineInput(inventory[0], gasTank.getGas().getGas()), true, getRecipes()); if(inventory[0].stackSize <= 0) { @@ -234,7 +234,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM return false; } - ItemStack itemstack = RecipeHandler.getOutput(new AdvancedInput(inventory[0], gasTank.getGas().getGas()), false, getRecipes()); + ItemStack itemstack = RecipeHandler.getOutput(new AdvancedMachineInput(inventory[0], gasTank.getGas().getGas()), false, getRecipes()); if(itemstack == null) { diff --git a/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java b/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java index 930adc05d..be164ba77 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java +++ b/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java @@ -11,6 +11,8 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; +import mekanism.common.recipe.RecipeHandler; +import mekanism.common.recipe.RecipeHandler.Recipe; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; @@ -21,17 +23,11 @@ public class TileEntityAmbientAccumulator extends TileEntityContainerBlock imple { public GasTank collectedGas = new GasTank(1000); - public static Map dimensionGases = new HashMap(); + public int cachedDimensionId = 0; + public GasStack cachedGas; public static Random gasRand = new Random(); - static - { - dimensionGases.put(-1, "sulfurDioxideGas"); - dimensionGases.put(+0, "oxygen"); - dimensionGases.put(+1, "tritium"); - } - public TileEntityAmbientAccumulator() { super("AmbientAccumulator"); @@ -43,11 +39,15 @@ public class TileEntityAmbientAccumulator extends TileEntityContainerBlock imple { if(!worldObj.isRemote) { - Gas gasToCollect = GasRegistry.getGas(dimensionGases.get(worldObj.provider.dimensionId)); - - if(gasToCollect != null && gasRand.nextDouble() < 0.05) + if(cachedGas == null || worldObj.provider.dimensionId != cachedDimensionId) { - collectedGas.receive(new GasStack(gasToCollect, 1), true); + cachedDimensionId = worldObj.provider.dimensionId; + cachedGas = RecipeHandler.getDimensionGas(cachedDimensionId); + } + + if(cachedGas != null && gasRand.nextDouble() < 0.05) + { + collectedGas.receive(cachedGas, true); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java index 3551e48ba..229460ebf 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java @@ -3,7 +3,7 @@ package mekanism.common.tile; import java.util.Map; import mekanism.api.EnumColor; -import mekanism.api.recipe.ChanceOutput; +import mekanism.common.recipe.outputs.ChanceOutput; import mekanism.common.MekanismItems; import mekanism.common.SideData; import mekanism.common.recipe.RecipeHandler; diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index 216a63ec8..b6a09aee1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -119,7 +119,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri injectTank.draw(INJECT_USAGE, true); } else { - GasStack stack = RecipeHandler.getItemToGasOutput(inventory[1], true, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); + GasStack stack = RecipeHandler.getDissolutionOutput(inventory[1], true); outputTank.receive(stack, true); injectTank.draw(INJECT_USAGE, true); @@ -171,7 +171,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri { if(slotID == 1) { - return RecipeHandler.getItemToGasOutput(itemstack, false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()) != null; + return RecipeHandler.getDissolutionOutput(itemstack, false) != null; } else if(slotID == 3) { @@ -223,7 +223,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri return false; } - GasStack stack = RecipeHandler.getItemToGasOutput(inventory[1], false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); + GasStack stack = RecipeHandler.getDissolutionOutput(inventory[1], false); if(stack == null || (outputTank.getGas() != null && (outputTank.getGas().getGas() != stack.getGas() || outputTank.getNeeded() < stack.amount))) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index f4949541f..bbdd09df0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -107,7 +107,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp operatingTicks++; } else { - GasStack stack = RecipeHandler.getItemToGasOutput(inventory[0], true, Recipe.CHEMICAL_OXIDIZER.get()); + GasStack stack = RecipeHandler.getOxidizerOutput(inventory[0], true); gasTank.receive(stack, true); operatingTicks = 0; @@ -151,7 +151,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp { if(slotID == 0) { - return RecipeHandler.getItemToGasOutput(itemstack, false, Recipe.CHEMICAL_OXIDIZER.get()) != null; + return RecipeHandler.getOxidizerOutput(itemstack, false) != null; } else if(slotID == 1) { @@ -203,7 +203,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp return false; } - GasStack stack = RecipeHandler.getItemToGasOutput(inventory[0], false, Recipe.CHEMICAL_OXIDIZER.get()); + GasStack stack = RecipeHandler.getOxidizerOutput(inventory[0], false); if(stack == null || (gasTank.getGas() != null && (gasTank.getGas().getGas() != stack.getGas() || gasTank.getNeeded() < stack.amount))) { diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index 41977ebc7..f7254210b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -13,7 +13,7 @@ import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; -import mekanism.api.recipe.ChemicalPair; +import mekanism.common.recipe.outputs.ChemicalPairOutput; import mekanism.common.Mekanism; import mekanism.common.base.ISustainedData; import mekanism.common.block.BlockMachine.MachineType; @@ -204,7 +204,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp return canFillWithSwap(RecipeHandler.getElectrolyticSeparatorOutput(fluidTank, false)) && getEnergy() >= general.FROM_H2*2; } - public boolean canFillWithSwap(ChemicalPair gases) + public boolean canFillWithSwap(ChemicalPairOutput gases) { if(gases == null) { @@ -214,13 +214,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp return canFill(gases) || canFill(gases.swap()); } - public boolean canFill(ChemicalPair gases) + public boolean canFill(ChemicalPairOutput gases) { return (leftTank.canReceive(gases.leftGas.getGas()) && leftTank.getNeeded() >= gases.leftGas.amount && rightTank.canReceive(gases.rightGas.getGas()) && rightTank.getNeeded() >= gases.rightGas.amount); } - public void fillTanks(ChemicalPair gases) + public void fillTanks(ChemicalPairOutput gases) { if(gases == null) return; diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 09e6e14f3..6f7404385 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -10,8 +10,8 @@ import mekanism.api.Range4D; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; -import mekanism.api.infuse.InfusionInput; -import mekanism.api.infuse.InfusionOutput; +import mekanism.common.recipe.inputs.InfusionInput; +import mekanism.common.recipe.outputs.InfusionOutput; import mekanism.common.Mekanism; import mekanism.common.MekanismItems; import mekanism.common.PacketHandler; diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index e0ff26877..aff1a625c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -12,8 +12,8 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; -import mekanism.api.recipe.PressurizedProducts; -import mekanism.api.recipe.PressurizedRecipe; +import mekanism.common.recipe.outputs.PressurizedProducts; +import mekanism.common.recipe.machines.PressurizedRecipe; import mekanism.common.SideData; import mekanism.common.base.ISustainedData; import mekanism.common.block.BlockMachine.MachineType; @@ -154,16 +154,16 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl { PressurizedRecipe recipe = getRecipe(); - recipe.reactants.use(inventory[0], inputFluidTank, inputGasTank); + recipe.getInput().use(inventory[0], inputFluidTank, inputGasTank); if(inventory[0].stackSize <= 0) { inventory[0] = null; } - recipe.products.fillTank(outputGasTank); + recipe.getOutput().fillTank(outputGasTank); - recipe.products.addProducts(inventory, 2); + recipe.getOutput().addProducts(inventory, 2); markDirty(); ejectorComponent.onOutput(); @@ -179,7 +179,7 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl return false; } - PressurizedProducts products = recipe.products; + PressurizedProducts products = recipe.getOutput(); if(products.getItemOutput() != null) {