Start on tile rewrite
This commit is contained in:
parent
169c8e5ceb
commit
ef133ab25b
27 changed files with 39 additions and 891 deletions
|
@ -2,6 +2,7 @@ package techreborn.api.recipe;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
package techreborn.api.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
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();
|
||||
|
||||
/**
|
||||
* This gets the output form the array list
|
||||
*
|
||||
* @param i get output form position in arraylist
|
||||
* @return the output
|
||||
*/
|
||||
public ItemStack getOutput(int i);
|
||||
|
||||
/**
|
||||
* @return The ammount of outputs
|
||||
*/
|
||||
public int getOutputsSize();
|
||||
|
||||
/**
|
||||
* @return get 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();
|
||||
|
||||
/**
|
||||
* This should be a user friendly name
|
||||
*
|
||||
* @return The user friendly name of the recipe.
|
||||
*/
|
||||
public String getUserFreindlyName();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* @param tile the tile that is doing the crafting
|
||||
* @return if true the recipe will craft, if false it will not
|
||||
*/
|
||||
public boolean canCraft(TileEntity tile);
|
||||
|
||||
/**
|
||||
* @param tile the tile that is doing the crafting
|
||||
* @return return true if fluid was taken and should craft
|
||||
*/
|
||||
public boolean onCraft(TileEntity tile);
|
||||
|
||||
public Object clone() throws CloneNotSupportedException;
|
||||
|
||||
public boolean useOreDic();
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package techreborn.api.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.Core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeHandler {
|
||||
|
||||
/**
|
||||
* This is the array list of all of the recipes for all of the machines
|
||||
*/
|
||||
public static final ArrayList<IBaseRecipeType> recipeList = new ArrayList<>();
|
||||
|
||||
public static HashMap<IBaseRecipeType, String> stackMap = new HashMap<>();
|
||||
/**
|
||||
* This is a list of all the registered machine names.
|
||||
*/
|
||||
public static ArrayList<String> machineNames = 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<IBaseRecipeType> getRecipeClassFromName(String name) {
|
||||
List<IBaseRecipeType> baseRecipeList = new ArrayList<>();
|
||||
for (IBaseRecipeType baseRecipe : recipeList) {
|
||||
if (baseRecipe.getRecipeName().equals(name)) {
|
||||
baseRecipeList.add(baseRecipe);
|
||||
}
|
||||
}
|
||||
return baseRecipeList;
|
||||
}
|
||||
|
||||
public static String getUserFreindlyName(String name) {
|
||||
for (IBaseRecipeType baseRecipe : recipeList) {
|
||||
if (baseRecipe.getRecipeName().equals(name)) {
|
||||
return baseRecipe.getUserFreindlyName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
// if (!RecipeConfigManager.canLoadRecipe(recipe)) {
|
||||
// return;
|
||||
// }
|
||||
if (!machineNames.contains(recipe.getRecipeName())) {
|
||||
machineNames.add(recipe.getRecipeName());
|
||||
}
|
||||
recipeList.add(recipe);
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
|
||||
buffer.append(ste);
|
||||
}
|
||||
stackMap.put(recipe, buffer.toString());
|
||||
}
|
||||
|
||||
public static void scanForDupeRecipes() throws Exception {
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start();
|
||||
for (IBaseRecipeType baseRecipeType : recipeList) {
|
||||
for (IBaseRecipeType recipe : recipeList) {
|
||||
if (baseRecipeType != recipe && baseRecipeType.getRecipeName().equals(recipe.getRecipeName())) {
|
||||
for (int i = 0; i < baseRecipeType.getInputs().size(); i++) {
|
||||
if (ItemUtils.isItemEqual(baseRecipeType.getInputs().get(i), recipe.getInputs().get(i), true,
|
||||
false, false)) {
|
||||
StringBuilder itemInfo = new StringBuilder();
|
||||
for (ItemStack inputs : baseRecipeType.getInputs()) {
|
||||
itemInfo.append(":").append(inputs.getItem().getUnlocalizedName()).append(",").append(inputs.getDisplayName()).append(",").append(inputs.stackSize);
|
||||
}
|
||||
Core.logHelper.all(stackMap.get(baseRecipeType));
|
||||
// throw new Exception("Found a duplicate recipe for
|
||||
// " + baseRecipeType.getRecipeName() + " with
|
||||
// inputs " + itemInfo.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Core.logHelper.all(watch + " : Scanning dupe recipes");
|
||||
watch.stop();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package techreborn.api.recipe.recipeConfig;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.api.recipe.IBaseRecipeType;
|
||||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue