More work on the recipe system.
This commit is contained in:
parent
4d66bb9e9d
commit
12bea10af6
6 changed files with 139 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
81
src/main/java/techreborn/api/recipe/RecipeCrafter.java
Normal file
81
src/main/java/techreborn/api/recipe/RecipeCrafter.java
Normal 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(){
|
||||
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue