Example usage for net.minecraftforge.common.brewing BrewingRecipeRegistry brewPotions

List of usage examples for net.minecraftforge.common.brewing BrewingRecipeRegistry brewPotions

Introduction

In this page you can find the example usage for net.minecraftforge.common.brewing BrewingRecipeRegistry brewPotions.

Prototype

public static void brewPotions(NonNullList<ItemStack> inputs, ItemStack ingredient, int[] inputIndexes) 

Source Link

Document

Used by the brewing stand to brew its inventory Extra parameters exist to allow modders to create bigger brewing stands without much hassle

Usage

From source file:com.buuz135.industrial.tile.magic.PotionEnervatorTile.java

License:Open Source License

@Override
public float performWork() {
    if (WorkUtils.isDisabled(this.getBlockType()))
        return 0;
    if (action > 5)
        action = 0;//from  ww  w.j ava2 s. c om
    if (action != 0 && outputPotions.getStackInSlot(0).isEmpty() && outputPotions.getStackInSlot(1).isEmpty()
            && outputPotions.getStackInSlot(2).isEmpty()) {
        action = 0;
        partialSync(NBT_ACTION, true);
        return 1;
    }
    if (action == 0 && inputGlassBottles.getStackInSlot(0).getCount() >= 3
            && ItemHandlerHelper.insertItem(outputPotions, new ItemStack(Items.POTIONITEM, 3), true).isEmpty()
            && fluidTank.getFluidAmount() >= 3000) { //DUMMY STACK
        ItemStack bottles = new ItemStack(Items.POTIONITEM, 3);
        NBTTagCompound c = new NBTTagCompound();
        c.setString("Potion", "minecraft:water");
        bottles.setTagCompound(c);
        ItemHandlerHelper.insertItem(outputPotions, bottles, false);
        fluidTank.drain(3000, true);
        inputGlassBottles.getStackInSlot(0).setCount(inputGlassBottles.getStackInSlot(0).getCount() - 3);
        action = 1;
        partialSync(NBT_ACTION, true);
        return 1;
    } else if (action > 0) {
        ItemStack ingredient = inputIngredients.getStackInSlot(action - 1);
        if (!ingredient.isEmpty()) {
            NonNullList<ItemStack> potions = NonNullList.create();
            potions.add(outputPotions.getStackInSlot(0));
            potions.add(outputPotions.getStackInSlot(1));
            potions.add(outputPotions.getStackInSlot(2));
            if (BrewingRecipeRegistry.hasOutput(potions.get(0), ingredient)) {
                BrewingRecipeRegistry.brewPotions(potions, ingredient, new int[] { 0, 1, 2 });
                for (int i = 0; i < 3; ++i)
                    outputPotions.setStackInSlot(i, potions.get(i));
                ++action;
                ingredient.setCount(ingredient.getCount() - 1);
                if (action > 5)
                    action = 0;
                partialSync(NBT_ACTION, true);
                return 1;
            }
        }
    }
    return 0;
}