• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ItemUtils类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中codechicken.lib.util.ItemUtils的典型用法代码示例。如果您正苦于以下问题:Java ItemUtils类的具体用法?Java ItemUtils怎么用?Java ItemUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ItemUtils类属于codechicken.lib.util包,在下文中一共展示了ItemUtils类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: activate

点赞 3

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
@Override
public boolean activate(EntityPlayer player, int subPart) {

    ItemStack held = player.inventory.getCurrentItem();
    if (held.isEmpty()) {
        return super.activate(player, subPart);
    } else if (ItemUtils.areStacksSameType(held, ConfigurationHandler.nugget) && !regulate) {
        regulate = true;

        if (!player.capabilities.isCreativeMode) {
            held.shrink(1);
        }
        markUpdate();
        return true;
    } else if (held.getItem() == Items.IRON_INGOT && !signal) {
        signal = true;

        if (!player.capabilities.isCreativeMode) {
            held.shrink(1);
        }
        markUpdate();
        return true;
    } else {
        return super.activate(player, subPart);
    }
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:27,
代码来源:TileItemTranslocator.java

示例2: activate

点赞 3

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
public void activate(int subHit, EntityPlayer player) {
    ItemStack held = player.inventory.getCurrentItem();
    if (held.isEmpty()) {
        if (!items[subHit].isEmpty()) {
            giveOrDropItem(items[subHit], player);
        }
        items[subHit] = ItemStack.EMPTY;
    } else {
        if (!InventoryUtils.areStacksIdentical(held, items[subHit])) {
            ItemStack old = items[subHit];
            items[subHit] = ItemUtils.copyStack(held, 1);
            player.inventory.decrStackSize(player.inventory.currentItem, 1);

            if (!old.isEmpty()) {
                giveOrDropItem(old, player);
            }
        }
    }

    timeout = 2400;
    IBlockState state = world.getBlockState(getPos());
    world.notifyBlockUpdate(getPos(), state, state, 3);
    markDirty();
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:25,
代码来源:TileCraftingGrid.java

示例3: slotClick

点赞 3

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
@Override
public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, ClickType clickType) {
    ItemStack held = player.inventory.getItemStack();
    if (button == 0 && clickType == ClickType.QUICK_MOVE) {
        NEIClientUtils.cheatItem(getStack(), button, -1);
    } else if (button == 1) {
        putStack(ItemStack.EMPTY);
    } else if (!held.isEmpty()) {
        if (isItemValid(held)) {
            putStack(ItemUtils.copyStack(held, 1));
            player.inventory.setItemStack(ItemStack.EMPTY);
        }
    } else if (getHasStack()) {
        player.inventory.setItemStack(getStack());
    }

    return ItemStack.EMPTY;
}
 

开发者ID:TheCBProject,
项目名称:NotEnoughItems,
代码行数:19,
代码来源:ContainerPotionCreator.java

示例4: putStack

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
@Override
public void putStack(@Nonnull ItemStack stack) {
    if (!stack.isEmpty() && stack.getCount() > stackLimit) {
        stack = ItemUtils.copyStack(stack, stackLimit);
    }
    super.putStack(stack);
}
 

开发者ID:TheCBProject,
项目名称:CodeChickenLib,
代码行数:8,
代码来源:SlotDummy.java

示例5: getInsertibleQuantity

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
/**
 * 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;
}
 

开发者ID:TheCBProject,
项目名称:CodeChickenLib,
代码行数:13,
代码来源:InventoryUtils.java

示例6: insertItem

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
/**
 * @param simulate If set to true, no items will actually be inserted
 * @return The number of items unable to be inserted
 */
public static int insertItem(InventoryRange inv, @Nonnull ItemStack stack, boolean simulate) {
    stack = stack.copy();
    for (int pass = 0; pass < 2; pass++) {
        for (int slot : inv.slots) {
            ItemStack base = inv.inv.getStackInSlot(slot);
            if ((pass == 0) == (base.isEmpty())) {
                continue;
            }
            int fit = fitStackInSlot(inv, slot, stack);
            if (fit == 0) {
                continue;
            }

            if (!base.isEmpty()) {
                stack.shrink(fit);
                if (!simulate) {
                    base.grow(fit);
                    inv.inv.setInventorySlotContents(slot, base);
                }
            } else {
                if (!simulate) {
                    inv.inv.setInventorySlotContents(slot, ItemUtils.copyStack(stack, fit));
                }
                stack.shrink(fit);
            }
            if (stack.getCount() == 0) {
                return 0;
            }
        }
    }
    return stack.getCount();
}
 

开发者ID:TheCBProject,
项目名称:CodeChickenLib,
代码行数:37,
代码来源:InventoryUtils.java

示例7: countMatchingStacks

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
/**
 * Counts the matching stacks.
 * Checks for insertion or extraction.
 *
 * @param handler The inventory.
 * @param filter What we are checking for.
 * @param insert If we are checking for insertion or extraction.
 * @return The total number of items of the specified filter type.
 */
public static int countMatchingStacks(IItemHandler handler, ItemStack filter, boolean insert) {

    int c = 0;
    for (int slot = 0; slot < handler.getSlots(); slot++) {
        ItemStack stack = handler.getStackInSlot(slot);
        if (!stack.isEmpty() && ItemUtils.areStacksSameType(filter, stack) && (insert ? canInsertStack(handler, slot, stack) : canExtractStack(handler, slot))) {
            c += stack.getCount();
        }
    }
    return c;
}
 

开发者ID:TheCBProject,
项目名称:CodeChickenLib,
代码行数:21,
代码来源:InventoryUtils.java

示例8: getInsertableQuantity

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
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;
}
 

开发者ID:TheCBProject,
项目名称:CodeChickenLib,
代码行数:16,
代码来源:InventoryUtils.java

示例9: stripModifiers

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
@Override
public void stripModifiers() {

    super.stripModifiers();
    if (regulate) {
        regulate = false;
        dropItem(ItemUtils.copyStack(ConfigurationHandler.nugget, 1));
    }
    if (signal) {
        setPowering(false);
        signal = false;
        dropItem(new ItemStack(Items.IRON_INGOT));
    }
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:15,
代码来源:TileItemTranslocator.java

示例10: getDrops

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
@Override
public Collection<ItemStack> getDrops(IBlockState state) {

    Collection<ItemStack> stuff = super.getDrops(state);
    if (regulate) {
        stuff.add(ItemUtils.copyStack(ConfigurationHandler.nugget, 1));
    }
    if (signal) {
        stuff.add(new ItemStack(Items.IRON_INGOT));
    }
    return stuff;
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:13,
代码来源:TileItemTranslocator.java

示例11: spreadOutput

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
private void spreadOutput(ItemStack move, int src, boolean rspass, InventoryRange[] attached) {

        if (move.getCount() == 0) {
            return;
        }

        int outputCount = 0;
        int[] outputQuantities = new int[6];
        for (int i = 0; i < 6; i++) {
            ItemAttachment ia = (ItemAttachment) attachments[i];
            if (ia != null && !ia.a_eject && ia.redstone == rspass) {
                outputQuantities[i] = insertAmount(move, ia, attached[i]);
                if (outputQuantities[i] > 0) {
                    outputCount++;
                }
            }
        }

        for (int dst = 0; dst < 6 && move.getCount() > 0; dst++) {
            int qty = outputQuantities[dst];
            if (qty <= 0) {
                continue;
            }

            qty = Math.min(qty, move.getCount() / outputCount + world.rand.nextInt(move.getCount() % outputCount + 1));
            outputCount--;

            if (qty == 0) {
                continue;
            }

            InventoryRange range = attached[dst];
            ItemStack add = ItemUtils.copyStack(move, qty);
            InventoryUtils.insertItem(range, add, false);
            move.shrink(qty);

            sendTransferPacket(src, dst, add);
        }
    }
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:40,
代码来源:TileItemTranslocator.java

示例12: dropItems

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
public void dropItems() {
    Vector3 drop = Vector3.fromTileCenter(this);
    for (ItemStack item : items) {
        if (!item.isEmpty()) {
            ItemUtils.dropItem(item, world, drop);
        }
    }
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:9,
代码来源:TileCraftingGrid.java

示例13: giveOrDropItem

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
private void giveOrDropItem(ItemStack stack, EntityPlayer player) {
    if (player.inventory.addItemStackToInventory(stack)) {
        player.inventoryContainer.detectAndSendChanges();
    } else {
        ItemUtils.dropItem(stack, world, Vector3.fromTileCenter(this));
    }
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:8,
代码来源:TileCraftingGrid.java

示例14: dropItem

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
public void dropItem(ItemStack stack) {
    ItemUtils.dropItem(stack, world, Vector3.fromTileCenter(this));
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:4,
代码来源:TileTranslocator.java

示例15: drawSlotItem

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
public void drawSlotItem(Slot par1Slot, ItemStack itemstack, int i, int j, String s) {
    itemRender.renderItemAndEffectIntoGUI(itemstack, i, j);
    FontUtils.drawItemQuantity(i, j, itemstack, null, 0);
    itemRender.renderItemOverlayIntoGUI(fontRendererObj, ItemUtils.copyStack(itemstack, 1), i, j, null);
}
 

开发者ID:TheCBProject,
项目名称:Translocators,
代码行数:6,
代码来源:GuiTranslocator.java

示例16: getInfiniteItem

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
@Override
public ItemStack getInfiniteItem(ItemStack typeStack) {
    return ItemUtils.copyStack(typeStack, -1);
}
 

开发者ID:TheCBProject,
项目名称:NotEnoughItems,
代码行数:5,
代码来源:InfiniteStackSizeHandler.java

示例17: DistributedIngred

点赞 2

import codechicken.lib.util.ItemUtils; //导入依赖的package包/类
public DistributedIngred(ItemStack item) {
    stack = ItemUtils.copyStack(item, 1);
}
 

开发者ID:TheCBProject,
项目名称:NotEnoughItems,
代码行数:4,
代码来源:DefaultOverlayHandler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)