for (var i = 0; i < 39; i++) {
    if (pinv.getItemInSlot(i) != null) {
        switch (pinv.getItemInSlot(i).itemID) {
        case 325:                                                   //Small Bomb Bag(Bucket)
            if (i != 15) {
                switchSlot(i, 15);
            }
            pinv.getItemInSlot(15).quantity = 20;
            break;
        case 334:                                                   //Large Bomb Bag(Leather)
            if (i != 15) {
                if (pinv.getItemInSlot(15) != null && pinv.getItemInSlot(15).itemID == 353) {
                    var item = pinv.getItemInSlot(i).copy();
                    pinv.emptySlot(i);
                    pinv.setSlot(15, item);
                }
                else {
                    switchSlot(i, 15);
            }   }
            pinv.getItemInSlot(15).quantity = 30;
            break;
        case 335:                                                   //Giant's Bomb Bag(Milk Bucket)
            if (i != 15) {
                if (pinv.getItemInSlot(15) != null && (pinv.getItemInSlot(15).itemID == 353 || pinv.getItemInSlot(15).itemID == 331)) {
                    var item = pinv.getItemInSlot(i).copy();
                    pinv.emptySlot(i);
                    pinv.setSlot(15, item);
                }
                else {
                    switchSlot(i, 15);
            }   }
            pinv.getItemInSlot(15).quantity = 45;
            break;
        case 466:                                                   //Bomb
            if (i != 19 && i > 8) {
                if (pinv.getItemInSlot(19) != null && pinv.getItemInSlot(19).itemID == 466) {
                    pinv.getItemInSlot(19).quantity += pinv.getItemInSlot(i).quantity;
                    pinv.emptySlot(i);
                }
                else
                {
                    switchSlot(i, 19);
            }   }
            bombSlot = pinv.getSlotContainingItem(466);
            if (pinv.consumeItemAmount(466, 0, 17)) {
                pinv.setSlot(bombSlot, Item(466, 16));
            }
            if (pinv.getSlotContainingItem(353) != -1 && pinv.consumeItemAmount(466, 0, 9)) {
                pinv.setSlot(bombSlot, Item(466, 8));
            }
            else if (pinv.getSlotContainingItem(331) != -1 && pinv.consumeItemAmount(466, 0, 13)) {
                pinv.setSlot(bombSlot, Item(466, 12));
            }
            break;
}   }   }