Java Code Examples for codechicken.lib.util.ItemUtils#copyStack()

The following examples show how to use codechicken.lib.util.ItemUtils#copyStack() . 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: SlotDummy.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void putStack(@Nonnull ItemStack stack) {
    if (!stack.isEmpty() && stack.getCount() > stackLimit) {
        stack = ItemUtils.copyStack(stack, stackLimit);
    }
    super.putStack(stack);
}
 
Example 2
Source File: InventoryUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Gets the maximum quantity of an item that can be inserted into inv
 */
public static int getInsertibleQuantity(InventoryRange inv, @Nonnull ItemStack stack) {
    int quantity = 0;
    stack = ItemUtils.copyStack(stack, Integer.MAX_VALUE);
    for (int slot : inv.slots) {
        quantity += fitStackInSlot(inv, slot, stack);
    }

    return quantity;
}
 
Example 3
Source File: InventoryUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static int getInsertableQuantity(IItemHandler handler, ItemStack stack) {
    ItemStack copy = ItemUtils.copyStack(stack, Integer.MAX_VALUE);
    int quantity = 0;
    for (int slot = 0; slot < handler.getSlots(); slot++) {
        if (canInsertStack(handler, slot, copy)) {
            ItemStack left = handler.insertItem(slot, copy, true);
            if (left.isEmpty()) {
                quantity += copy.getCount();
            } else {
                quantity += copy.getCount() - left.getCount();
            }
        }
    }
    return quantity;
}
 
Example 4
Source File: InfiniteStackSizeHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public ItemStack getInfiniteItem(ItemStack typeStack) {
    return ItemUtils.copyStack(typeStack, -1);
}
 
Example 5
Source File: DefaultOverlayHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public DistributedIngred(ItemStack item) {
    stack = ItemUtils.copyStack(item, 1);
}