2015-03-07 12:51:28 +01:00
|
|
|
package ellpeck.actuallyadditions.recipe;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-05-07 16:36:29 +02:00
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2015-06-28 03:12:32 +02:00
|
|
|
public class GrinderRecipeManualRegistry{
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static ArrayList<GrinderRecipe> recipes = new ArrayList<GrinderRecipe>();
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static void registerRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int secondChance){
|
|
|
|
recipes.add(new GrinderRecipe(input, outputOne, outputTwo, secondChance));
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static void registerRecipe(String input, String outputOne, String outputTwo, int secondChance, int outputAmount){
|
|
|
|
ArrayList<ItemStack> inputStacks = (ArrayList<ItemStack>)OreDictionary.getOres(input, false);
|
|
|
|
ArrayList<ItemStack> outputOneStacks = (ArrayList<ItemStack>)OreDictionary.getOres(outputOne, false);
|
|
|
|
ArrayList<ItemStack> outputTwoStacks = (ArrayList<ItemStack>)OreDictionary.getOres(outputTwo, false);
|
2015-05-07 16:36:29 +02:00
|
|
|
|
|
|
|
if(inputStacks != null && !inputStacks.isEmpty()){
|
2015-05-24 13:58:34 +02:00
|
|
|
for(ItemStack anInput : inputStacks){
|
|
|
|
ItemStack theInput = anInput.copy();
|
2015-05-07 16:36:29 +02:00
|
|
|
if(outputOneStacks != null && !outputOneStacks.isEmpty()){
|
2015-05-24 13:58:34 +02:00
|
|
|
for(ItemStack anOutputOne : outputOneStacks){
|
|
|
|
ItemStack theOutputOne = anOutputOne.copy();
|
|
|
|
theOutputOne.stackSize = outputAmount;
|
2015-05-07 16:36:29 +02:00
|
|
|
if(outputTwoStacks != null && !outputTwoStacks.isEmpty()){
|
2015-05-24 13:58:34 +02:00
|
|
|
for(ItemStack anOutputTwo : outputTwoStacks){
|
|
|
|
ItemStack theOutputTwo = anOutputTwo.copy();
|
2015-06-21 02:28:49 +02:00
|
|
|
registerRecipe(theInput, theOutputOne, theOutputTwo, secondChance);
|
2015-05-07 16:36:29 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-21 02:28:49 +02:00
|
|
|
else registerRecipe(theInput, theOutputOne, null, 0);
|
2015-05-07 16:36:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static void registerRecipe(ItemStack input, ItemStack outputOne){
|
|
|
|
registerRecipe(input, outputOne, null, 0);
|
2015-05-07 16:36:29 +02:00
|
|
|
}
|
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static ItemStack getOutput(ItemStack input, boolean wantSecond){
|
2015-03-07 02:23:31 +01:00
|
|
|
for(GrinderRecipe recipe : recipes){
|
|
|
|
if(recipe.input.isItemEqual(input)){
|
|
|
|
return wantSecond ? recipe.secondOutput : recipe.firstOutput;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static boolean hasRecipe(ItemStack input, ItemStack outputOne){
|
2015-05-04 17:26:50 +02:00
|
|
|
for(GrinderRecipe recipe : recipes){
|
2015-05-25 17:00:54 +02:00
|
|
|
if(recipe.input.isItemEqual(input) && recipe.firstOutput.isItemEqual(outputOne)) return true;
|
2015-05-04 17:26:50 +02:00
|
|
|
}
|
2015-05-25 17:00:54 +02:00
|
|
|
return false;
|
2015-05-04 17:26:50 +02:00
|
|
|
}
|
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static int getSecondChance(ItemStack input){
|
2015-03-07 02:23:31 +01:00
|
|
|
for(GrinderRecipe recipe : recipes){
|
|
|
|
if(recipe.input.isItemEqual(input)){
|
|
|
|
return recipe.secondChance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-21 02:28:49 +02:00
|
|
|
public static class GrinderRecipe{
|
2015-03-07 02:23:31 +01:00
|
|
|
|
|
|
|
public final ItemStack input;
|
|
|
|
public final ItemStack firstOutput;
|
|
|
|
public final ItemStack secondOutput;
|
|
|
|
public final int secondChance;
|
|
|
|
|
|
|
|
public GrinderRecipe(ItemStack input, ItemStack firstOutput, ItemStack secondOutput, int secondChance){
|
|
|
|
this.input = input;
|
|
|
|
this.firstOutput = firstOutput;
|
|
|
|
this.secondOutput = secondOutput;
|
|
|
|
this.secondChance = secondChance;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|