Search in sources :

Example 1 with AlchemyArrayEffectCrafting

use of WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectCrafting in project BloodMagic by WayofTime.

the class AlchemyArrayRecipeRegistry method getRecipeForOutputStack.

/**
 * @param stack of the recipe
 * @return an array of two ItemStacks - first index is the input stack,
 * second is the catalyst stack. Returns {null, null} if no recipe
 * is valid.
 */
public static ItemStack[] getRecipeForOutputStack(ItemStack stack) {
    for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
        AlchemyArrayRecipe recipe = entry.getValue();
        if (recipe != null && entry.getKey().size() > 0) {
            for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet()) {
                if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting) {
                    AlchemyArrayEffectCrafting craftingEffect = (AlchemyArrayEffectCrafting) effectEntry.getValue();
                    ItemStack resultStack = craftingEffect.outputStack;
                    if (!resultStack.isEmpty()) {
                        if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
                            return new ItemStack[] { entry.getKey().get(0), effectEntry.getKey().toStack() };
                        }
                    }
                }
            }
        }
    }
    return new ItemStack[] { null, null };
}
Also used : AlchemyArrayEffectCrafting(WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectCrafting) AlchemyArrayEffect(WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect) List(java.util.List) ItemStackWrapper(WayofTime.bloodmagic.util.ItemStackWrapper) ItemStack(net.minecraft.item.ItemStack)

Aggregations

AlchemyArrayEffect (WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect)1 AlchemyArrayEffectCrafting (WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectCrafting)1 ItemStackWrapper (WayofTime.bloodmagic.util.ItemStackWrapper)1 List (java.util.List)1 ItemStack (net.minecraft.item.ItemStack)1