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


Java InventoryUtils类代码示例

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


InventoryUtils类属于codechicken.lib.inventory包,在下文中一共展示了InventoryUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: givePlayerItem

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
        player.addChatComponentMessage(setColour(new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
        return;
    }

    int given = stack.stackSize;
    if(doGive) {
        if (infinite)
            player.inventory.addItemStackToInventory(stack);
        else
            given -= InventoryUtils.insertItem(player.inventory, stack, false);
    }

    sendNotice(player, new ChatComponentTranslation("commands.give.success", stack.func_151000_E(), infinite ? "\u221E" : Integer.toString(given), player.getCommandSenderName()), "notify-item");
    player.openContainer.detectAndSendChanges();
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:18,代码来源:NEIServerUtils.java

示例3: slotClick

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

    return null;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:18,代码来源:ContainerPotionCreator.java

示例4: fillTankWithContainer

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player)
{
    ItemStack stack = player.getCurrentEquippedItem();
    FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);

    if(liquid == null)
        return false;

    if(tank.fill(ForgeDirection.UNKNOWN, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode)
        return false;
    
    tank.fill(ForgeDirection.UNKNOWN, liquid, true);
    
    if(!player.capabilities.isCreativeMode)
        InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);

    player.inventoryContainer.detectAndSendChanges();
    return true;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:20,代码来源:FluidUtils.java

示例5: fillTankWithContainer

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player) {
    ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
    FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);

    if (liquid == null) {
        return false;
    }

    if (tank.fill(liquid, false) != liquid.amount && !player.capabilities.isCreativeMode) {
        return false;
    }

    tank.fill(liquid, true);

    if (!player.capabilities.isCreativeMode) {
        InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);
    }

    player.inventoryContainer.detectAndSendChanges();
    return true;
}
 
开发者ID:TheCBProject,项目名称:CodeChickenCore,代码行数:22,代码来源:FluidUtils.java

示例6: givePlayerItem

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
        player.addChatComponentMessage(setColour(new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
        return;
    }

    int given = stack.stackSize;
    if(doGive) {
        if (infinite)
            player.inventory.addItemStackToInventory(stack);
        else
            given -= InventoryUtils.insertItem(player.inventory, stack, false);
    }

    sendNotice(player, new ChatComponentTranslation("commands.give.success", stack.getChatComponent(), infinite ? "\u221E" : Integer.toString(given), player.getCommandSenderName()), "notify-item");
    player.openContainer.detectAndSendChanges();
}
 
开发者ID:SneakyTactician,项目名称:BIGB,代码行数:18,代码来源:NEIServerUtils.java

示例7: isSatsified

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
private boolean isSatsified(ItemAttachment ia, InventoryRange access) {

        boolean filterSet = false;
        for (ItemStack filter : ia.filters) {
            if (!filter.isEmpty()) {
                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);
    }
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:21,代码来源:TileItemTranslocator.java

示例8: insertAmount

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
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;
    }
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:19,代码来源:TileItemTranslocator.java

示例9: activate

import codechicken.lib.inventory.InventoryUtils; //导入依赖的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

示例10: givePlayerItem

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void givePlayerItem(EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
        player.sendMessage(setColour(new TextComponentTranslation("nei.chat.give.noitem"), TextFormatting.WHITE));
        return;
    }

    int given = stack.getCount();
    if (doGive) {
        if (infinite) {
            player.inventory.addItemStackToInventory(stack);
        } else {
            given -= InventoryUtils.insertItem(player.inventory, stack, false);
        }
    }

    sendNotice(player, new TextComponentTranslation("commands.give.success", stack.getTextComponent(), infinite ? "\u221E" : Integer.toString(given), player.getName()), "notify-item");
    player.openContainer.detectAndSendChanges();
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:19,代码来源:NEIServerUtils.java

示例11: saveBannedItems

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void saveBannedItems() {
    File file = new File(saveDir, "banneditems.cfg");
    try {
        if(!file.exists())
            file.createNewFile();

        PrintWriter p = new PrintWriter(file);
        p.println("#Saved in this format for external editing. The format isn't that hard to figure out. If you think you're up to it, modify it here!");

        for (ItemStackMap.Entry<Set<String>> entry : bannedItems.entries()) {
            NBTTagCompound key = InventoryUtils.savePersistant(entry.key, new NBTTagCompound());
            key.removeTag("Count");
            if(key.getByte("Damage") == 0) key.removeTag("Damage");

            p.print(key.toString());
            p.print("=[");
            int i = 0;
            for (String s : entry.value) {
                if(i++ != 0) p.print(", ");
                p.print(s);
            }
            p.println("]");
        }
        p.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:29,代码来源:NEIServerConfig.java

示例12: 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

示例13: 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

示例14: sendOpenPotionWindow

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
public static void sendOpenPotionWindow() {
    ItemStack[] potionStore = new ItemStack[9];
    InventoryUtils.readItemStacksFromTag(potionStore, NEIClientConfig.global.nbt.getCompoundTag("potionStore").getTagList("items", 10));
    PacketCustom packet = new PacketCustom(channel, 24);
    for (ItemStack stack : potionStore)
        packet.writeItemStack(stack);
    packet.sendToServer();
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:9,代码来源:NEICPH.java

示例15: dump

import codechicken.lib.inventory.InventoryUtils; //导入依赖的package包/类
@Override
public Iterable<String[]> dump(int mode) {
    LinkedList<String[]> list = new LinkedList<String[]>();
    for (ItemStack stack : ItemPanel.items)
        list.add(new String[]{
                Item.itemRegistry.getNameForObject(stack.getItem()),
                Integer.toString(Item.getIdFromItem(stack.getItem())),
                Integer.toString(InventoryUtils.actualDamage(stack)),
                stack.stackTagCompound == null ? "false" : "true",
                EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.itemDisplayNameShort(stack))
        });

    return list;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:15,代码来源:ItemPanelDumper.java


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