Search in sources :

Example 1 with IngredientStack

use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.

the class RecipeShapedIngredient method saveIngredients.

public static Object[] saveIngredients(Object... recipe) {
    Object[] converted = new Object[recipe.length];
    String shape = "";
    boolean shapeDone = false;
    for (int i = 0; i < converted.length; i++) {
        converted[i] = recipe[i];
        if (!shapeDone)
            if (recipe[i] instanceof String[]) {
                String[] parts = ((String[]) recipe[i]);
                for (String s : parts) shape += s;
            } else if (recipe[i] instanceof String)
                shape += (String) recipe[i];
        if (recipe[i] instanceof Character) {
            if (!shapeDone) {
                shapeDone = true;
                tempIngredients = new IngredientStack[shape.length()];
            }
            Character chr = (Character) recipe[i];
            Object in = recipe[i + 1];
            IngredientStack ingredient = ApiUtils.createIngredientStack(in);
            if (ingredient != null) {
                //Temp Replacement, fixed in constructor
                recipe[i + 1] = Blocks.FIRE;
                for (int j = 0; j < shape.length(); j++) if (chr.charValue() == shape.charAt(j))
                    tempIngredients[j] = ingredient;
            }
        }
    }
    return converted;
}
Also used : IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack)

Example 2 with IngredientStack

use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.

the class RecipeShapelessIngredient method setIngredients.

public RecipeShapelessIngredient setIngredients(IngredientStack[] ingr) {
    ingredients = new ArrayList();
    input.clear();
    for (IngredientStack stack : ingr) if (stack != null) {
        ingredients.add(stack);
        input.add(stack.getShapedRecipeInput());
    }
    return this;
}
Also used : ArrayList(java.util.ArrayList) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack)

Example 3 with IngredientStack

use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.

the class RecipeShapelessIngredient method saveIngredients.

public static Object[] saveIngredients(Object... recipe) {
    Object[] converted = new Object[recipe.length];
    tempIngredients = new IngredientStack[recipe.length];
    for (int i = 0; i < recipe.length; i++) {
        IngredientStack ingr = ApiUtils.createIngredientStack(recipe[i]);
        if (ingr != null) {
            tempIngredients[i] = ingr;
            converted[i] = Blocks.FIRE;
        }
    }
    return converted;
}
Also used : IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack)

Example 4 with IngredientStack

use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project DefiledLands by Lykrast.

the class CompatImmersiveEngineering method postInit.

@Override
public void postInit() {
    // Garden Cloche
    // Mostly copied from the vanilla registering
    // Uses same numbers as Sugar Cane and Mushrooms
    IngredientStack vilespineSoil = new IngredientStack(ImmutableList.of(new ItemStack(ModBlocks.dirtDefiled), new ItemStack(ModBlocks.grassDefiled), new ItemStack(ModBlocks.sandDefiled)));
    BelljarHandler.stackingHandler.register(new ItemStack(ModBlocks.vilespine), new ItemStack[] { new ItemStack(ModBlocks.vilespine, 2) }, vilespineSoil, ModBlocks.vilespine.getDefaultState(), ModBlocks.vilespine.getDefaultState().withProperty(BlockVilespine.TOPMOST, true));
    BelljarHandler.cropHandler.register(new ItemStack(ModBlocks.scuronotte), new ItemStack[] { new ItemStack(ModBlocks.scuronotte, 2) }, vilespineSoil, ModBlocks.scuronotte.getDefaultState());
    IngredientStack blastemSoil = new IngredientStack(ImmutableList.of(new ItemStack(ModBlocks.dirtDefiled), new ItemStack(ModBlocks.grassDefiled)));
    BelljarHandler.cropHandler.register(new ItemStack(ModBlocks.blastem), new ItemStack[] { new ItemStack(ModItems.blastemFruit) }, blastemSoil, ModBlocks.blastem.getDefaultState());
}
Also used : IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack) ItemStack(net.minecraft.item.ItemStack)

Example 5 with IngredientStack

use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.

the class TileEntityAssembler method consumeIngredients.

public boolean consumeIngredients(AssemblerHandler.RecipeQuery[] queries, ArrayList<ItemStack> itemStacks, boolean doConsume, @Nullable NonNullList<ItemStack> gridItems) {
    if (!doConsume) {
        ArrayList<ItemStack> dupeList = new ArrayList<>(itemStacks.size());
        for (ItemStack stack : itemStacks) dupeList.add(stack.copy());
        itemStacks = dupeList;
    }
    for (int i = 0; i < queries.length; i++) {
        AssemblerHandler.RecipeQuery recipeQuery = queries[i];
        if (recipeQuery != null && recipeQuery.query != null) {
            FluidStack fs = recipeQuery.query instanceof FluidStack ? (FluidStack) recipeQuery.query : (recipeQuery.query instanceof IngredientStack && ((IngredientStack) recipeQuery.query).fluid != null) ? ((IngredientStack) recipeQuery.query).fluid : null;
            int querySize = recipeQuery.querySize;
            if (fs != null) {
                boolean hasFluid = false;
                for (FluidTank tank : tanks) if (tank.getFluid() != null && tank.getFluid().containsFluid(fs)) {
                    hasFluid = true;
                    if (doConsume)
                        tank.drain(fs.amount, true);
                    break;
                }
                if (hasFluid)
                    continue;
                else
                    querySize = 1;
            }
            Iterator<ItemStack> it = itemStacks.iterator();
            while (it.hasNext()) {
                ItemStack next = it.next();
                if (!next.isEmpty() && ApiUtils.stackMatchesObject(next, recipeQuery.query, true)) {
                    int taken = Math.min(querySize, next.getCount());
                    ItemStack forGrid = next.splitStack(taken);
                    if (gridItems != null)
                        gridItems.set(i, forGrid);
                    if (next.getCount() <= 0)
                        it.remove();
                    querySize -= taken;
                    if (querySize <= 0)
                        break;
                }
            }
            if (querySize > 0)
                return false;
        }
    }
    return true;
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) FluidStack(net.minecraftforge.fluids.FluidStack) ArrayList(java.util.ArrayList) AssemblerHandler(blusunrize.immersiveengineering.api.tool.AssemblerHandler) ItemStack(net.minecraft.item.ItemStack) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack)

Aggregations

IngredientStack (blusunrize.immersiveengineering.api.crafting.IngredientStack)11 ItemStack (net.minecraft.item.ItemStack)8 ArrayList (java.util.ArrayList)4 FluidStack (net.minecraftforge.fluids.FluidStack)3 FluidTank (net.minecraftforge.fluids.FluidTank)2 IFluidTank (net.minecraftforge.fluids.IFluidTank)2 ComparableItemStack (blusunrize.immersiveengineering.api.ComparableItemStack)1 BlueprintCraftingRecipe (blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe)1 AssemblerHandler (blusunrize.immersiveengineering.api.tool.AssemblerHandler)1 IESlot (blusunrize.immersiveengineering.common.gui.IESlot)1 GuiButtonManualNavigation (blusunrize.lib.manual.gui.GuiButtonManualNavigation)1 Slot (net.minecraft.inventory.Slot)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1