當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemStack.isItemEqual方法代碼示例

本文整理匯總了Java中net.minecraft.item.ItemStack.isItemEqual方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemStack.isItemEqual方法的具體用法?Java ItemStack.isItemEqual怎麽用?Java ItemStack.isItemEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.item.ItemStack的用法示例。


在下文中一共展示了ItemStack.isItemEqual方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hasItemStack

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns true if the specified ItemStack exists in the inventory.
 */
public boolean hasItemStack(ItemStack itemStackIn)
{
    for (ItemStack[] aitemstack : this.allInventories)
    {
        for (ItemStack itemstack : aitemstack)
        {
            if (itemstack != null && itemstack.isItemEqual(itemStackIn))
            {
                return true;
            }
        }
    }

    return false;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:InventoryPlayer.java

示例2: setInventorySlotContents

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
 */
public void setInventorySlotContents(int index, @Nullable ItemStack stack)
{
    boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]);
    this.furnaceItemStacks[index] = stack;

    if (stack != null && stack.stackSize > this.getInventoryStackLimit())
    {
        stack.stackSize = this.getInventoryStackLimit();
    }

    if (index == 0 && !flag)
    {
        this.totalCookTime = this.getCookTime(stack);
        this.cookTime = 0;
        this.markDirty();
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:TileEntityFurnace.java

示例3: getRemainingItems

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
    NonNullList<ItemStack> nonnulllist = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

    for (int i = 0; i < nonnulllist.size(); ++i) {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack.isItemEqual(new ItemStack(Items.POTIONITEM))) {
            nonnulllist.set(i, new ItemStack(Items.GLASS_BOTTLE, 1));
            continue;
        }

        nonnulllist.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack));
    }

    return nonnulllist;
}
 
開發者ID:TeamCovertDragon,項目名稱:MooncakeCraft,代碼行數:19,代碼來源:RemainBottleRecipeFactory.java

示例4: setInventorySlotContents

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
 */
public void setInventorySlotContents(int index, ItemStack stack)
{
    boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]);
    this.furnaceItemStacks[index] = stack;

    if (stack != null && stack.stackSize > this.getInventoryStackLimit())
    {
        stack.stackSize = this.getInventoryStackLimit();
    }

    if (index == 0 && !flag)
    {
        this.totalCookTime = this.getCookTime(stack);
        this.cookTime = 0;
        this.markDirty();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:TileEntityFurnace.java

示例5: importFromChamber

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
private void importFromChamber(TileEntityPressureChamberValve core) {
    ItemStackHandler chamberStacks = core.getStacksInChamber();
    for (ItemStack chamberStack : new ItemStackHandlerIterable(chamberStacks)) {
        ItemStack inputStack = inventory.getStackInSlot(0);
        if ((inputStack.isEmpty() || inputStack.isItemEqual(chamberStack)) && filterHandler.doesItemMatchFilter(chamberStack)) {
            int maxAllowedItems = Math.abs(core.getAirHandler(null).getAir()) / PneumaticValues.USAGE_CHAMBER_INTERFACE;
            if (maxAllowedItems > 0) {
                if (!inputStack.isEmpty()) {
                    maxAllowedItems = Math.min(maxAllowedItems, chamberStack.getMaxStackSize() - inputStack.getCount());
                }
                int transferredItems = Math.min(chamberStack.getCount(), maxAllowedItems);
                ItemStack toTransferStack = chamberStack.copy().splitStack(transferredItems);
                ItemStack excess = inventory.insertItem(0, toTransferStack, true);
                if (excess.getCount() < toTransferStack.getCount()) {
                    // we can transfer at least some of the items
                    transferredItems = toTransferStack.getCount() - excess.getCount();
                    core.addAir((core.getAirHandler(null).getAir() > 0 ? -1 : 1) * transferredItems * PneumaticValues.USAGE_CHAMBER_INTERFACE);
                    toTransferStack.setCount(transferredItems);
                    inventory.insertItem(0, toTransferStack, false);
                    chamberStack.shrink(transferredItems);
                }
            }
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:26,代碼來源:TileEntityPressureChamberInterface.java

示例6: setInventorySlotContents

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Sets the given item stack to the specified slot in the inventory (can be
 * crafting or armor sections).
 */
@Override
public void setInventorySlotContents(int index, @Nullable ItemStack stack) {
	boolean flag = !stack.isEmpty() && stack.isItemEqual(this.furnaceItemStacks.get(index))
			&& ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks.get(index));
	this.furnaceItemStacks.set(index, stack);

	if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit())
		stack.setCount( this.getInventoryStackLimit());

	if (index < 9 && !flag) {
		this.totalCookTime = this.getCookTime(stack);
		this.cookTime = 0;
		this.markDirty();
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:20,代碼來源:TileEntityAmmoFurnace.java

示例7: getItemAmount

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public int getItemAmount() {
    List<ItemStack> stacks = new ArrayList<>();
    for (int i = 0; i < input.getSlots(); ++i) {
        if (!input.getStackInSlot(i).isEmpty()) {
            boolean isItNew = true;
            for (ItemStack stack : stacks) {
                if (stack.isItemEqual(input.getStackInSlot(i))) {
                    isItNew = false;
                    break;
                }
            }
            if (isItNew) stacks.add(input.getStackInSlot(i));
        }
    }
    return stacks.size();
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:17,代碼來源:AbstractReactorTile.java

示例8: 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()
{
    if (((ItemStack)this.furnaceItemStacks.get(0)).func_190926_b())
    {
        return false;
    }
    else
    {
        ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult((ItemStack)this.furnaceItemStacks.get(0));

        if (itemstack.func_190926_b())
        {
            return false;
        }
        else
        {
            ItemStack itemstack1 = (ItemStack)this.furnaceItemStacks.get(2);
            return itemstack1.func_190926_b() ? true : (!itemstack1.isItemEqual(itemstack) ? false : (itemstack1.func_190916_E() < this.getInventoryStackLimit() && itemstack1.func_190916_E() < itemstack1.getMaxStackSize() ? true : itemstack1.func_190916_E() < itemstack.getMaxStackSize()));
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:TileEntityFurnace.java

示例9: isSameStackForFuel

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public static boolean isSameStackForFuel(ItemStack fuel, ItemStack stack)
{
    boolean itemEqual = stack.getMetadata() == OreDictionary.WILDCARD_VALUE
                        ? fuel.isItemEqualIgnoreDurability(stack)
                        : fuel.isItemEqual(stack);

    boolean nbtEqual = !stack.hasTagCompound() || ItemStack.areItemStackTagsEqual(stack, fuel);

    return itemEqual && nbtEqual;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:11,代碼來源:ItemHelper.java

示例10: hasItemStack

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns true if the specified ItemStack exists in the inventory.
 */
public boolean hasItemStack(ItemStack itemStackIn)
{
    label19:

    for (List<ItemStack> list : this.allInventories)
    {
        Iterator iterator = list.iterator();

        while (true)
        {
            if (!iterator.hasNext())
            {
                continue label19;
            }

            ItemStack itemstack = (ItemStack)iterator.next();

            if (!itemstack.func_190926_b() && itemstack.isItemEqual(itemStackIn))
            {
                break;
            }
        }

        return true;
    }

    return false;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:32,代碼來源:InventoryPlayer.java

示例11: isValidRecipe

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public boolean isValidRecipe(FluidStack fluidStack, @Nonnull ItemStack inputItem) {
    if (inputLiquid != null) {
        if (fluidStack == null) return false;
        if (!Fluids.areFluidsEqual(fluidStack.getFluid(), inputLiquid.getFluid())) return false;
        if (fluidStack.amount < inputLiquid.amount) return false;
    }
    if (!this.inputItem.isEmpty()) {
        if (inputItem.isEmpty()) return false;
        if (!inputItem.isItemEqual(this.inputItem) && !PneumaticCraftUtils.isSameOreDictStack(inputItem, this.inputItem))
            return false;
        if (inputItem.getCount() < this.inputItem.getCount()) return false;
    }
    return true;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:16,代碼來源:BasicThermopneumaticProcessingPlantRecipe.java

示例12: canItemStacksStack

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public static boolean canItemStacksStack(ItemStack a, ItemStack b)
{
    if (a == null || !a.isItemEqual(b))
        return false;

    return ItemStack.areItemStackTagsEqual(a, b);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:ItemHandlerHelper.java

示例13: smeltItem

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
private void smeltItem(int id)
{
    if (this.canSmelt(id))
    {
        int inputIndex = type.getFirstInputSlot(id);
        int outputIndex = type.getFirstOutputSlot(id);

        ItemStack input = itemHandler.getStackInSlot(inputIndex);
        ItemStack output = itemHandler.getStackInSlot(outputIndex);
        ItemStack result = FurnaceRecipes.instance().getSmeltingResult(input);

        if (output.isEmpty())
        {
            itemHandler.setStackInSlot(outputIndex, result.copy());
        } else if (output.isItemEqual(result))
        {
            output.grow(result.getCount());
        }

        if (input.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && input.getMetadata() == 1)
        {
            fillBucketInFuelSlots();
        }

        input.shrink(1);

        if (input.isEmpty())
        {
            itemHandler.setStackInSlot(inputIndex, ItemStack.EMPTY);
        }
    }
}
 
開發者ID:cubex2,項目名稱:morefurnaces,代碼行數:36,代碼來源:TileEntityIronFurnace.java

示例14: doesItemMatchFilter

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
boolean doesItemMatchFilter(ItemStack itemStack) {
    if (itemStack.isEmpty()) return true;

    switch (filterMode) {
        case ITEM:
            boolean filterEmpty = true;
            for (int i = 0; i < 9; i++) {
                ItemStack filterStack = getStackInSlot(i);
                if (!filterStack.isEmpty()) {
                    filterEmpty = false;
                    if (itemStack.isItemEqual(filterStack)) {
                        return true;
                    }
                }
            }
            return filterEmpty;
        case CREATIVE_TAB:
            try {
                int itemCreativeTabIndex = itemStack.getItem().getCreativeTab() != null ? itemStack.getItem().getCreativeTab().getTabIndex() : -1;
                if (itemCreativeTabIndex == creativeTabID) {
                    return true;
                }
            } catch (Throwable e) {
                //when we are SMP getCreativeTab() is client only.
                filterMode = EnumFilterMode.NAME_BEGINS;
            }
            return false;
        case NAME_BEGINS:
            return itemStack.getDisplayName().toLowerCase().startsWith(itemNameFilter.toLowerCase());
        case NAME_CONTAINS:
            return itemStack.getDisplayName().toLowerCase().contains(itemNameFilter.toLowerCase());
    }
    return false;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:35,代碼來源:TileEntityPressureChamberInterface.java

示例15: setInventorySlotContents

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
	final boolean flag = !stack.isEmpty() && stack.isItemEqual(itemStacks.get(index)) && ItemStack.areItemStackTagsEqual(stack, itemStacks.get(index));
	itemStacks.set(index, stack);

	if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit()) {
		stack.setCount(getInventoryStackLimit());
	}

	if (index == 0 && !flag) {
		this.markDirty();
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:14,代碼來源:TileApiary.java


注:本文中的net.minecraft.item.ItemStack.isItemEqual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。