ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java

89 lines
3.2 KiB
Java
Raw Normal View History

2016-03-18 18:41:37 +01:00
/*
2016-05-16 22:52:27 +02:00
* This file ("RecipeUtil.java") is part of the Actually Additions mod for Minecraft.
2016-03-18 18:41:37 +01:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2016-03-18 18:41:37 +01:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2016-03-18 18:41:37 +01:00
*/
package de.ellpeck.actuallyadditions.mod.util;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
2016-08-03 01:09:11 +02:00
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
2016-03-18 18:41:37 +01:00
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
2016-08-03 01:09:11 +02:00
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
2016-05-14 13:51:18 +02:00
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
2016-08-03 01:09:11 +02:00
import net.minecraft.item.ItemStack;
2016-03-18 18:41:37 +01:00
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
2016-08-03 01:09:11 +02:00
import net.minecraftforge.oredict.OreDictionary;
2016-03-18 18:41:37 +01:00
2016-08-03 01:09:11 +02:00
import java.util.ArrayList;
import java.util.Collections;
2016-03-18 18:41:37 +01:00
import java.util.List;
2016-06-17 23:50:38 +02:00
public final class RecipeUtil{
2016-03-18 18:41:37 +01:00
2016-05-14 13:51:18 +02:00
public static LensConversionRecipe lastReconstructorRecipe(){
2016-05-19 20:05:12 +02:00
List<LensConversionRecipe> list = ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES;
2016-03-18 18:41:37 +01:00
return list.get(list.size()-1);
}
public static CrusherRecipe lastCrusherRecipe(){
2016-05-19 20:05:12 +02:00
List<CrusherRecipe> list = ActuallyAdditionsAPI.CRUSHER_RECIPES;
2016-03-18 18:41:37 +01:00
return list.get(list.size()-1);
}
public static IRecipe lastIRecipe(){
List list = CraftingManager.getInstance().getRecipeList();
Object recipe = list.get(list.size()-1);
return recipe instanceof IRecipe ? (IRecipe)recipe : null;
}
2016-08-03 01:09:11 +02:00
public static List<ItemStack> getCrusherRecipeOutputOnes(CrusherRecipe recipe){
return doRecipeOrWhatever(recipe.outputOneStack, recipe.outputOne, recipe.outputOneAmount);
}
public static List<ItemStack> getCrusherRecipeOutputTwos(CrusherRecipe recipe){
return doRecipeOrWhatever(recipe.outputTwoStack, recipe.outputTwo, recipe.outputTwoAmount);
}
public static List<ItemStack> getCrusherRecipeInputs(CrusherRecipe recipe){
return doRecipeOrWhatever(recipe.inputStack, recipe.input, 1);
}
public static List<ItemStack> getConversionLensInputs(LensConversionRecipe recipe){
return doRecipeOrWhatever(recipe.inputStack, recipe.input, 1);
}
public static List<ItemStack> getConversionLensOutputs(LensConversionRecipe recipe){
return doRecipeOrWhatever(recipe.outputStack, recipe.output, 1);
}
private static List<ItemStack> doRecipeOrWhatever(ItemStack stack, String oredict, int amount){
if(stack != null){
return Collections.singletonList(stack.copy());
}
if(oredict == null || oredict.isEmpty()){
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(oredict, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack aStack : stacks){
if(aStack != null){
ItemStack stackCopy = aStack.copy();
stackCopy.stackSize = amount;
stacksCopy.add(stackCopy);
}
}
return stacksCopy;
}
return null;
}
2016-03-18 18:41:37 +01:00
}