package com.zivilon.cinder_loe;

import lotr.common.LOTRMod;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapelessOreRecipe;

import java.util.Random;

public class CinderShapelessOreRecipe extends ShapelessOreRecipe {
    public CinderShapelessOreRecipe(ItemStack result, Object... recipe) {
        super(result, recipe);
    }

    @Override
    public ItemStack getCraftingResult(InventoryCrafting inv) {
        ItemStack result = super.getCraftingResult(inv).copy();
        for (int i = 0; i < inv.getSizeInventory(); i++) {
            ItemStack stack = inv.getStackInSlot(i);
            if (stack != null && stack.getItem() == LOTRMod.rollingPin) {
                 stack = stack.copy();
                 stack.attemptDamageItem(1, new Random());
                 if (stack.getItemDamage() > stack.getMaxDamage()) {
                     stack.stackSize -= 1;
                 }
                 inv.setInventorySlotContents(i, stack);
            }
        }
        return result;
    }

    @Override
    public boolean matches (InventoryCrafting inv, World world) {
        return super.matches(inv, world);
    }

    @Override
    public ItemStack getRecipeOutput() {
        return super.getRecipeOutput();
    }


}
