当前位置: 首页>>代码示例>>Java>>正文


Java InventoryUtils.canStack方法代码示例

本文整理汇总了Java中codechicken.lib.inventory.InventoryUtils.canStack方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryUtils.canStack方法的具体用法?Java InventoryUtils.canStack怎么用?Java InventoryUtils.canStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在codechicken.lib.inventory.InventoryUtils的用法示例。


在下文中一共展示了InventoryUtils.canStack方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findIngred

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public DistributedIngred findIngred(final List<DistributedIngred> ingredStacks, final ItemStack pstack) {
    for (final DistributedIngred istack : ingredStacks) {
        if (istack.isSaw) {
            if (this.sameSaw(pstack, istack.stack)) {
                return istack;
            }
            continue;
        }
        else {
            if (InventoryUtils.canStack(pstack, istack.stack)) {
                return istack;
            }
            continue;
        }
    }
    return null;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:18,代码来源:FMPMicroBlocksOverlayHandler.java

示例2: assignIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks)
{
    ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
    for(PositionedStack posstack : ingredients)//assign what we need and have
    {
        DistributedIngred biggestIngred = null;
        ItemStack permutation = null;
        int biggestSize = 0;
        for(ItemStack pstack : posstack.items)
        {
            for(int j = 0; j < ingredStacks.size(); j++)
            {
                DistributedIngred istack = ingredStacks.get(j);
                if(!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount-istack.distributed < pstack.stackSize)
                    continue;
                
                int relsize = (istack.invAmount-istack.invAmount/istack.recipeAmount*istack.distributed)/pstack.stackSize;
                if(relsize > biggestSize)
                {
                    biggestSize = relsize;
                    biggestIngred = istack;
                    permutation = pstack;
                    break;
                }
            }
        }
        
        if(biggestIngred == null)//not enough ingreds
            return null;

        biggestIngred.distributed+=permutation.stackSize;
        assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
    }
    
    return assignedIngredients;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:37,代码来源:DefaultOverlayHandler.java

示例3: findIngred

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public DistributedIngred findIngred(List<DistributedIngred> ingredStacks, ItemStack pstack)
{
    for(DistributedIngred istack : ingredStacks)
        if(InventoryUtils.canStack(pstack, istack.stack))
            return istack;
    return null;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:8,代码来源:DefaultOverlayHandler.java

示例4: assignIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks) {
    ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<>();
    for (PositionedStack posstack : ingredients)//assign what we need and have
    {
        DistributedIngred biggestIngred = null;
        ItemStack permutation = null;
        int biggestSize = 0;
        for (ItemStack pstack : posstack.items) {
            for (int j = 0; j < ingredStacks.size(); j++) {
                DistributedIngred istack = ingredStacks.get(j);
                if (!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount - istack.distributed < pstack.getCount()) {
                    continue;
                }

                int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.getCount();
                if (relsize > biggestSize) {
                    biggestSize = relsize;
                    biggestIngred = istack;
                    permutation = pstack;
                    break;
                }
            }
        }

        if (biggestIngred == null)//not enough ingreds
        {
            return null;
        }

        biggestIngred.distributed += permutation.getCount();
        assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
    }

    return assignedIngredients;
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:36,代码来源:DefaultOverlayHandler.java

示例5: findIngred

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
public DistributedIngred findIngred(List<DistributedIngred> ingredStacks, ItemStack pstack) {
    for (DistributedIngred istack : ingredStacks) {
        if (InventoryUtils.canStack(pstack, istack.stack)) {
            return istack;
        }
    }
    return null;
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:9,代码来源:DefaultOverlayHandler.java

示例6: moveIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private void moveIngredients(final GuiContainer gui, final List<IngredientDistribution> assignedIngredients, final int quantity) {
    for (final IngredientDistribution distrib : assignedIngredients) {
        final ItemStack pstack = distrib.permutation;
        int transferCap = quantity * pstack.stackSize;
        int transferred = 0;
        if (distrib.distrib.isSaw) {
            transferCap = 1;
        }
        int destSlotIndex = 0;
        Slot dest = distrib.slots[0];
        int slotTransferred = 0;
        final int slotTransferCap = pstack.getMaxStackSize();
        for (final Slot slot : (Collection<Slot>) gui.inventorySlots.inventorySlots) {
            if (slot.getHasStack()) {
                if (!(slot.inventory instanceof InventoryPlayer)) {
                    continue;
                }
                final ItemStack stack = slot.getStack();
                if (distrib.distrib.isSaw) {
                    if (!sameItemStack(stack, pstack)) {
                        continue;
                    }
                }
                else if (!InventoryUtils.canStack(stack, pstack)) {
                    continue;
                }
                FastTransferManager.clickSlot(gui, slot.slotNumber);
                for (int amount = Math.min(transferCap - transferred, stack.stackSize), c = 0; c < amount; ++c) {
                    FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
                    ++transferred;
                    if (++slotTransferred >= slotTransferCap) {
                        if (++destSlotIndex == distrib.slots.length) {
                            dest = null;
                            break;
                        }
                        dest = distrib.slots[destSlotIndex];
                        slotTransferred = 0;
                    }
                }
                FastTransferManager.clickSlot(gui, slot.slotNumber);
                if (transferred >= transferCap) {
                    break;
                }
                if (dest == null) {
                    break;
                }
                continue;
            }
        }
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:52,代码来源:FMPMicroBlocksOverlayHandler.java

示例7: assignIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
private List<IngredientDistribution> assignIngredients(final List<PositionedStack> ingredients, final List<DistributedIngred> ingredStacks) {
    final ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
    for (final PositionedStack posstack : ingredients) {
        DistributedIngred biggestIngred = null;
        ItemStack permutation = null;
        int biggestSize = 0;
        for (final ItemStack pstack : posstack.items) {
            final boolean isSaw = isSaw(pstack);
            for (int j = 0; j < ingredStacks.size(); ++j) {
                final DistributedIngred istack = ingredStacks.get(j);
                if (isSaw == istack.isSaw) {
                    if (isSaw) {
                        if (this.sameSaw(pstack, istack.stack)) {
                            if (istack.invAmount - istack.distributed >= pstack.stackSize) {
                                biggestSize = 1;
                                biggestIngred = istack;
                                permutation = pstack;
                                break;
                            }
                        }
                    }
                    else if (InventoryUtils.canStack(pstack, istack.stack)) {
                        if (istack.invAmount - istack.distributed >= pstack.stackSize) {
                            final int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.stackSize;
                            if (relsize > biggestSize) {
                                biggestSize = relsize;
                                biggestIngred = istack;
                                permutation = pstack;
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (biggestIngred == null) {
            return null;
        }
        final DistributedIngred distributedIngred = biggestIngred;
        distributedIngred.distributed += permutation.stackSize;
        assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
    }
    return assignedIngredients;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:45,代码来源:FMPMicroBlocksOverlayHandler.java

示例8: moveIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity)
{        
    for(IngredientDistribution distrib : assignedIngredients)
    {
        ItemStack pstack = distrib.permutation;
        int transferCap = quantity*pstack.stackSize;
        int transferred = 0;
        
        int destSlotIndex = 0;
        Slot dest = distrib.slots[0];
        int slotTransferred = 0;
        int slotTransferCap = pstack.getMaxStackSize();
        
        for(Slot slot : (List<Slot>)gui.inventorySlots.inventorySlots)
        {
            if(!slot.getHasStack() || !(slot.inventory instanceof InventoryPlayer))
                continue;
            
            ItemStack stack = slot.getStack();
            if(!InventoryUtils.canStack(stack, pstack))
                continue;
            
            FastTransferManager.clickSlot(gui, slot.slotNumber);
            int amount = Math.min(transferCap-transferred, stack.stackSize);
            for(int c = 0; c < amount; c++)
            {
                FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
                transferred++;
                slotTransferred++;
                if(slotTransferred >= slotTransferCap)
                {
                    destSlotIndex++;
                    if(destSlotIndex == distrib.slots.length)
                    {
                        dest = null;
                        break;
                    }
                    dest = distrib.slots[destSlotIndex];
                    slotTransferred = 0;
                }
            }
            FastTransferManager.clickSlot(gui, slot.slotNumber);
            if(transferred >= transferCap || dest == null)
                break;
        }
    }       
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:49,代码来源:DefaultOverlayHandler.java

示例9: moveIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity)
{        
    for(IngredientDistribution distrib : assignedIngredients)
    {
        ItemStack pstack = distrib.permutation;
        int transferCap = quantity*pstack.stackSize;
        int transferred = 0;
        
        int destSlotIndex = 0;
        Slot dest = distrib.slots[0];
        int slotTransferred = 0;
        int slotTransferCap = pstack.getMaxStackSize();
        
        for(Slot slot : (List<Slot>)gui.inventorySlots.inventorySlots)
        {
            if(!slot.getHasStack() || !canMoveFrom(slot, gui))
                continue;
            
            ItemStack stack = slot.getStack();
            if(!InventoryUtils.canStack(stack, pstack))
                continue;
            
            FastTransferManager.clickSlot(gui, slot.slotNumber);
            int amount = Math.min(transferCap-transferred, stack.stackSize);
            for(int c = 0; c < amount; c++)
            {
                FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
                transferred++;
                slotTransferred++;
                if(slotTransferred >= slotTransferCap)
                {
                    destSlotIndex++;
                    if(destSlotIndex == distrib.slots.length)
                    {
                        dest = null;
                        break;
                    }
                    dest = distrib.slots[destSlotIndex];
                    slotTransferred = 0;
                }
            }
            FastTransferManager.clickSlot(gui, slot.slotNumber);
            if(transferred >= transferCap || dest == null)
                break;
        }
    }       
}
 
开发者ID:SneakyTactician,项目名称:BIGB,代码行数:49,代码来源:DefaultOverlayHandler.java

示例10: moveIngredients

import codechicken.lib.inventory.InventoryUtils; //导入方法依赖的package包/类
@SuppressWarnings ("unchecked")
private void moveIngredients(GuiContainer gui, List<IngredientDistribution> assignedIngredients, int quantity) {
    for (IngredientDistribution distrib : assignedIngredients) {
        ItemStack pstack = distrib.permutation;
        int transferCap = quantity * pstack.getCount();
        int transferred = 0;

        int destSlotIndex = 0;
        Slot dest = distrib.slots[0];
        int slotTransferred = 0;
        int slotTransferCap = pstack.getMaxStackSize();

        for (Slot slot : gui.inventorySlots.inventorySlots) {
            if (!slot.getHasStack() || !canMoveFrom(slot, gui)) {
                continue;
            }

            ItemStack stack = slot.getStack();
            if (!InventoryUtils.canStack(stack, pstack)) {
                continue;
            }

            FastTransferManager.clickSlot(gui, slot.slotNumber);
            int amount = Math.min(transferCap - transferred, stack.getCount());
            for (int c = 0; c < amount; c++) {
                FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
                transferred++;
                slotTransferred++;
                if (slotTransferred >= slotTransferCap) {
                    destSlotIndex++;
                    if (destSlotIndex == distrib.slots.length) {
                        dest = null;
                        break;
                    }
                    dest = distrib.slots[destSlotIndex];
                    slotTransferred = 0;
                }
            }
            FastTransferManager.clickSlot(gui, slot.slotNumber);
            if (transferred >= transferCap || dest == null) {
                break;
            }
        }
    }
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:46,代码来源:DefaultOverlayHandler.java


注:本文中的codechicken.lib.inventory.InventoryUtils.canStack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。