diff --git a/src/main/java/techreborn/api/recipe/BaseRecipe.java b/src/main/java/techreborn/api/recipe/BaseRecipe.java index b1b3be8a0..1793dacd2 100644 --- a/src/main/java/techreborn/api/recipe/BaseRecipe.java +++ b/src/main/java/techreborn/api/recipe/BaseRecipe.java @@ -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(); outputs = new ArrayList(); 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; + } } diff --git a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java index 66f948ef9..d44831686 100644 --- a/src/main/java/techreborn/api/recipe/IBaseRecipeType.java +++ b/src/main/java/techreborn/api/recipe/IBaseRecipeType.java @@ -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(); } diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java new file mode 100644 index 000000000..9ace84184 --- /dev/null +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -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(){ + + } +} diff --git a/src/main/java/techreborn/api/recipe/RecipeHanderer.java b/src/main/java/techreborn/api/recipe/RecipeHanderer.java index bd98667a7..ae3018d2c 100644 --- a/src/main/java/techreborn/api/recipe/RecipeHanderer.java +++ b/src/main/java/techreborn/api/recipe/RecipeHanderer.java @@ -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 recipeList = new ArrayList(); + /** + * 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 getRecipeClassFromName(String name){ List baseRecipeList = new ArrayList(); 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; } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 243d52ce2..4026f0321 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -9,6 +9,7 @@ import techreborn.api.BlastFurnaceRecipe; import techreborn.api.CentrifugeRecipie; import techreborn.api.TechRebornAPI; import techreborn.config.ConfigTechReborn; +import techreborn.recipes.ImplosionCompressorRecipe; import techreborn.util.CraftingHelper; import techreborn.util.LogHelper; import techreborn.util.RecipeRemover; @@ -194,6 +195,9 @@ public class ModRecipes { new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c', Blocks.cobblestone); TechRebornAPI.registerBlastFurnaceRecipe(new BlastFurnaceRecipe(new ItemStack(Items.apple), new ItemStack(Items.ender_pearl), new ItemStack(Items.golden_apple), new ItemStack(Items.diamond), 120, 1000)); + + new ImplosionCompressorRecipe(new ItemStack(Items.diamond), new ItemStack(Items.golden_apple), new ItemStack(Items.brewing_stand), new ItemStack(Items.carrot), 120, 5); + LogHelper.info("Machine Recipes Added"); } diff --git a/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java b/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java index 454266203..3a995cee9 100644 --- a/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java +++ b/src/main/java/techreborn/recipes/ImplosionCompressorRecipe.java @@ -5,11 +5,15 @@ 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); + public ImplosionCompressorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime, int euPerTick) { + super("implosionCompressorRecipe", tickTime, euPerTick); + if(input1 != null) + inputs.add(input1); + if(input2 != null) + inputs.add(input2); + if(output1 != null) + outputs.add(output1); + if(output2 != null) + outputs.add(output2); } }