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

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

Introduction

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

Prototype

public static boolean hasOutput(ItemStack input, ItemStack ingredient) 

Source Link

Document

Returns true if the passed input and ingredient have an output

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;/*w  ww  .j  a  va2s  .c o  m*/
    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;
}

From source file:therogue.storehouse.tile.machine.TilePotionBrewer.java

License:Open Source License

@Override
public void update() {
    if (injectors.size() == 0)
        return;/*  w ww .  j av  a2  s .co  m*/
    IInventoryItemHandler internalView = inventory.guiAccess;
    if (injectors.size() <= injector) {
        int slots = BREWING_SLOTS.size();
        for (Integer i : OUTPUT_SLOTS) {
            if (internalView.getStackInSlot(i).isEmpty()) {
                for (Integer j : BREWING_SLOTS) {
                    if (!internalView.getStackInSlot(j).isEmpty()) {
                        internalView.insertItem(i, internalView.extractItem(j, -1, false), false);
                        --slots;
                        break;
                    }
                }
            }
        }
        if (slots == 0)
            injector = 0;
    }
    if (injectors.size() <= injector)
        return;
    ItemStack nextIngredient = injectors.get(injector).getNext();
    for (Integer bottle_slot : BOTTLE_SLOTS) {
        if (BrewingRecipeRegistry.hasOutput(internalView.getStackInSlot(bottle_slot), nextIngredient)) {
            for (Integer brewing_slot : BREWING_SLOTS) {
                if (internalView.getStackInSlot(brewing_slot).isEmpty()) {
                    internalView.insertItem(brewing_slot, internalView.extractItem(bottle_slot, -1, false),
                            false);
                }
            }
        }
    }
}