diff --git a/common/mekanism/api/gas/OreGas.java b/common/mekanism/api/gas/OreGas.java index 86dd31f2b..b8e02b6e2 100644 --- a/common/mekanism/api/gas/OreGas.java +++ b/common/mekanism/api/gas/OreGas.java @@ -5,6 +5,7 @@ import net.minecraft.util.StatCollector; public class OreGas extends Gas { private String oreName; + private OreGas cleanGas; public OreGas(String s, String name) { @@ -13,6 +14,23 @@ public class OreGas extends Gas oreName = name; } + public boolean isClean() + { + return getCleanGas() == null; + } + + public OreGas getCleanGas() + { + return cleanGas; + } + + public OreGas setCleanGas(OreGas gas) + { + cleanGas = gas; + + return this; + } + public String getOreName() { return StatCollector.translateToLocal(oreName); diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 86d061a33..5da070bc2 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -709,6 +709,18 @@ public class Mekanism //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("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1))); + + //Chemical Washer Recipes + for(Gas gas : GasRegistry.getRegisteredGasses()) + { + if(gas instanceof OreGas && !((OreGas)gas).isClean()) + { + OreGas oreGas = (OreGas)gas; + + RecipeHandler.addChemicalWasherRecipe(new GasStack(oreGas, 1), new GasStack(oreGas.getCleanGas(), 1)); + RecipeHandler.addChemicalCrystalizerRecipe(new GasStack(oreGas, 200), new ItemStack(Crystal, 1, Resource.getFromName(oreGas.getName()).ordinal())); + } + } //Infuse objects InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); @@ -1071,8 +1083,8 @@ public class Mekanism { String name = resource.getName(); - GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setVisible(false)); - GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); + OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); + GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false)); } FluidRegistry.registerFluid(new Fluid("brine")); diff --git a/common/mekanism/common/Resource.java b/common/mekanism/common/Resource.java index 969b99356..faf554fec 100644 --- a/common/mekanism/common/Resource.java +++ b/common/mekanism/common/Resource.java @@ -18,6 +18,19 @@ public enum Resource name = s; } + public static Resource getFromName(String s) + { + for(Resource r : values()) + { + if(r.name.toLowerCase().equals(s.toLowerCase())) + { + return r; + } + } + + return null; + } + public String getName() { return name; diff --git a/common/mekanism/common/integration/OreDictManager.java b/common/mekanism/common/integration/OreDictManager.java index e63529286..ea4cf4939 100644 --- a/common/mekanism/common/integration/OreDictManager.java +++ b/common/mekanism/common/integration/OreDictManager.java @@ -220,6 +220,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 6)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 3)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 3)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("copper"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreTin")) @@ -227,6 +228,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 7)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 4)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 4)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("tin"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreOsmium")) @@ -234,6 +236,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 2)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 2)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 2)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("osmium"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreIron")) @@ -241,6 +244,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 0)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 0)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 0)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("iron"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreGold")) @@ -248,6 +252,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 1)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 1)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 1)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("gold"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreSilver")) @@ -255,6 +260,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 8)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 5)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 5)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("silver"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreLead")) @@ -262,6 +268,7 @@ public final class OreDictManager RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 9)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 7)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 7)); + RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("lead"), 1000)); } for(ItemStack ore : OreDictionary.getOres("oreNickel")) diff --git a/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java b/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java index 3c1aa674e..3735c09fe 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java @@ -4,6 +4,7 @@ import mekanism.api.gas.IGasItem; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotStorageTank; import mekanism.common.recipe.RecipeHandler; +import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.tile.TileEntityChemicalOxidizer; import mekanism.common.util.ChargeUtils; import net.minecraft.entity.player.EntityPlayer; @@ -68,7 +69,7 @@ public class ContainerChemicalOxidizer extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(RecipeHandler.getChemicalOxidizerOutput(slotStack, false) != null) + if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_OXIDIZER.get()) != null) { if(!mergeItemStack(slotStack, 0, 1, true)) { diff --git a/common/mekanism/common/recipe/RecipeHandler.java b/common/mekanism/common/recipe/RecipeHandler.java index adcdae405..2799682d5 100644 --- a/common/mekanism/common/recipe/RecipeHandler.java +++ b/common/mekanism/common/recipe/RecipeHandler.java @@ -6,6 +6,7 @@ import java.util.Map; import mekanism.api.AdvancedInput; import mekanism.api.ChanceOutput; import mekanism.api.ChemicalPair; +import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; @@ -236,19 +237,77 @@ public final class RecipeHandler return null; } + + /** + * Gets the Chemical Washer GasStack output of the defined GasTank input. + * @param itemstack - input GasTank + * @param removeGas - whether or not to use gas in the gas tank + * @return output GasStack + */ + public static GasStack getChemicalDissolutionChamberOutput(GasTank gasTank, boolean removeGas) + { + GasStack gas = gasTank.getGas(); + + if(gas != null) + { + HashMap recipes = Recipe.CHEMICAL_WASHER.get(); + + for(Map.Entry entry : recipes.entrySet()) + { + GasStack key = (GasStack)entry.getKey(); + + if(key != null && key.getGas() == gas.getGas() && key.amount >= gas.amount) + { + gasTank.draw(key.amount, removeGas); + + return entry.getValue().copy(); + } + } + } + + return null; + } + + /** + * Gets the Chemical Washer GasStack output of the defined GasTank input. + * @param gasTank - input GasTank + * @param removeGas - whether or not to use gas in the gas tank + * @return output GasStack + */ + public static GasStack getChemicalWasherOutput(GasTank gasTank, boolean removeGas) + { + GasStack gas = gasTank.getGas(); + + if(gas != null) + { + HashMap recipes = Recipe.CHEMICAL_WASHER.get(); + + for(Map.Entry entry : recipes.entrySet()) + { + GasStack key = (GasStack)entry.getKey(); + + if(key != null && key.getGas() == gas.getGas() && key.amount >= gas.amount) + { + gasTank.draw(key.amount, removeGas); + + return entry.getValue().copy(); + } + } + } + + return null; + } /** - * Gets the InfusionOutput of the ItemStack in the parameters. + * 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 getChemicalOxidizerOutput(ItemStack itemstack, boolean stackDecrease) + public static GasStack getItemToGasOutput(ItemStack itemstack, boolean stackDecrease, HashMap recipes) { if(itemstack != null) { - HashMap recipes = Recipe.CHEMICAL_OXIDIZER.get(); - for(Map.Entry entry : recipes.entrySet()) { ItemStack stack = (ItemStack)entry.getKey(); @@ -355,30 +414,6 @@ public final class RecipeHandler return null; } - /** - * Gets the output ItemStack of the ItemStack in the parameters. - * @param itemstack - input ItemStack - * @param recipes - Map of recipes - * @return whether the item can be used in a recipe - */ - public static boolean isInRecipe(ItemStack itemstack, Map recipes) - { - if(itemstack != null) - { - for(Map.Entry entry : recipes.entrySet()) - { - ItemStack stack = (ItemStack)entry.getKey(); - - if(StackUtils.equalsWildcard(stack, itemstack)) - { - return true; - } - } - } - - return false; - } - /** * Get the result of electrolysing a given fluid * @param fluidTank - the FluidTank to electrolyse fluid from @@ -406,6 +441,30 @@ public final class RecipeHandler return null; } + + /** + * Gets the output ItemStack of the ItemStack in the parameters. + * @param itemstack - input ItemStack + * @param recipes - Map of recipes + * @return whether the item can be used in a recipe + */ + public static boolean isInRecipe(ItemStack itemstack, Map recipes) + { + if(itemstack != null) + { + for(Map.Entry entry : recipes.entrySet()) + { + ItemStack stack = (ItemStack)entry.getKey(); + + if(StackUtils.equalsWildcard(stack, itemstack)) + { + return true; + } + } + } + + return false; + } public static enum Recipe { diff --git a/common/mekanism/common/tile/TileEntityChemicalOxidizer.java b/common/mekanism/common/tile/TileEntityChemicalOxidizer.java index 7c78cbdf0..0a1ea41c6 100644 --- a/common/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/common/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -19,6 +19,7 @@ import mekanism.common.PacketHandler.Transmission; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity; import mekanism.common.recipe.RecipeHandler; +import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.util.ChargeUtils; import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; @@ -107,7 +108,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen operatingTicks++; } else { - GasStack stack = RecipeHandler.getChemicalOxidizerOutput(inventory[0], true); + GasStack stack = RecipeHandler.getItemToGasOutput(inventory[0], true, Recipe.CHEMICAL_OXIDIZER.get()); gasTank.receive(stack, true); operatingTicks = 0; @@ -152,7 +153,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen { if(slotID == 0) { - return RecipeHandler.getChemicalOxidizerOutput(itemstack, false) != null; + return RecipeHandler.getItemToGasOutput(itemstack, false, Recipe.CHEMICAL_OXIDIZER.get()) != null; } else if(slotID == 1) { @@ -204,7 +205,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen return false; } - GasStack stack = RecipeHandler.getChemicalOxidizerOutput(inventory[0], false); + GasStack stack = RecipeHandler.getItemToGasOutput(inventory[0], false, Recipe.CHEMICAL_OXIDIZER.get()); if(stack == null || (gasTank.getGas() != null && (gasTank.getGas().getGas() != stack.getGas() || gasTank.getNeeded() < stack.amount))) {