Fix NEI support to dynamically accept different gas types

This commit is contained in:
Aidan C. Brady 2014-01-18 12:16:14 -05:00
parent ee2b81c3fd
commit 740f4581b0
5 changed files with 36 additions and 16 deletions

View file

@ -11,6 +11,7 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import mekanism.api.AdvancedInput; import mekanism.api.AdvancedInput;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.common.ObfuscatedNames; import mekanism.common.ObfuscatedNames;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
@ -34,7 +35,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
public abstract Set<Entry<AdvancedInput, ItemStack>> getRecipes(); public abstract Set<Entry<AdvancedInput, ItemStack>> getRecipes();
public abstract List<ItemStack> getFuelStacks(); public abstract List<ItemStack> getFuelStacks(Gas gasType);
@Override @Override
public void drawBackground(int i) public void drawBackground(int i)
@ -77,9 +78,9 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
{ {
if(outputId.equals(getRecipeId())) if(outputId.equals(getRecipeId()))
{ {
for(Map.Entry irecipe : getRecipes()) for(Map.Entry<AdvancedInput, ItemStack> irecipe : getRecipes())
{ {
arecipes.add(new CachedIORecipe(irecipe, getFuelStacks())); arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType)));
} }
} }
else { else {
@ -90,11 +91,11 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
@Override @Override
public void loadCraftingRecipes(ItemStack result) public void loadCraftingRecipes(ItemStack result)
{ {
for(Map.Entry irecipe : getRecipes()) for(Map.Entry<AdvancedInput, ItemStack> irecipe : getRecipes())
{ {
if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) 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()) 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)) if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getKey().itemStack, ingredient))
{ {
arecipes.add(new CachedIORecipe(irecipe, getFuelStacks())); arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getKey().gasType)));
} }
} }
} }

View file

@ -1,12 +1,13 @@
package mekanism.client.nei; package mekanism.client.nei;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.api.ListUtils; import mekanism.api.ListUtils;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasRegistry;
import mekanism.client.gui.GuiChemicalInjectionChamber; import mekanism.client.gui.GuiChemicalInjectionChamber;
import mekanism.common.Mekanism;
import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -45,12 +46,21 @@ public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipe
} }
@Override @Override
public List<ItemStack> getFuelStacks() public List<ItemStack> getFuelStacks(Gas gasType)
{
if(gasType == GasRegistry.getGas("sulfuricAcid"))
{ {
List<ItemStack> fuels = OreDictionary.getOres("dustSulfur"); List<ItemStack> fuels = OreDictionary.getOres("dustSulfur");
fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("sulfuricAcid"))); fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("sulfuricAcid")));
return fuels; return fuels;
} }
else if(gasType == GasRegistry.getGas("water"))
{
return ListUtils.asList(MekanismUtils.getFullGasTank(GasRegistry.getGas("water")));
}
return new ArrayList<ItemStack>();
}
@Override @Override
public Class getGuiClass() public Class getGuiClass()

View file

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.api.ListUtils; import mekanism.api.ListUtils;
import mekanism.api.gas.Gas;
import mekanism.client.gui.GuiCombiner; import mekanism.client.gui.GuiCombiner;
import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.RecipeHandler.Recipe;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -42,7 +43,7 @@ public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler
} }
@Override @Override
public List<ItemStack> getFuelStacks() public List<ItemStack> getFuelStacks(Gas gasType)
{ {
return ListUtils.asList(new ItemStack(Block.cobblestone)); return ListUtils.asList(new ItemStack(Block.cobblestone));
} }

View file

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.api.ListUtils; import mekanism.api.ListUtils;
import mekanism.api.gas.Gas;
import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.client.gui.GuiOsmiumCompressor;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.RecipeHandler.Recipe;
@ -42,7 +43,7 @@ public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler
} }
@Override @Override
public List<ItemStack> getFuelStacks() public List<ItemStack> getFuelStacks(Gas gasType)
{ {
return ListUtils.asList(new ItemStack(Mekanism.Ingot, 1, 1)); return ListUtils.asList(new ItemStack(Mekanism.Ingot, 1, 1));
} }

View file

@ -1,9 +1,11 @@
package mekanism.client.nei; package mekanism.client.nei;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.api.ListUtils; import mekanism.api.ListUtils;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasRegistry;
import mekanism.client.gui.GuiPurificationChamber; import mekanism.client.gui.GuiPurificationChamber;
import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.RecipeHandler.Recipe;
@ -44,11 +46,16 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl
} }
@Override @Override
public List<ItemStack> getFuelStacks() public List<ItemStack> getFuelStacks(Gas gasType)
{
if(gasType == GasRegistry.getGas("oxygen"))
{ {
return ListUtils.asList(new ItemStack(Item.flint), MekanismUtils.getFullGasTank(GasRegistry.getGas("oxygen"))); return ListUtils.asList(new ItemStack(Item.flint), MekanismUtils.getFullGasTank(GasRegistry.getGas("oxygen")));
} }
return new ArrayList<ItemStack>();
}
@Override @Override
public Class getGuiClass() public Class getGuiClass()
{ {