Search in sources :

Example 6 with IngredientStack

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

the class Utils method canCombineArrays.

public static boolean canCombineArrays(ItemStack[] stacks, ItemStack[] target) {
    HashSet<IngredientStack> inputSet = new HashSet();
    for (ItemStack s : stacks) inputSet.add(new IngredientStack(s));
    for (ItemStack t : target) {
        int size = t.getCount();
        Iterator<IngredientStack> it = inputSet.iterator();
        while (it.hasNext()) {
            IngredientStack in = it.next();
            if (in.matchesItemStackIgnoringSize(t)) {
                int taken = Math.min(size, in.inputSize);
                size -= taken;
                in.inputSize -= taken;
                if (in.inputSize <= 0)
                    it.remove();
                if (size <= 0)
                    break;
            }
        }
        if (size > 0)
            return false;
    }
    return true;
}
Also used : IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IngredientStack

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

the class GuiModWorkbench method drawScreen.

@Override
public void drawScreen(int mx, int my, float partial) {
    super.drawScreen(mx, my, partial);
    for (int i = 0; i < ((ContainerModWorkbench) inventorySlots).slotCount; i++) {
        Slot s = inventorySlots.getSlot(i);
        if (s instanceof IESlot.BlueprintOutput && !s.getHasStack()) {
            BlueprintCraftingRecipe recipe = ((IESlot.BlueprintOutput) s).recipe;
            if (recipe != null && !recipe.output.isEmpty())
                if (isPointInRegion(s.xPos, s.yPos, 16, 16, mx, my)) {
                    ArrayList<String> tooltip = new ArrayList<String>();
                    tooltip.add(recipe.output.getRarity().color + recipe.output.getDisplayName());
                    ArrayList<ItemStack> inputs = new ArrayList<ItemStack>();
                    for (IngredientStack stack : recipe.inputs) {
                        ItemStack toAdd = Utils.copyStackWithAmount(stack.getRandomizedExampleStack(this.mc.player.ticksExisted), stack.inputSize);
                        if (toAdd.isEmpty())
                            continue;
                        boolean isNew = true;
                        for (ItemStack ss : inputs) if (OreDictionary.itemMatches(ss, toAdd, true)) {
                            ss.grow(toAdd.getCount());
                            isNew = false;
                            break;
                        }
                        if (isNew)
                            inputs.add(toAdd.copy());
                    }
                    for (ItemStack ss : inputs) tooltip.add(TextFormatting.GRAY.toString() + ss.getCount() + "x " + ss.getDisplayName());
                    ClientUtils.drawHoveringText(tooltip, mx, my, fontRenderer);
                    RenderHelper.enableGUIStandardItemLighting();
                }
        }
    }
}
Also used : BlueprintCraftingRecipe(blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe) ArrayList(java.util.ArrayList) IESlot(blusunrize.immersiveengineering.common.gui.IESlot) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack) IESlot(blusunrize.immersiveengineering.common.gui.IESlot)

Example 8 with IngredientStack

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

the class TileEntityAssembler method consumeItem.

public Optional<ItemStack> consumeItem(Object query, int querySize, ItemStack[] inventory, ArrayList<ItemStack> containerItems) {
    FluidStack fs = query instanceof FluidStack ? (FluidStack) query : (query instanceof IngredientStack && ((IngredientStack) query).fluid != null) ? ((IngredientStack) query).fluid : null;
    if (fs != null)
        for (FluidTank tank : tanks) if (tank.getFluid() != null && tank.getFluid().containsFluid(fs)) {
            tank.drain(fs.amount, true);
            markDirty();
            this.markContainingBlockForUpdate(null);
            return Optional.absent();
        }
    Optional<ItemStack> ret = null;
    for (int i = 0; i < inventory.length; i++) if (inventory[i] != null && Utils.stackMatchesObject(inventory[i], query, true)) {
        int taken = Math.min(querySize, inventory[i].stackSize);
        boolean doTake = true;
        if (doTake) {
            ret = Optional.of(inventory[i].splitStack(taken));
            if (inventory[i].stackSize <= 0)
                inventory[i] = null;
        }
        querySize -= taken;
        if (querySize <= 0)
            break;
    }
    if (query == null || querySize <= 0)
        return ret;
    return null;
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) FluidStack(net.minecraftforge.fluids.FluidStack) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack) ItemStack(net.minecraft.item.ItemStack)

Example 9 with IngredientStack

use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project BetterWithEngineering by BetterWithMods.

the class SteelRebalance method init.

@Override
public void init(FMLInitializationEvent event) {
    if (BWE.ConfigManager.immersiveEngineering.steel.arcFurnaceCrucible)
        hackMultiblocks();
    // Remove Recipes
    ArcFurnaceRecipe.removeRecipes(new ItemStack(IEContent.itemMetal, 1, 8));
    int ratio = BWE.ConfigManager.immersiveEngineering.steel.ratio;
    if (ModuleLoader.isFeatureEnabled(HarderSteelRecipe.class)) {
        ArcFurnaceRecipe.addRecipe(ItemMaterial.getMaterial(ItemMaterial.EnumMaterial.INGOT_STEEL, ratio), new IngredientStack("ingotIron", ratio), BlockUrn.getStack(BlockUrn.EnumType.EMPTY, 1), 512, 100, new IngredientStack("dustCoke", ratio), BlockUrn.getStack(BlockUrn.EnumType.FULL, 1), ItemMaterial.getMaterial(ItemMaterial.EnumMaterial.SOUL_FLUX, ratio));
    } else {
        ArcFurnaceRecipe.addRecipe(ItemMaterial.getMaterial(ItemMaterial.EnumMaterial.INGOT_STEEL, ratio), new IngredientStack("ingotIron", ratio), BlockUrn.getStack(BlockUrn.EnumType.EMPTY, 1), 512, 100, new IngredientStack("dustCoke", ratio), BlockUrn.getStack(BlockUrn.EnumType.FULL, 1));
    }
    // Add Recipes
    MillRecipes.addMillRecipe(new ItemStack(IEContent.itemMaterial, 1, 17), new String[] { "fuelCoke" });
}
Also used : ItemStack(net.minecraft.item.ItemStack) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack)

Example 10 with IngredientStack

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

the class ManualPageMultiblock method initPage.

@Override
public void initPage(GuiManual gui, int x, int y, List<GuiButton> pageButtons) {
    int yOff = 0;
    if (multiblock.getStructureManual() != null) {
        this.renderInfo = new MultiblockRenderInfo(multiblock);
        this.blockAccess = new MultiblockBlockAccess(renderInfo);
        transX = x + 60 + renderInfo.structureWidth / 2;
        transY = y + 35 + (float) Math.sqrt(renderInfo.structureHeight * renderInfo.structureHeight + renderInfo.structureWidth * renderInfo.structureWidth + renderInfo.structureLength * renderInfo.structureLength) / 2;
        rotX = 25;
        rotY = -45;
        scale = multiblock.getManualScale();
        boolean canRenderFormed = multiblock.canRenderFormedStructure();
        yOff = (int) (transY + scale * Math.sqrt(renderInfo.structureHeight * renderInfo.structureHeight + renderInfo.structureWidth * renderInfo.structureWidth + renderInfo.structureLength * renderInfo.structureLength) / 2);
        pageButtons.add(new GuiButtonManualNavigation(gui, 100, x + 4, (int) transY - (canRenderFormed ? 11 : 5), 10, 10, 4));
        if (canRenderFormed)
            pageButtons.add(new GuiButtonManualNavigation(gui, 103, x + 4, (int) transY + 1, 10, 10, 6));
        if (this.renderInfo.structureHeight > 1) {
            pageButtons.add(new GuiButtonManualNavigation(gui, 101, x + 4, (int) transY - (canRenderFormed ? 14 : 8) - 16, 10, 16, 3));
            pageButtons.add(new GuiButtonManualNavigation(gui, 102, x + 4, (int) transY + (canRenderFormed ? 14 : 8), 10, 16, 2));
        }
    }
    IngredientStack[] totalMaterials = this.multiblock.getTotalMaterials();
    if (totalMaterials != null) {
        componentTooltip = new ArrayList();
        componentTooltip.add(I18n.format("desc.immersiveengineering.info.reqMaterial"));
        int maxOff = 1;
        boolean hasAnyItems = false;
        boolean[] hasItems = new boolean[totalMaterials.length];
        for (int ss = 0; ss < totalMaterials.length; ss++) if (totalMaterials[ss] != null) {
            IngredientStack req = totalMaterials[ss];
            int reqSize = req.inputSize;
            for (int slot = 0; slot < ManualUtils.mc().player.inventory.getSizeInventory(); slot++) {
                ItemStack inSlot = ManualUtils.mc().player.inventory.getStackInSlot(slot);
                if (!inSlot.isEmpty() && req.matchesItemStackIgnoringSize(inSlot))
                    if ((reqSize -= inSlot.getCount()) <= 0)
                        break;
            }
            if (reqSize <= 0) {
                hasItems[ss] = true;
                if (!hasAnyItems)
                    hasAnyItems = true;
            }
            maxOff = Math.max(maxOff, ("" + req.inputSize).length());
        }
        for (int ss = 0; ss < totalMaterials.length; ss++) if (totalMaterials[ss] != null) {
            IngredientStack req = totalMaterials[ss];
            int indent = maxOff - ("" + req.inputSize).length();
            String sIndent = "";
            if (indent > 0)
                for (int ii = 0; ii < indent; ii++) sIndent += "0";
            String s = hasItems[ss] ? (TextFormatting.GREEN + TextFormatting.BOLD.toString() + "\u2713" + TextFormatting.RESET + " ") : hasAnyItems ? ("   ") : "";
            s += TextFormatting.GRAY + sIndent + req.inputSize + "x " + TextFormatting.RESET;
            ItemStack example = req.getExampleStack();
            if (!example.isEmpty())
                s += example.getRarity().color + example.getDisplayName();
            else
                s += "???";
            componentTooltip.add(s);
        }
    }
    super.initPage(gui, x, yOff, pageButtons);
}
Also used : GuiButtonManualNavigation(blusunrize.lib.manual.gui.GuiButtonManualNavigation) ArrayList(java.util.ArrayList) IngredientStack(blusunrize.immersiveengineering.api.crafting.IngredientStack) ItemStack(net.minecraft.item.ItemStack)

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