Java Code Examples for codechicken.lib.inventory.InventoryUtils#getInsertibleQuantity()

The following examples show how to use codechicken.lib.inventory.InventoryUtils#getInsertibleQuantity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileItemTranslocator.java    From Translocators with MIT License 6 votes vote down vote up
private boolean isSatsified(ItemAttachment ia, InventoryRange access)
{
    boolean filterSet = false;
    for(ItemStack filter : ia.filters)
        if(filter != null)
        {
            filterSet = true;
            if(ia.regulate)
            {
                if(countMatchingStacks(access, filter, !ia.a_eject) < filterCount(ia, filter))
                    return false;
            }
            else
            {
                if(InventoryUtils.getInsertibleQuantity(access, filter) > 0)
                    return false;
            }
        }
    
    return filterSet || !hasEmptySpace(access);
}
 
Example 2
Source File: TileItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
private int insertAmount(ItemStack stack, ItemAttachment ia, InventoryRange range)
{
    int filter = filterCount(ia, stack);
    if(filter == 0)
        return 0;
    
    int fit = InventoryUtils.getInsertibleQuantity(range, stack);
    if(fit == 0)
        return 0;

    if(ia.regulate && filter > 0)
        fit = Math.min(fit, filter-countMatchingStacks(range, stack, true));
    
    return fit > 0 ? fit : 0;
}
 
Example 3
Source File: NEIClientUtils.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static boolean canItemFitInInventory(EntityPlayer player, ItemStack itemstack) {
    return InventoryUtils.getInsertibleQuantity(new InventoryRange(player.inventory, 0, 36), itemstack) > 0;
}
 
Example 4
Source File: NEIClientUtils.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static boolean canItemFitInInventory(EntityPlayer player, ItemStack itemstack) {
    return InventoryUtils.getInsertibleQuantity(new InventoryRange(player.inventory, 0, 36), itemstack) > 0;
}