2015-09-21 23:49:49 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("ToolTableHandler.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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.recipe;
|
|
|
|
|
|
2015-09-22 23:32:19 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.ItemUtil;
|
2015-09-21 23:49:49 +02:00
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
public class ToolTableHandler{
|
|
|
|
|
|
|
|
|
|
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
|
|
|
|
|
2015-09-23 21:34:12 +02:00
|
|
|
|
public static void addRecipe(ItemStack output, ItemStack... itemsNeeded){
|
2015-09-22 23:32:19 +02:00
|
|
|
|
recipes.add(new Recipe(output, itemsNeeded));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ItemStack getResultFromSlots(ItemStack[] slots){
|
|
|
|
|
Recipe recipe = getRecipeFromSlots(slots);
|
|
|
|
|
return recipe == null ? null : recipe.output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Recipe getRecipeFromSlots(ItemStack[] slots){
|
|
|
|
|
for(Recipe recipe : recipes){
|
|
|
|
|
if(ItemUtil.containsAll(slots, recipe.itemsNeeded)){
|
|
|
|
|
return recipe;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isIngredient(ItemStack stack){
|
|
|
|
|
for(Recipe recipe : recipes){
|
|
|
|
|
if(stack != null){
|
|
|
|
|
for(ItemStack aStack : recipe.itemsNeeded){
|
|
|
|
|
if(aStack != null && stack.isItemEqual(aStack)){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2015-09-21 23:49:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Recipe{
|
|
|
|
|
|
|
|
|
|
public ItemStack[] itemsNeeded;
|
|
|
|
|
public ItemStack output;
|
|
|
|
|
|
2015-09-22 23:32:19 +02:00
|
|
|
|
public Recipe(ItemStack output, ItemStack... itemsNeeded){
|
2015-09-21 23:49:49 +02:00
|
|
|
|
this.output = output;
|
|
|
|
|
this.itemsNeeded = itemsNeeded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|