Finished recipe system for new machines.
This commit is contained in:
parent
b0fbaba62b
commit
90328958bb
7 changed files with 145 additions and 34 deletions
|
@ -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);
|
||||
|
|
|
@ -710,6 +710,18 @@ public class Mekanism
|
|||
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));
|
||||
InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20));
|
||||
|
@ -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"));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
@ -238,17 +239,75 @@ public final class RecipeHandler
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the InfusionOutput of the ItemStack in the parameters.
|
||||
* 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<GasStack, GasStack> recipes = Recipe.CHEMICAL_WASHER.get();
|
||||
|
||||
for(Map.Entry<GasStack, GasStack> 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<GasStack, GasStack> recipes = Recipe.CHEMICAL_WASHER.get();
|
||||
|
||||
for(Map.Entry<GasStack, GasStack> 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 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<ItemStack, GasStack> recipes)
|
||||
{
|
||||
if(itemstack != null)
|
||||
{
|
||||
HashMap<ItemStack, GasStack> recipes = Recipe.CHEMICAL_OXIDIZER.get();
|
||||
|
||||
for(Map.Entry<ItemStack, GasStack> 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<ItemStack, ItemStack> 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
|
||||
|
@ -407,6 +442,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<ItemStack, ItemStack> 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
|
||||
{
|
||||
ENRICHMENT_CHAMBER(new HashMap<ItemStack, ItemStack>()),
|
||||
|
|
|
@ -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)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue