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


Java ItemStack.areItemsEqual方法代码示例

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


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

示例1: matches

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean matches(List<ItemStack> stackList) {
	
	List<ItemStack> inputsMissing = new ArrayList(inputs);
	
	for (int i = 0; i < stackList.size(); i++) {
		ItemStack stack = stackList.get(i);
		if (stack == null)
			break;
		
		int stackIndex = -1;
		
		for (int j = 0; j < inputsMissing.size(); j++) {
			ItemStack input = inputsMissing.get(j);
			
			if (ItemStack.areItemsEqual(input, stack)) {
				stackIndex = j;
				break;
			}
		}
		if (stackIndex >= 0)
			inputsMissing.remove(stackIndex);
		else return false;
	}
	return inputsMissing.isEmpty();
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:26,代码来源:UCrafting.java

示例2: getRecipesForRequestedOutput

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/** Attempt to find all recipes that result in an item of the requested output.
 * @param output the desired item, eg from Types.xsd - "diamond_pickaxe" etc - or as a Minecraft name - eg "tile.woolCarpet.blue"
 * @return a list of IRecipe objects that result in this item.
 */
public static List<IRecipe> getRecipesForRequestedOutput(String output)
{
    List<IRecipe> matchingRecipes = new ArrayList<IRecipe>();
    ItemStack target = MinecraftTypeHelper.getItemStackFromParameterString(output);
    List<?> recipes = CraftingManager.getInstance().getRecipeList();
    for (Object obj : recipes)
    {
        if (obj == null)
            continue;
        if (obj instanceof IRecipe)
        {
            ItemStack is = ((IRecipe)obj).getRecipeOutput();
            if (is == null)
                continue;
            if (ItemStack.areItemsEqual(is, target))
            {
                matchingRecipes.add((IRecipe)obj);
            }
        }
    }
    return matchingRecipes;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:27,代码来源:CraftingHelper.java

示例3: equals

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
protected boolean equals(ItemStackHandler oldValue, ItemStackHandler newValue) {
    if (oldValue.getSlots() != newValue.getSlots()) return false;
    for (int i = 0; i < oldValue.getSlots(); i++) {
        if (!ItemStack.areItemsEqual(oldValue.getStackInSlot(i), newValue.getStackInSlot(i))) {
            return false;
        }
    }
    return true;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:SyncedField.java

示例4: consumeInventoryItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean consumeInventoryItem(InventoryPlayer inv, ItemStack item) {
    for (int i = 0; i < inv.mainInventory.size(); ++i) {
        if (ItemStack.areItemsEqual(inv.mainInventory.get(i), item)) {
            inv.mainInventory.get(i).shrink(1);
            if (inv.mainInventory.get(i).getCount() <= 0) {
                inv.mainInventory.set(i, ItemStack.EMPTY);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:PneumaticCraftUtils.java

示例5: canStackResults

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean canStackResults() {
	if (inv.getStackInSlot(0).isEmpty()) return true;
	ItemStack recipeResult = SpinningThreadRecipe.REGISTRY.getValue(new ResourceLocation(loadedRecipe)).getResult();
	if (ItemStack.areItemsEqual(inv.getStackInSlot(0), recipeResult) && ItemStack.areItemStackTagsEqual(inv.getStackInSlot(0), recipeResult)) {
		int sum = inv.getStackInSlot(0).getCount() + recipeResult.getCount();
		return sum <= recipeResult.getMaxStackSize();
	}
	return false;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:TileEntityThreadSpinner.java

示例6: onTake

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack) {
    CraftiniumRecipe recipe = CraftiniumRecipeRegistry.findMatching(this.craftMatrix, thePlayer.world, this.table, thePlayer);
    if(recipe == null) {
        this.inventory.setInventorySlotContents(0, ItemStack.EMPTY);
        return ItemStack.EMPTY;
    } else {
        this.onCrafting(stack);
        net.minecraftforge.common.ForgeHooks.setCraftingPlayer(thePlayer);
        NonNullList<ItemStack> nonnulllist = recipe.remaining(this.craftMatrix, thePlayer.world, this.table, thePlayer);
        net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

        for (int i = 0; i < nonnulllist.size(); ++i) {
            ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
            ItemStack itemstack1 = nonnulllist.get(i);

            if (!itemstack.isEmpty()) {
                this.craftMatrix.decrStackSize(i, 1);
                itemstack = this.craftMatrix.getStackInSlot(i);
            }

            if (!itemstack1.isEmpty()) {
                if (itemstack.isEmpty()) {
                    this.craftMatrix.setInventorySlotContents(i, itemstack1);
                } else if (ItemStack.areItemsEqual(itemstack, itemstack1) && ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) {
                    itemstack1.grow(itemstack.getCount());
                    this.craftMatrix.setInventorySlotContents(i, itemstack1);
                } else if (!this.player.inventory.addItemStackToInventory(itemstack1)) {
                    this.player.dropItem(itemstack1, false);
                }
            }
        }

        return stack;
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:36,代码来源:CraftiniumSlotCrafting.java

示例7: onTake

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
	if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 9) {
		stack = ItemFromData.getRandomWeapon(playerIn.getRNG(), ItemFromData.VISIBLE_WEAPON);
		//playerIn.addStat(TF2Achievements.HOME_MADE);
		playerIn.inventory.setItemStack(stack);
	} else if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 10) {
		stack = ItemFromData.getRandomWeaponOfClass("cosmetic", playerIn.getRNG(), false);
		playerIn.inventory.setItemStack(stack);
	}
	if(stack.hasTagCompound()&&stack.getTagCompound().getBoolean("Australium")){
		//playerIn.addStat(TF2Achievements.SHINY);
	}
	net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
	this.onCrafting(stack);
	net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
	NonNullList<ItemStack> aitemstack = TF2CraftingManager.INSTANCE.getRemainingItems(this.craftMatrix, playerIn.world);
	net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

	for (int i = 0; i < aitemstack.size(); ++i) {
		ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
		ItemStack itemstack1 = aitemstack.get(i);

		if (!itemstack.isEmpty()) {
			this.craftMatrix.decrStackSize(i, 1);
			itemstack = this.craftMatrix.getStackInSlot(i);
		}

		if (!itemstack1.isEmpty())
			if (itemstack.isEmpty())
				this.craftMatrix.setInventorySlotContents(i, itemstack1);
			else if (ItemStack.areItemsEqual(itemstack, itemstack1)
					&& ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) {
				itemstack1.grow(itemstack.getCount());
				this.craftMatrix.setInventorySlotContents(i, itemstack1);
			} else if (!this.player.inventory.addItemStackToInventory(itemstack1))
				this.player.dropItem(itemstack1, false);
	}
	return stack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:41,代码来源:SlotCraftingTF2.java

示例8: matches

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

	int potionEffects = 0;
	for (int i = 0; i < inv.getSizeInventory(); i++)
	{
		ItemStack stack = inv.getStackInSlot(i);
		if (!stack.isEmpty())
		{

			Item item = stack.getItem();
			if (item != Items.TIPPED_ARROW && item != Items.POTIONITEM && item != Items.SPLASH_POTION && item != Items.LINGERING_POTION) return false;

			if (tempStack.isEmpty())
			{
				tempStack = stack.copy();
			}
			else
			{
				if (!ItemStack.areItemsEqual(tempStack, stack)) return false;
			}

			if (ModConfiguration.maxPotionEffects >= 0)
			{
				potionEffects += PotionUtils.getEffectsFromStack(stack).size();
				if (potionEffects > ModConfiguration.maxPotionEffects) return false;
			}
		}
	}

	return true;
}
 
开发者ID:crazysnailboy,项目名称:CombinedPotions,代码行数:35,代码来源:RecipeCombinedPotions.java

示例9: registerRecipe

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static DefierRecipe registerRecipe(String mod_id, DefierRecipe recipe){
	for(DefierRecipe rec : REGISTRY.keySet()){
		if(ItemStack.areItemsEqual(rec.outputItem(), recipe.outputItem())){
			Defier.logger.info("Mod " + mod_id + " is overritting a defier recipe for " + recipe.getItem().getUnlocalizedName() + " from " + REGISTRY.get(rec));
			REGISTRY.remove(rec);
			break;
		}
	}
	if(recipe.rfcost > 0){
		REGISTRY.put(recipe, mod_id);
	}
	return recipe;
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:14,代码来源:DefierRecipeRegistry.java

示例10: onPickupFromSlot

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
    this.onCrafting(stack);
    net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
    ItemStack[] aitemstack = CraftingManager.getInstance().getRemainingItems(this.craftMatrix, playerIn.worldObj);
    net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
        ItemStack itemstack1 = aitemstack[i];

        if (itemstack != null)
        {
            this.craftMatrix.decrStackSize(i, 1);
            itemstack = this.craftMatrix.getStackInSlot(i);
        }

        if (itemstack1 != null)
        {
            if (itemstack == null)
            {
                this.craftMatrix.setInventorySlotContents(i, itemstack1);
            }
            else if (ItemStack.areItemsEqual(itemstack, itemstack1) && ItemStack.areItemStackTagsEqual(itemstack, itemstack1))
            {
                itemstack1.stackSize += itemstack.stackSize;
                this.craftMatrix.setInventorySlotContents(i, itemstack1);
            }
            else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack1))
            {
                this.thePlayer.dropItem(itemstack1, false);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:38,代码来源:SlotCrafting.java

示例11: itemStackIngredientsMatch

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/** Compare two ItemStacks and see if their items match - take wildcards into account, don't take stacksize into account.
 * @param A ItemStack A
 * @param B ItemStack B
 * @return true if the stacks contain matching items.
 */
private static boolean itemStackIngredientsMatch(ItemStack A, ItemStack B)
{
    if (A == null && B == null)
        return true;
    if (A == null || B == null)
        return false;
    if (A.getMetadata() == OreDictionary.WILDCARD_VALUE || B.getMetadata() == OreDictionary.WILDCARD_VALUE)
        return A.getItem() == B.getItem();
    return ItemStack.areItemsEqual(A, B);
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:16,代码来源:CraftingHelper.java

示例12: matchStacks

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static boolean matchStacks(ItemStack stack1, ItemStack stack2, boolean fuzzyMeta) {
    return fuzzyMeta ? ItemStack.areItemsEqualIgnoreDurability(stack1, stack2) : ItemStack.areItemsEqual(stack1, stack2);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:4,代码来源:IOHelper.java

示例13: addItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Nullable
public ItemStack addItem(ItemStack stack)
{
    ItemStack itemstack = stack.copy();

    for (int i = 0; i < this.slotsCount; ++i)
    {
        ItemStack itemstack1 = this.getStackInSlot(i);

        if (itemstack1 == null)
        {
            this.setInventorySlotContents(i, itemstack);
            this.markDirty();
            return null;
        }

        if (ItemStack.areItemsEqual(itemstack1, itemstack))
        {
            int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize());
            int k = Math.min(itemstack.stackSize, j - itemstack1.stackSize);

            if (k > 0)
            {
                itemstack1.stackSize += k;
                itemstack.stackSize -= k;

                if (itemstack.stackSize <= 0)
                {
                    this.markDirty();
                    return null;
                }
            }
        }
    }

    if (itemstack.stackSize != stack.stackSize)
    {
        this.markDirty();
    }

    return itemstack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:43,代码来源:InventoryBasic.java

示例14: addItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack addItem(ItemStack stack)
{
    ItemStack itemstack = stack.copy();

    for (int i = 0; i < this.slotsCount; ++i)
    {
        ItemStack itemstack1 = this.getStackInSlot(i);

        if (itemstack1.func_190926_b())
        {
            this.setInventorySlotContents(i, itemstack);
            this.markDirty();
            return ItemStack.field_190927_a;
        }

        if (ItemStack.areItemsEqual(itemstack1, itemstack))
        {
            int j = Math.min(this.getInventoryStackLimit(), itemstack1.getMaxStackSize());
            int k = Math.min(itemstack.func_190916_E(), j - itemstack1.func_190916_E());

            if (k > 0)
            {
                itemstack1.func_190917_f(k);
                itemstack.func_190918_g(k);

                if (itemstack.func_190926_b())
                {
                    this.markDirty();
                    return ItemStack.field_190927_a;
                }
            }
        }
    }

    if (itemstack.func_190916_E() != stack.func_190916_E())
    {
        this.markDirty();
    }

    return itemstack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:42,代码来源:InventoryBasic.java

示例15: func_181078_a

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean func_181078_a(ItemStack p_181078_1_, ItemStack p_181078_2_)
{
    return ItemStack.areItemsEqual(p_181078_1_, p_181078_2_) && (!p_181078_2_.hasTagCompound() || p_181078_1_.hasTagCompound() && NBTUtil.func_181123_a(p_181078_2_.getTagCompound(), p_181078_1_.getTagCompound(), false));
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:MerchantRecipeList.java


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