Started working on the recipe system
This commit is contained in:
parent
85e7503aa6
commit
4d66bb9e9d
5 changed files with 123 additions and 0 deletions
41
src/main/java/techreborn/api/recipe/BaseRecipe.java
Normal file
41
src/main/java/techreborn/api/recipe/BaseRecipe.java
Normal file
|
@ -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<ItemStack> inputs;
|
||||||
|
|
||||||
|
public ArrayList<ItemStack> outputs;
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
public BaseRecipe(String name) {
|
||||||
|
inputs = new ArrayList<ItemStack>();
|
||||||
|
outputs = new ArrayList<ItemStack>();
|
||||||
|
this.name = name;
|
||||||
|
//This adds all new recipes
|
||||||
|
RecipeHanderer.addRecipe(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getOutputs() {
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getInputs() {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
33
src/main/java/techreborn/api/recipe/IBaseRecipeType.java
Normal file
33
src/main/java/techreborn/api/recipe/IBaseRecipeType.java
Normal file
|
@ -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<ItemStack> getInputs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to get all of the outputs
|
||||||
|
*
|
||||||
|
* @return the List of outputs
|
||||||
|
*/
|
||||||
|
public List<ItemStack> 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();
|
||||||
|
}
|
29
src/main/java/techreborn/api/recipe/RecipeHanderer.java
Normal file
29
src/main/java/techreborn/api/recipe/RecipeHanderer.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package techreborn.api.recipe;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class RecipeHanderer {
|
||||||
|
|
||||||
|
public static ArrayList<IBaseRecipeType> recipeList = new ArrayList<IBaseRecipeType>();
|
||||||
|
|
||||||
|
public static List<IBaseRecipeType> getRecipeClassFromName(String name){
|
||||||
|
List<IBaseRecipeType> baseRecipeList = new ArrayList<IBaseRecipeType>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
5
src/main/java/techreborn/api/recipe/package-info.java
Normal file
5
src/main/java/techreborn/api/recipe/package-info.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI")
|
||||||
|
package techreborn.api.recipe;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.API;
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue