From 740f4581b047e9cad2b57c91e1f304c231d8db00 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 18 Jan 2014 12:16:14 -0500 Subject: [PATCH] Fix NEI support to dynamically accept different gas types --- .../nei/AdvancedMachineRecipeHandler.java | 15 +++++++------- ...ChemicalInjectionChamberRecipeHandler.java | 20 ++++++++++++++----- .../client/nei/CombinerRecipeHandler.java | 3 ++- .../nei/OsmiumCompressorRecipeHandler.java | 3 ++- .../nei/PurificationChamberRecipeHandler.java | 11 ++++++++-- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java b/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java index 71c7ec548..5446e1756 100644 --- a/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java +++ b/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java @@ -11,6 +11,7 @@ import java.util.Map.Entry; import java.util.Set; import mekanism.api.AdvancedInput; +import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.common.ObfuscatedNames; import mekanism.common.util.MekanismUtils; @@ -34,7 +35,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler public abstract Set> getRecipes(); - public abstract List getFuelStacks(); + public abstract List getFuelStacks(Gas gasType); @Override public void drawBackground(int i) @@ -77,9 +78,9 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { if(outputId.equals(getRecipeId())) { - for(Map.Entry irecipe : getRecipes()) + for(Map.Entry irecipe : getRecipes()) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks())); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); } } else { @@ -90,11 +91,11 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler @Override public void loadCraftingRecipes(ItemStack result) { - for(Map.Entry irecipe : getRecipes()) + for(Map.Entry irecipe : getRecipes()) { if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks())); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); } } } @@ -108,7 +109,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { if(irecipe.getKey().gasType == ((GasStack)ingredients[0]).getGas()) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks())); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); } } } @@ -124,7 +125,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getKey().itemStack, ingredient)) { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks())); + arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType))); } } } diff --git a/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java b/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java index 25c1d6ef6..e65f80556 100644 --- a/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java @@ -1,12 +1,13 @@ package mekanism.client.nei; +import java.util.ArrayList; import java.util.List; import java.util.Set; import mekanism.api.ListUtils; +import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.client.gui.GuiChemicalInjectionChamber; -import mekanism.common.Mekanism; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; @@ -45,11 +46,20 @@ public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipe } @Override - public List getFuelStacks() + public List getFuelStacks(Gas gasType) { - List fuels = OreDictionary.getOres("dustSulfur"); - fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("sulfuricAcid"))); - return fuels; + if(gasType == GasRegistry.getGas("sulfuricAcid")) + { + List fuels = OreDictionary.getOres("dustSulfur"); + fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("sulfuricAcid"))); + return fuels; + } + else if(gasType == GasRegistry.getGas("water")) + { + return ListUtils.asList(MekanismUtils.getFullGasTank(GasRegistry.getGas("water"))); + } + + return new ArrayList(); } @Override diff --git a/common/mekanism/client/nei/CombinerRecipeHandler.java b/common/mekanism/client/nei/CombinerRecipeHandler.java index a74706065..af16f6e6c 100644 --- a/common/mekanism/client/nei/CombinerRecipeHandler.java +++ b/common/mekanism/client/nei/CombinerRecipeHandler.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Set; import mekanism.api.ListUtils; +import mekanism.api.gas.Gas; import mekanism.client.gui.GuiCombiner; import mekanism.common.recipe.RecipeHandler.Recipe; import net.minecraft.block.Block; @@ -42,7 +43,7 @@ public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler } @Override - public List getFuelStacks() + public List getFuelStacks(Gas gasType) { return ListUtils.asList(new ItemStack(Block.cobblestone)); } diff --git a/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java b/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java index f3396377d..ec8838096 100644 --- a/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java +++ b/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Set; import mekanism.api.ListUtils; +import mekanism.api.gas.Gas; import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.common.Mekanism; import mekanism.common.recipe.RecipeHandler.Recipe; @@ -42,7 +43,7 @@ public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler } @Override - public List getFuelStacks() + public List getFuelStacks(Gas gasType) { return ListUtils.asList(new ItemStack(Mekanism.Ingot, 1, 1)); } diff --git a/common/mekanism/client/nei/PurificationChamberRecipeHandler.java b/common/mekanism/client/nei/PurificationChamberRecipeHandler.java index 5e45ef244..056756e05 100644 --- a/common/mekanism/client/nei/PurificationChamberRecipeHandler.java +++ b/common/mekanism/client/nei/PurificationChamberRecipeHandler.java @@ -1,9 +1,11 @@ package mekanism.client.nei; +import java.util.ArrayList; import java.util.List; import java.util.Set; import mekanism.api.ListUtils; +import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.client.gui.GuiPurificationChamber; import mekanism.common.recipe.RecipeHandler.Recipe; @@ -44,9 +46,14 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl } @Override - public List getFuelStacks() + public List getFuelStacks(Gas gasType) { - return ListUtils.asList(new ItemStack(Item.flint), MekanismUtils.getFullGasTank(GasRegistry.getGas("oxygen"))); + if(gasType == GasRegistry.getGas("oxygen")) + { + return ListUtils.asList(new ItemStack(Item.flint), MekanismUtils.getFullGasTank(GasRegistry.getGas("oxygen"))); + } + + return new ArrayList(); } @Override