Package com.sk89q.craftbook.access

Examples of com.sk89q.craftbook.access.Item


                        if (itemArray[i].id == id &&
                                itemArray[i].count >= 1) {
                            int newAmount = itemArray[i].count - 1;

                            if (newAmount > 0) {
                                itemArray[i] = new Item(itemArray[i].id, newAmount);
                            } else {
                                itemArray[i] = null;
                            }

                            InventoryUtil.setContents(chest, itemArray);
View Full Code Here


        int invenIndex = 0;
        boolean changed = false;

        try {
            for (int cartSlot = 0; cartSlot < fromItems.length; cartSlot++) {
                Item cartItem = fromItems[cartSlot];

                if (cartItem == null || cartItem.count == 0) {
                    continue;
                }

                try {
                    for (; invenIndex < inventories.length; invenIndex++) {
                        Item[] chestItems = inventories[invenIndex].getItems();

                        for (int chestSlot = 0; chestSlot < chestItems.length; chestSlot++) {
                            Item chestItem = chestItems[chestSlot];

                            if (chestItem.id == 0 || chestItem.count == 0) {
                                chestItems[chestSlot] = cartItem;
                                fromItems[cartSlot] = null;
                                setContents(inventories[invenIndex], chestItems);
                                changed = true;
                                throw new TransferredItemException();
                            } else if (chestItem.id == cartItem.id
                                    && chestItem.count < 64
                                    && chestItem.count >= 0) {
                                int spaceAvailable = 64 - chestItem.count;

                                if (spaceAvailable >= cartItem.count) {
                                    chestItem = chestItem.addItems(cartItem.count);
                                    fromItems[cartSlot] = null;
                                    setContents(inventories[invenIndex], chestItems);
                                    changed = true;
                                    throw new TransferredItemException();
                                } else {
                                    cartItem = cartItem.removeItems(spaceAvailable);
                                    chestItem = new Item(chestItem.id, 64);
                                    changed = true;
                                }
                            }
                        }
                    }
View Full Code Here

                boolean changed = false;
                Item[] chestItems = inventory.getItems();

                try {
                    for (int chestSlot = 0; chestSlot < chestItems.length; chestSlot++) {
                        Item chestItem = chestItems[chestSlot];

                        if (chestItem == null || chestItem.count == 0) {
                            continue;
                        }

                        for (int cartSlot = 0; cartSlot < toItems.length; cartSlot++) {
                            Item cartItem = toItems[cartSlot];

                            if (cartItem == null) {
                                toItems[cartSlot] = chestItem;
                                chestItems[chestSlot] = null;
                                changed = true;
                                throw new TransferredItemException();
                            } else if (cartItem.id == chestItem.id
                                    && cartItem.count < 64
                                    && cartItem.count >= 0) {
                                int spaceAvailable = 64 - cartItem.count;

                                if (spaceAvailable >= chestItem.count) {
                                    cartItem = cartItem.addItems(chestItem.count);
                                    chestItems[chestSlot] = null;
                                    changed = true;
                                    throw new TransferredItemException();
                                } else {
                                    chestItem = chestItem.removeItems(spaceAvailable);
                                    cartItem = new Item(cartItem.id, 64);
                                    changed = true;
                                }
                            }
                        }
View Full Code Here

        int size = itemArray.getLength();

        for (int i = 0; i < size; i++) {
            if (contents[i] == null) {
                itemArray.setItem(i, new Item(0, 0));
            } else {
                itemArray.setItem(i, contents[i]);
            }
        }
        itemArray.flushChanges();
View Full Code Here

                for (int i = 0; itemArray.length > i; i++) {
                    // Found an item
                    if (itemArray[i].id == id &&
                            itemArray[i].count < 64) {
                        int newAmount = itemArray[i].count + 1;
                        itemArray[i] = new Item(itemArray[i].id, newAmount);

                        InventoryUtil.setContents(chest, itemArray);

                        return;
                    } else {
                        emptySlot = i;
                    }
                }

                // Didn't find an existing stack, so let's create a new one
                if (emptySlot != -1) {
                    itemArray[emptySlot] = new Item(id, 1);

                    InventoryUtil.setContents(chest, itemArray);

                    return;
                }
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.access.Item

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.