More work on the recipe system.

This commit is contained in:
modmuss50 2015-05-07 20:38:11 +01:00
parent 4d66bb9e9d
commit 12bea10af6
6 changed files with 139 additions and 7 deletions

View file

@ -16,12 +16,18 @@ public abstract class BaseRecipe implements IBaseRecipeType {
public String name;
public BaseRecipe(String name) {
public int tickTime;
public int euPerTick;
public BaseRecipe(String name, int tickTime, int euPerTick) {
inputs = new ArrayList<ItemStack>();
outputs = new ArrayList<ItemStack>();
this.name = name;
//This adds all new recipes
RecipeHanderer.addRecipe(this);
this.tickTime = tickTime;
this.euPerTick = euPerTick;
}
@Override
@ -38,4 +44,14 @@ public abstract class BaseRecipe implements IBaseRecipeType {
public String getRecipeName() {
return name;
}
@Override
public int tickTime() {
return tickTime;
}
@Override
public int euPerTick() {
return euPerTick;
}
}

View file

@ -30,4 +30,16 @@ public interface IBaseRecipeType {
* @return The recipeName
*/
public String getRecipeName();
/**
* This is how long the recipe needs to tick for the crafting operation to complete
* @return tick length
*/
public int tickTime();
/**
* This is how much eu Per tick the machine should use
* @return the amount of eu to be used per tick.
*/
public int euPerTick();
}

View file

@ -0,0 +1,81 @@
package techreborn.api.recipe;
import ic2.api.energy.prefab.BasicSink;
import techreborn.tiles.TileMachineBase;
import techreborn.util.Inventory;
/**
* Use this in your tile entity to craft things
*/
public class RecipeCrafter {
/**
* This is the recipe type to use
*/
public String recipeName;
/**
* This is the parent tile
*/
public TileMachineBase parentTile;
/**
* This is the place to use the power from
*/
public BasicSink energy;
/**
* This is the amount of inputs that the setRecipe has
*/
public int inputs;
/**
* This is the amount of outputs that the recipe has
*/
public int outputs;
/**
* This is the inventory to use for the crafting
*/
public Inventory inventory;
/**
* This is the list of the slots that the crafting logic should look for the input item stacks.
*/
public int[] inputSlots;
/**
* This si the list fo the slots that the crafting logic should look fot the output item stacks.
*/
public int[] outputSlots;
/**
* This is the constructor, not a lot to say here :P
* @param recipeName
* @param parentTile
* @param energy
* @param inputs
* @param outputs
* @param inventory
* @param inputSlots
* @param outputSlots
*/
public RecipeCrafter(String recipeName, TileMachineBase parentTile, BasicSink energy, int inputs, int outputs, Inventory inventory, int[] inputSlots, int[] outputSlots) {
this.recipeName = recipeName;
this.parentTile = parentTile;
this.energy = energy;
this.inputs = inputs;
this.outputs = outputs;
this.inventory = inventory;
this.inputSlots = inputSlots;
this.outputSlots = outputSlots;
}
/**
* Call this on the tile tick
*/
public void updateEntity(){
}
}

View file

@ -6,8 +6,16 @@ import java.util.List;
public class RecipeHanderer {
/**
* This is the array list of all of the recipes for all of the machines
*/
public static ArrayList<IBaseRecipeType> recipeList = new ArrayList<IBaseRecipeType>();
/**
* Use this to get all of the recipes form a recipe name
* @param name the name that the recipe was resisted as.
* @return A list of all the recipes of a given name.
*/
public static List<IBaseRecipeType> getRecipeClassFromName(String name){
List<IBaseRecipeType> baseRecipeList = new ArrayList<IBaseRecipeType>();
for(IBaseRecipeType baseRecipe : recipeList){
@ -18,7 +26,14 @@ public class RecipeHanderer {
return baseRecipeList;
}
/**
* Add a recipe to the system
* @param recipe The recipe to add to the system.
*/
public static void addRecipe(IBaseRecipeType recipe){
if(recipe == null){
return;
}
if(recipeList.contains(recipe)){
return;
}