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


Java ItemStack.isEmpty方法代码示例

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


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

示例1: amountRequested

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public int amountRequested(ItemStack stack) {
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if (totalRequestingAmount > 0) {
        IItemHandler inv = IOHelper.getInventoryForTE(getTileEntity());
        int count = 0;
        if (inv != null) {
            for (int i = 0; i < inv.getSlots(); i++) {
                ItemStack s = inv.getStackInSlot(i);
                if (!s.isEmpty() && isItemEqual(s, stack)) {
                    count += s.getCount();
                }
            }
            count += getIncomingItems(stack);
            return Math.max(0, Math.min(stack.getCount(), totalRequestingAmount - count));
        }
    }
    return 0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:20,代码来源:SemiBlockRequester.java

示例2: handleGUIButtonPress

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void handleGUIButtonPress(int buttonID, EntityPlayer player) {
    switch (buttonID) {
        case 0:
            if (++redstoneMode > 1) redstoneMode = 0;
            break;
        case 1:
            ItemStack stack = inventory.getStackInSlot(PROGRAM_SLOT);
            NBTTagCompound tag = stack.isEmpty() ? null : stack.getTagCompound();
            if (tag != null)
                readProgWidgetsFromNBT(tag);
            else
                progWidgets.clear();
            break;
        case 2:
            tryProgramDrone(player);
            break;
        case 9:
            undo();
            break;
        case 10:
            redo();
            break;
    }
    sendDescriptionPacket();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:27,代码来源:TileEntityProgrammer.java

示例3: extractItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Nonnull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
    if (amount == 0) return ItemStack.EMPTY;
    ItemStack existing = tile.getItemStack().copy();
    if (existing.isEmpty()) return ItemStack.EMPTY;
    if (tile.getAmount() <= amount) {
        int newAmount = tile.getAmount();
        if (!simulate) {
            tile.setAmount(0);
            outItems.setStackInSlot(0, ItemStack.EMPTY);
        }
        return ItemHandlerHelper.copyStackWithSize(existing, newAmount);
    } else {
        if (!simulate) {
            tile.setAmount(tile.amount - amount);
        }
        return ItemHandlerHelper.copyStackWithSize(existing, amount);
    }
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:21,代码来源:BlackHoleUnitTile.java

示例4: renderItemInWorld

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack){
    if(!stack.isEmpty()){
        Minecraft mc = Minecraft.getMinecraft();
        RenderItem renderer = mc.getRenderItem();
        TextureManager manager = mc.getTextureManager();

        IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null);

        manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
        GlStateManager.enableRescaleNormal();
        GlStateManager.enableBlend();
        GlStateManager.pushMatrix();
        model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false);
        renderer.renderItem(stack, model);
        GlStateManager.cullFace(GlStateManager.CullFace.BACK);
        GlStateManager.popMatrix();
        GlStateManager.disableRescaleNormal();
        GlStateManager.disableBlend();
        manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:25,代码来源:Util.java

示例5: canSmelt

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
 */
private boolean canSmelt(int id)
{
    int inputIndex = type.getFirstInputSlot(id);
    int outputIndex = type.getFirstOutputSlot(id);

    ItemStack input = itemHandler.getStackInSlot(inputIndex);
    ItemStack output = itemHandler.getStackInSlot(outputIndex);

    if (input.isEmpty())
    {
        return false;
    } else
    {
        ItemStack res = FurnaceRecipes.instance().getSmeltingResult(input);
        if (res.isEmpty())
            return false;
        if (output.isEmpty())
            return true;
        if (!output.isItemEqual(res))
            return false;
        int result = output.getCount() + res.getCount();
        return result <= itemHandler.getSlotLimit(outputIndex) && result <= res.getMaxStackSize();
    }
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:28,代码来源:TileEntityIronFurnace.java

示例6: getBlocksFromString

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ArrayList<Block> getBlocksFromString(String blockName)
{
	ArrayList<Block> blocks = new ArrayList<>();
	if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName)))
		blocks.add(Block.getBlockFromName(blockName));
	for(ItemStack oreStack : OreDictionary.getOres(blockName))
		if(oreStack.getItem() instanceof ItemBlock)
			blocks.add(((ItemBlock)oreStack.getItem()).getBlock());
	ArrayList<Block> finalBlocks = new ArrayList<>();
	for(Block b : blocks)
	{
		NonNullList<ItemStack> items = NonNullList.create();
		b.getSubBlocks(CreativeTabs.SEARCH, items);
		for(ItemStack stack : items)
			if(!stack.isEmpty())
				finalBlocks.add(Block.getBlockFromItem(stack.getItem()));
			else
				finalBlocks.add(b);
	}
	return finalBlocks;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:22,代码来源:HarshenUtils.java

示例7: fillInventory

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void fillInventory(IInventory inventory, Random rand, LootContext context)
{
	TileEntityChest chest = (TileEntityChest) inventory;
    CustomLootContext.Builder context$builder = new CustomLootContext.Builder((WorldServer) chest.getWorld());
    context$builder.withChestPos(chest.getPos());
    CustomLootContext customContext = context$builder.build();
	
    List<ItemStack> list = this.generateLootForPools(rand, customContext);
    List<Integer> list1 = this.getEmptySlotsRandomized(inventory, rand);
    this.shuffleItems(list, list1.size(), rand);

    for (ItemStack itemstack : list)
    {
        if (list1.isEmpty())
        {
        	LootSlashConquer.LOGGER.warn("Tried to over-fill a container");
            return;
        }
        
        if (itemstack.isEmpty())
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), ItemStack.EMPTY);
        }
        else
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), itemstack);
        }
    }
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:31,代码来源:CustomLootTable.java

示例8: updateStatus

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void updateStatus()
{
    TileEntity te = world.getTileEntity(pos);
    if (te != null && te instanceof TileTranslationDesk)
    {
        TileTranslationDesk ttd = (TileTranslationDesk) te;
        ItemStack stack = ttd.handler.getStackInSlot(0);
        if (panel.translating)
        {
            status = Status.TRANSLATING;
            return;
        }
        entryName = null;
        if (!stack.isEmpty())
        {
            for (Pair<IfEntry, IRSTranslatePapyrus> p : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSTranslatePapyrus.class, Minecraft.getMinecraft().player))
            {
                if (p.getRight().isSuitable(stack))
                {
                    this.entryName = p.getLeft().getId();
                    this.stack = stack;
                    status = Status.CAN_TRANSLATE;
                    return;
                }
            }
            status = Status.CANT_TRANSLATE;
            return;
        }
    }
    status = Status.NO_PAPYRUS;
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:32,代码来源:GuiTranslationDesk.java

示例9: isEmpty

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean isEmpty () {
    for (ItemStack stack : furnaceItemStacks) {
        if (!stack.isEmpty())
            return false;
    }

    return true;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:10,代码来源:TileBloomeryFurnace.java

示例10: getData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static WeaponData getData(ItemStack stack) {
	WeaponData value = BLANK_DATA;
	if(!stack.isEmpty() && stack.hasCapability(TF2weapons.WEAPONS_DATA_CAP, null)) {
		value=stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null).inst;
		if (value == BLANK_DATA && stack.hasTagCompound() && MapList.nameToData.containsKey(stack.getTagCompound().getString("Type")))
			value = stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null).inst = MapList.nameToData.get(stack.getTagCompound().getString("Type"));
	}
	return value;	
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:10,代码来源:ItemFromData.java

示例11: doImport

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
protected boolean doImport(int maxItems) {
    boolean success = false;

    // Suck from input inventory
    IItemHandler handler = IOHelper.getInventoryForTE(IOHelper.getNeighbor(this, inputDir));
    if (handler != null) {
        for (int i = 0; i < maxItems; i++) {
            LocatedItemStack extracted = IOHelper.extractOneItem(handler, true);
            if (!extracted.stack.isEmpty()) {
                ItemStack excess = ItemHandlerHelper.insertItem(inventory, extracted.stack, false);
                if (excess.isEmpty()) {
                    handler.extractItem(extracted.slot, 1, false);
                    success = true;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
    }

    // Suck in item entities
    for (EntityItem entity : getNeighborItems(this, inputDir)) {
        if (!entity.isDead) {
            ItemStack remainder = IOHelper.insert(this, entity.getItem(), null, false);
            if (remainder.isEmpty()) {
                entity.setDead();
                success = true;
            }
        }
    }

    return success;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:36,代码来源:TileEntityOmnidirectionalHopper.java

示例12: matches

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
	ArrayList<ItemStack> stacks = new ArrayList<>();

	for (int x = 0; x < inv.getSizeInventory(); x++) {
		ItemStack stack = inv.getStackInSlot(x);
		if (!stack.isEmpty())
			if (stacks.size() < 2 && stack.getItem() instanceof ItemFromData && ItemFromData.getData(stack).getInt(PropertyType.COST) >= 6)
				stacks.add(stack);
			else
				return false;
	}
	// System.out.println("matches "+(australium&&stack2!=null));
	return stacks.size() == 2;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:16,代码来源:RecipeToScrap.java

示例13: getSlotData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SuppressWarnings("SuspiciousNameCombination")
   public static Map<Pair<Integer, Integer>, Boolean> getSlotData(EntityPlayer player)
{
	HashMap<Pair<Integer, Integer>, Boolean> ret = Maps.newHashMap();
	for (int i = 9; i < 36; ++i)
	{
		ItemStack is = player.inventory.getStackInSlot(i);
		if (!is.isEmpty())
		{
			int x = (i - 9) % 9;
			int y = (i - 9) / 9;
			ret.put(Pair.of(x, y), true);
			if (getVolume(is) != defaultVolume)
			{
				Pair<Byte, Byte> volume = getVolume(is);
				for (byte b = 0; b < volume.getLeft(); ++b)
				{
					for (byte b1 = 0; b1 < volume.getRight(); ++b1)
					{
						ret.put(Pair.of(x + b, y + b1), true);
					}
				}
			}
		}
	}
	
	return ret;
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:29,代码来源:PlayerInventoryHelper.java

示例14: getCraftingResult

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
@Override
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) {
    ItemStack newOutput = this.output.copy();

    ItemStack cartridge = ItemStack.EMPTY;
    ItemStack portalgun = ItemStack.EMPTY;

    for (int i = 0; i < var1.getSizeInventory(); ++i) {
        ItemStack stack = var1.getStackInSlot(i);

        if (!stack.isEmpty()) {
            if (stack.getItem() instanceof CartridgeItem) {
                cartridge = stack;
            } else if (stack.getItem() instanceof EmptyPortalGunItem) {
                portalgun = stack;
            }
        }
    }

    if (portalgun.hasTagCompound()) {
        newOutput.setTagCompound(portalgun.getTagCompound().copy());
    }
    if (!cartridge.isEmpty()) {
        int charge = CartridgeItem.getCharge(cartridge);
        PortalGunItem.setCharge(newOutput, charge);
    }

    return newOutput;
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:34,代码来源:InsertCartridgeFactory.java

示例15: shuffleItems

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * shuffles items by changing their order and splitting stacks
 */
private void shuffleItems(List<ItemStack> stacks, int p_186463_2_, Random rand)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();
    Iterator<ItemStack> iterator = stacks.iterator();

    while (iterator.hasNext())
    {
        ItemStack itemstack = iterator.next();

        if (itemstack.isEmpty())
        {
            iterator.remove();
        }
        else if (itemstack.getCount() > 1)
        {
            list.add(itemstack);
            iterator.remove();
        }
    }

    p_186463_2_ = p_186463_2_ - stacks.size();

    while (p_186463_2_ > 0 && !list.isEmpty())
    {
        ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
        int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2);
        ItemStack itemstack1 = itemstack2.splitStack(i);

        if (itemstack2.getCount() > 1 && rand.nextBoolean())
        {
            list.add(itemstack2);
        }
        else
        {
            stacks.add(itemstack2);
        }

        if (itemstack1.getCount() > 1 && rand.nextBoolean())
        {
            list.add(itemstack1);
        }
        else
        {
            stacks.add(itemstack1);
        }
    }

    stacks.addAll(list);
    Collections.shuffle(stacks, rand);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:54,代码来源:CustomLootTable.java


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