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 String name;
|
||||||
|
|
||||||
public BaseRecipe(String name) {
|
public int tickTime;
|
||||||
|
|
||||||
|
public int euPerTick;
|
||||||
|
|
||||||
|
public BaseRecipe(String name, int tickTime, int euPerTick) {
|
||||||
inputs = new ArrayList<ItemStack>();
|
inputs = new ArrayList<ItemStack>();
|
||||||
outputs = new ArrayList<ItemStack>();
|
outputs = new ArrayList<ItemStack>();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
//This adds all new recipes
|
//This adds all new recipes
|
||||||
RecipeHanderer.addRecipe(this);
|
RecipeHanderer.addRecipe(this);
|
||||||
|
this.tickTime = tickTime;
|
||||||
|
this.euPerTick = euPerTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,4 +44,14 @@ public abstract class BaseRecipe implements IBaseRecipeType {
|
||||||
public String getRecipeName() {
|
public String getRecipeName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int tickTime() {
|
||||||
|
return tickTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int euPerTick() {
|
||||||
|
return euPerTick;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,16 @@ public interface IBaseRecipeType {
|
||||||
* @return The recipeName
|
* @return The recipeName
|
||||||
*/
|
*/
|
||||||
public String getRecipeName();
|
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 {
|
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>();
|
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){
|
public static List<IBaseRecipeType> getRecipeClassFromName(String name){
|
||||||
List<IBaseRecipeType> baseRecipeList = new ArrayList<IBaseRecipeType>();
|
List<IBaseRecipeType> baseRecipeList = new ArrayList<IBaseRecipeType>();
|
||||||
for(IBaseRecipeType baseRecipe : recipeList){
|
for(IBaseRecipeType baseRecipe : recipeList){
|
||||||
|
@ -18,7 +26,14 @@ public class RecipeHanderer {
|
||||||
return baseRecipeList;
|
return baseRecipeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a recipe to the system
|
||||||
|
* @param recipe The recipe to add to the system.
|
||||||
|
*/
|
||||||
public static void addRecipe(IBaseRecipeType recipe){
|
public static void addRecipe(IBaseRecipeType recipe){
|
||||||
|
if(recipe == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(recipeList.contains(recipe)){
|
if(recipeList.contains(recipe)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import techreborn.api.BlastFurnaceRecipe;
|
||||||
import techreborn.api.CentrifugeRecipie;
|
import techreborn.api.CentrifugeRecipie;
|
||||||
import techreborn.api.TechRebornAPI;
|
import techreborn.api.TechRebornAPI;
|
||||||
import techreborn.config.ConfigTechReborn;
|
import techreborn.config.ConfigTechReborn;
|
||||||
|
import techreborn.recipes.ImplosionCompressorRecipe;
|
||||||
import techreborn.util.CraftingHelper;
|
import techreborn.util.CraftingHelper;
|
||||||
import techreborn.util.LogHelper;
|
import techreborn.util.LogHelper;
|
||||||
import techreborn.util.RecipeRemover;
|
import techreborn.util.RecipeRemover;
|
||||||
|
@ -194,6 +195,9 @@ public class ModRecipes {
|
||||||
new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c',
|
new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c',
|
||||||
Blocks.cobblestone);
|
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));
|
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");
|
LogHelper.info("Machine Recipes Added");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,15 @@ import techreborn.api.recipe.BaseRecipe;
|
||||||
|
|
||||||
public class ImplosionCompressorRecipe extends BaseRecipe {
|
public class ImplosionCompressorRecipe extends BaseRecipe {
|
||||||
|
|
||||||
public ImplosionCompressorRecipe(String name, ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2) {
|
public ImplosionCompressorRecipe(ItemStack input1, ItemStack input2, ItemStack output1, ItemStack output2, int tickTime, int euPerTick) {
|
||||||
super(name);
|
super("implosionCompressorRecipe", tickTime, euPerTick);
|
||||||
|
if(input1 != null)
|
||||||
inputs.add(input1);
|
inputs.add(input1);
|
||||||
|
if(input2 != null)
|
||||||
inputs.add(input2);
|
inputs.add(input2);
|
||||||
|
if(output1 != null)
|
||||||
outputs.add(output1);
|
outputs.add(output1);
|
||||||
|
if(output2 != null)
|
||||||
outputs.add(output2);
|
outputs.add(output2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue