From 4d66bb9e9d49e3246a29c52749c46e5f271658e2 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 7 May 2015 20:16:19 +0100 Subject: [PATCH] Started working on the recipe system --- .../techreborn/api/recipe/BaseRecipe.java | 41 +++++++++++++++++++ .../api/recipe/IBaseRecipeType.java | 33 +++++++++++++++ .../techreborn/api/recipe/RecipeHanderer.java | 29 +++++++++++++ .../techreborn/api/recipe/package-info.java | 5 +++ .../recipes/ImplosionCompressorRecipe.java | 15 +++++++ 5 files changed, 123 insertions(+) create mode 100644 src/main/java/techreborn/api/recipe/BaseRecipe.java create mode 100644 src/main/java/techreborn/api/recipe/IBaseRecipeType.java create mode 100644 src/main/java/techreborn/api/recipe/RecipeHanderer.java create mode 100644 src/main/java/techreborn/api/recipe/package-info.java create mode 100644 src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java diff --git a/src/main/java/techreborn/api/recipe/BaseRecipe.java b/src/main/java/techreborn/api/recipe/BaseRecipe.java new file mode 100644 index 000000000..b1b3be8a0 --- /dev/null +++ b/src/main/java/techreborn/api/recipe/BaseRecipe.java @@ -0,0 +1,41 @@ +package techreborn.api.recipe; + +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +/** + * Extend this to add a recipe + */ +public abstract class BaseRecipe implements IBaseRecipeType { + + public ArrayList inputs; + + public ArrayList outputs; + + public String name; + + public BaseRecipe(String name) { + inputs = new ArrayList(); + outputs = new ArrayList(); + this.name = name; + //This adds all new recipes + RecipeHanderer.addRecipe(this); + } + + @Override + public List getOutputs() { + return outputs; + } + + @Override + public List getInputs() { + return inputs; + } + + @Override + public String getRecipeName() { + return name; + } +} diff --git a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java new file mode 100644 index 000000000..66f948ef9 --- /dev/null +++ b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java @@ -0,0 +1,33 @@ +package techreborn.api.recipe; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * This is the base recipe class implement this to make a recipe handler + */ +public interface IBaseRecipeType { + + /** + * Use this to get all of the inputs + * + * @return the List of inputs + */ + public List getInputs(); + + /** + * Use this to get all of the outputs + * + * @return the List of outputs + */ + public List getOutputs(); + + /** + * This is the name to check that the recipe is the one that should be used in + * the tile entity that is set up to process this recipe. + * + * @return The recipeName + */ + public String getRecipeName(); +} diff --git a/src/main/java/techreborn/api/recipe/RecipeHanderer.java b/src/main/java/techreborn/api/recipe/RecipeHanderer.java new file mode 100644 index 000000000..bd98667a7 --- /dev/null +++ b/src/main/java/techreborn/api/recipe/RecipeHanderer.java @@ -0,0 +1,29 @@ +package techreborn.api.recipe; + +import java.util.ArrayList; +import java.util.List; + + +public class RecipeHanderer { + + public static ArrayList recipeList = new ArrayList(); + + public static List getRecipeClassFromName(String name){ + List baseRecipeList = new ArrayList(); + for(IBaseRecipeType baseRecipe : recipeList){ + if(baseRecipe.equals(name)){ + baseRecipeList.add(baseRecipe); + } + } + return baseRecipeList; + } + + public static void addRecipe(IBaseRecipeType recipe){ + if(recipeList.contains(recipe)){ + return; + } + recipeList.add(recipe); + } + + +} \ No newline at end of file diff --git a/src/main/java/techreborn/api/recipe/package-info.java b/src/main/java/techreborn/api/recipe/package-info.java new file mode 100644 index 000000000..7acc7ab23 --- /dev/null +++ b/src/main/java/techreborn/api/recipe/package-info.java @@ -0,0 +1,5 @@ +@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") +package techreborn.api.recipe; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java b/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java new file mode 100644 index 000000000..454266203 --- /dev/null +++ b/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java @@ -0,0 +1,15 @@ +package techreborn.recipes; + +import net.minecraft.item.ItemStack; +import techreborn.api.recipe.BaseRecipe; + +public class ImplosionCompressorRecipe extends BaseRecipe { + + public ImplosionCompressorRecipe(String name, ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2) { + super(name); + inputs.add(input1); + inputs.add(input2); + outputs.add(output1); + outputs.add(output2); + } +}