Package de.eydamos.backpack.inventory.container

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


        } else if(type == 2) {
            return new FactoryWorkbenchBackpack().getContainer((BackpackSave) save, inventories, entityPlayer);
        } else if(type == -1) {
            return new FactoryPersonalSlot().getContainer((PlayerSave) save, inventories, entityPlayer);
        }
        return new ContainerAdvanced();
    }
View Full Code Here


public class FactoryBackpackNormal extends AbstractFactory<BackpackSave> {

    @Override
    public ContainerAdvanced getContainer(BackpackSave backpack, IInventory[] inventories, EntityPlayer entityPlayer) {
        ContainerAdvanced container;
        if(inventories[1] instanceof AbstractInventoryBackpack || inventories[1] instanceof InventoryEnderChest) {
            container = new ContainerAdvanced(inventories, backpack);
        } else {
            container = new ContainerAdvanced();
        }

        int slotsPerRow = backpack.getSlotsPerRow();
        int inventoryRows = (int) Math.ceil(inventories[1].getSizeInventory() / (float) slotsPerRow);
        int maxWidth = (slotsPerRow < 9 ? 9 : slotsPerRow) * SLOT;

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

        int x = X_SPACING;
        int y = 17; // initial space for label

        container.addBoundary(Boundaries.BACKPACK);

        int remainingSlots = inventories[1].getSizeInventory();
        // backpack inventory
        for(int row = 0; row < inventoryRows; row++) {
            int cols = remainingSlots >= slotsPerRow ? slotsPerRow : remainingSlots;
            remainingSlots -= cols;
            if(cols * SLOT < maxWidth/* && !hasScrollbar */) {
                x += (int) Math.round(maxWidth / 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

    }

    @Override
    @SideOnly(Side.CLIENT)
    public GuiContainer getGuiContainer(BackpackSave backpack, IInventory[] inventories, EntityPlayer entityPlayer) {
        ContainerAdvanced container = getContainer(backpack, inventories, entityPlayer);
        GuiBackpack guiBackpack = new GuiBackpack(container);

        int slotsPerRow = backpack.getSlotsPerRow();
        int inventoryRows = (int) Math.ceil(inventories[1].getSizeInventory() / (float) slotsPerRow);
        int textPositionY = 17 + inventoryRows * SLOT + 2;
View Full Code Here

            inventorySlot = new InventoryBackpackSlot(player);
        } else {
            inventorySlot = new InventoryBasic(Localizations.INVENTORY_PERSONAL, false, 1);
        }
        InventoryPickup inventoryPickup = new InventoryPickup();
        ContainerAdvanced container = new ContainerPersonalSlot(inventorySlot, inventoryPickup);

        int maxWidth = 160;

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

        int x = (int) Math.round(maxWidth / 2. - SLOT / 2.) + 1;
        int y = 17; // initial space for label

        container.addBoundary(Boundaries.BACKPACK);

        // backpack slot
        container.addSlot(new SlotBackpackOnly(inventorySlot, 0, x, y));

        container.addBoundary(Boundaries.BACKPACK_END);

        x = X_SPACING;
        y += 15 + SLOT;
        // pickup inventory
        for(int i = 0; i < inventoryPickup.getSizeInventory(); i++) {
            container.addSlot(new SlotPhantom(inventoryPickup, i, x, y));
            x += SLOT;
        }

        container.addBoundary(Boundaries.INVENTORY);

        x = X_SPACING;
        y += 24;
        // 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

    }

    @Override
    @SideOnly(Side.CLIENT)
    public GuiContainer getGuiContainer(BackpackSave backpack, IInventory[] inventories, EntityPlayer entityPlayer) {
        ContainerAdvanced container = getContainer(backpack, inventories, entityPlayer);
        GuiWorkbenchBackpack guiBackpack = new GuiWorkbenchBackpack(container);

        GuiSlot guiSlot;
        for(int i = 0; i < container.inventorySlots.size(); i++) {
            Slot slot = (Slot) container.inventorySlots.get(i);
View Full Code Here

TOP

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

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.