Example usage for net.minecraftforge.common ForgeHooks getContainerItem

List of usage examples for net.minecraftforge.common ForgeHooks getContainerItem

Introduction

In this page you can find the example usage for net.minecraftforge.common ForgeHooks getContainerItem.

Prototype

@Nonnull
    public static ItemStack getContainerItem(@Nonnull ItemStack stack) 

Source Link

Usage

From source file:blusunrize.immersiveengineering.common.crafting.RecipeShapedIngredient.java

@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) //getRecipeLeftovers
{
    NonNullList<ItemStack> remains = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
    for (int yy = 0; yy < this.height; yy++)
        for (int xx = 0; xx < this.width; xx++) {
            int i = this.width * yy + xx;
            int transposedI = inv.getWidth() * (yy + lastStartY) + (xx + lastStartX);
            ItemStack s = inv.getStackInSlot(transposedI);
            NonNullList<Ingredient> matchedIngr = lastMatch == 1 ? ingredientsQuarterTurn
                    : lastMatch == 2 ? ingredientsEighthTurn : this.input;
            if (matchedIngr.get(i) instanceof IngredientFluidStack) {
                IFluidHandlerItem handler = FluidUtil
                        .getFluidHandler(s.getCount() > 1 ? Utils.copyStackWithAmount(s, 1) : s);
                if (handler != null) {
                    FluidStack fluid = ((IngredientFluidStack) matchedIngr.get(i)).getFluid();
                    handler.drain(fluid.amount, true);
                    remains.set(transposedI, handler.getContainer().copy());
                } else
                    remains.set(transposedI, ForgeHooks.getContainerItem(s));
            }/*from   ww  w.  j  a  v a2  s  .  c om*/
        }
    return remains;
}

From source file:de.ellpeck.toolheadswapper.RecipeSwapHead.java

public ItemStack[] getRemainingItems(InventoryCrafting inv) {
    ItemStack[] stacks = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < stacks.length; ++i) {
        stacks[i] = ForgeHooks.getContainerItem(inv.getStackInSlot(i));
    }//w ww .jav  a2  s . c om

    return stacks;
}

From source file:fr.wolf.addons.common.recipe.ShapedRecipesCompressor.java

License:Minecraft Mod Public

@Override
public ItemStack[] getRemainingItems(InventoryCrafting p_179532_1_) {
    ItemStack[] aitemstack = new ItemStack[p_179532_1_.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i) {
        ItemStack itemstack = p_179532_1_.getStackInSlot(i);
        aitemstack[i] = ForgeHooks.getContainerItem(itemstack);
    }//from  w  w  w  .ja v  a 2s  .c  o m

    return aitemstack;
}

From source file:vazkii.psi.common.crafting.recipe.ColorizerChangeRecipe.java

@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
    NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
    int dyeIndex = -1;
    ItemStack cad = ItemStack.EMPTY;//from   w  w w  . ja va  2  s . co m
    for (int i = 0; i < ret.size(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (!stack.isEmpty() && stack.getItem() instanceof ICAD) {
            cad = stack;
        } else {
            if (!stack.isEmpty() && stack.getItem() instanceof ICADColorizer)
                dyeIndex = i;
            ret.set(i, ForgeHooks.getContainerItem(stack));
        }
    }
    if (!cad.isEmpty() && dyeIndex != -1) {
        ICAD icad = (ICAD) cad.getItem();
        ret.set(dyeIndex, icad.getComponentInSlot(cad, EnumCADComponent.DYE));
    }

    return ret;
}