Package de.eydamos.backpack.inventory.container

Examples of de.eydamos.backpack.inventory.container.ContainerWorkbenchBackpack


    public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
        if(!(gui.inventorySlots instanceof ContainerWorkbenchBackpack)) {
            return;
        }

        ContainerWorkbenchBackpack container = (ContainerWorkbenchBackpack) gui.inventorySlots;
        container.clearCraftMatrix();

        int from = container.getBoundary(Boundaries.CRAFTING);
        int to = container.getBoundary(Boundaries.CRAFTING_END);
        int offsetX = container.isIntelligent() ? -17 : 5;
        int offsetY = 11;

        List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
        ArrayList<SlotStack> newRecipe = new ArrayList<SlotStack>();

        for(PositionedStack positionedStack : ingredients) {
            for(int slotIndex = from; slotIndex < to; slotIndex++) {
                Slot slot = container.getSlot(slotIndex);
                if(slot.xDisplayPosition == positionedStack.relx + offsetX && slot.yDisplayPosition == positionedStack.rely + offsetY) {
                    newRecipe.add(new SlotStack(positionedStack.item, slotIndex));
                    continue;
                }
            }
View Full Code Here


        containerInventories[0] = inventories[0];
        containerInventories[1] = inventories[1];
        containerInventories[2] = craftingGrid;
        containerInventories[3] = recipes;

        ContainerWorkbenchBackpack container;
        if(inventories[1] instanceof AbstractInventoryBackpack) {
            container = new ContainerWorkbenchBackpack(containerInventories, backpack);
        } else {
            container = new ContainerWorkbenchBackpack(craftingGrid);
        }

        // set container width (needed for gui)
        container.setWidth(9 * SLOT + 2 * X_SPACING);

        int xSpacing;
        int x;
        if(backpack.isIntelligent()) {
            xSpacing = X_SPACING;
            x = xSpacing + 72;
        } else {
            xSpacing = BIG_X_SPACING;
            x = xSpacing + 95;
        }
        int y = 17;

        container.addBoundary(Boundaries.EXTRA);

        // result slot
        container.addSlot(new SlotCraftingAdvanced(entityPlayer, container, 0, x, y + 18, containerInventories));

        x = xSpacing;

        container.addBoundary(Boundaries.EXTRA_END);
        container.addBoundary(Boundaries.CRAFTING);

        // crafting grid
        for(int row = 0; row < 3; row++) {
            for(int col = 0; col < 3; col++) {
                container.addSlot(new SlotPhantom(craftingGrid, col + row * 3, x, y));
                x += SLOT;
            }
            y += SLOT;
            x = xSpacing;
        }

        container.addBoundary(Boundaries.CRAFTING_END);

        if(backpack.isIntelligent()) {
            // recipes
            y = 17;
            x += 108;
            for(int row = 0; row < 3; row++) {
                for(int col = 0; col < 3; col++) {
                    container.addSlot(new SlotPhantom(recipes, col + row * 3, x, y));
                    x += SLOT;
                }
                y += SLOT;
                x = xSpacing + 108;
            }
        }

        x = X_SPACING;
        y += 5;

        container.addBoundary(Boundaries.BACKPACK);

        int remainingSlots = inventories[1].getSizeInventory();
        // backpack inventory
        for(int row = 0; row < inventories[1].getSizeInventory() / backpack.getSlotsPerRow(); row++) {
            int cols = remainingSlots - 9 >= 9 ? 9 : remainingSlots;
            remainingSlots -= cols;
            if(cols * SLOT < 9 * SLOT/* && !hasScrollbar */) {
                x += (int) Math.round(9 * SLOT / 2. - cols * SLOT / 2.) + 1;
            }
            for(int col = 0; col < cols; ++col) {
                container.addSlot(new SlotBackpack(inventories[1], col + row * 9, x, y));
                x += SLOT;
            }
            y += SLOT;
            x = X_SPACING;
        }

        container.addBoundary(Boundaries.BACKPACK_END);
        container.addBoundary(Boundaries.INVENTORY);

        y += 14; // space for label

        // player inventory
        for(int row = 0; row < 3; row++) {
            for(int col = 0; col < 9; col++) {
                container.addSlot(new Slot(inventories[0], col + row * 9 + 9, x, y));
                x += SLOT;
            }
            y += SLOT;
            x = X_SPACING;
        }

        container.addBoundary(Boundaries.INVENTORY_END);
        container.addBoundary(Boundaries.HOTBAR);

        y += 6;

        // hotbar
        for(int col = 0; col < 9; col++) {
            container.addSlot(new Slot(inventories[0], col, x, y));
            x += SLOT;
        }

        container.addBoundary(Boundaries.HOTBAR_END);

        y += SLOT;
        y += 7;

        // set container height (needed for gui)
        container.setHeight(y);

        return container;
    }
View Full Code Here

TOP

Related Classes of de.eydamos.backpack.inventory.container.ContainerWorkbenchBackpack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.