ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/recipe/CrusherRecipeAutoRegistry.java

62 lines
2.1 KiB
Java
Raw Normal View History

package ellpeck.actuallyadditions.recipe;
import ellpeck.actuallyadditions.config.ConfigValues;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
public class CrusherRecipeAutoRegistry{
public static ArrayList<SearchCase> searchCases = new ArrayList<SearchCase>();
public static class SearchCase{
public final String name;
public final int resultAmount;
2015-07-01 21:32:48 +02:00
public final String replacer;
2015-07-01 21:32:48 +02:00
public SearchCase(String name, int resultAmount, String replacer){
this.name = name;
this.resultAmount = resultAmount;
2015-07-01 21:32:48 +02:00
this.replacer = replacer;
}
public SearchCase(String name, int resultAmount){
this(name, resultAmount, "dust");
}
}
private static boolean hasException(String name){
for(String except : ConfigValues.crusherRecipeExceptions){
if(except.equals(name)) return true;
}
return false;
}
public static void registerFinally(){
String[] names = OreDictionary.getOreNames();
for(String inputName : names){
if(!hasException(inputName)){
int resultAmount = 1;
String inputNameWithoutPrefix = null;
2015-07-01 21:32:48 +02:00
String replacer = null;
for(SearchCase searchCase : searchCases){
String toSearch = searchCase.name;
if(inputName.length() > toSearch.length() && inputName.substring(0, toSearch.length()).equals(toSearch)){
inputNameWithoutPrefix = inputName.substring(toSearch.length());
resultAmount = searchCase.resultAmount;
2015-07-01 21:32:48 +02:00
replacer = searchCase.replacer;
break;
}
}
2015-07-01 21:32:48 +02:00
if(inputNameWithoutPrefix != null && replacer != null){
String inputWithDustPrefix = replacer+inputNameWithoutPrefix;
CrusherRecipeManualRegistry.registerRecipe(inputName, inputWithDustPrefix, resultAmount);
}
}
}
}
}