2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("CrusherRecipeAutoRegistry.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-07-01 16:06:40 +02:00
|
|
|
|
package ellpeck.actuallyadditions.recipe;
|
|
|
|
|
|
2015-07-02 11:44:41 +02:00
|
|
|
|
import ellpeck.actuallyadditions.config.ConfigValues;
|
2015-07-01 16:06:40 +02:00
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
public class CrusherRecipeAutoRegistry{
|
|
|
|
|
|
2015-07-17 23:22:10 +02:00
|
|
|
|
public static ArrayList<SearchCase> searchCases = new ArrayList<SearchCase>();
|
2015-07-01 16:06:40 +02:00
|
|
|
|
|
|
|
|
|
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 16:06:40 +02:00
|
|
|
|
|
2015-07-01 21:32:48 +02:00
|
|
|
|
public SearchCase(String name, int resultAmount, String replacer){
|
2015-07-01 16:06:40 +02:00
|
|
|
|
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");
|
2015-07-01 16:06:40 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-02 11:44:41 +02:00
|
|
|
|
private static boolean hasException(String name){
|
|
|
|
|
for(String except : ConfigValues.crusherRecipeExceptions){
|
|
|
|
|
if(except.equals(name)) return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 16:06:40 +02:00
|
|
|
|
public static void registerFinally(){
|
|
|
|
|
String[] names = OreDictionary.getOreNames();
|
|
|
|
|
for(String inputName : names){
|
|
|
|
|
|
2015-07-02 11:44:41 +02:00
|
|
|
|
if(!hasException(inputName)){
|
2015-07-01 16:06:40 +02:00
|
|
|
|
int resultAmount = 1;
|
|
|
|
|
String inputNameWithoutPrefix = null;
|
2015-07-01 21:32:48 +02:00
|
|
|
|
String replacer = null;
|
2015-07-01 16:06:40 +02:00
|
|
|
|
|
|
|
|
|
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;
|
2015-07-01 16:06:40 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 21:32:48 +02:00
|
|
|
|
if(inputNameWithoutPrefix != null && replacer != null){
|
|
|
|
|
String inputWithDustPrefix = replacer+inputNameWithoutPrefix;
|
2015-07-01 16:06:40 +02:00
|
|
|
|
CrusherRecipeManualRegistry.registerRecipe(inputName, inputWithDustPrefix, resultAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|