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


Java ItemStack.areItemStackTagsEqual方法代碼示例

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


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

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

示例2: canItemStacksStackRelaxed

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * A relaxed version of canItemStacksStack that stacks itemstacks with different metadata if they don't have subtypes.
 * This usually only applies when players pick up items.
 */
public static boolean canItemStacksStackRelaxed(ItemStack a, ItemStack b)
{
    if (a == null || b == null || a.getItem() != b.getItem())
        return false;

    if (!a.isStackable())
        return false;

    // Metadata value only matters when the item has subtypes
    // Vanilla stacks non-subtype items with different metadata together
    // e.g. a stick with metadata 0 and a stick with metadata 1 stack
    if (a.getHasSubtypes() && a.getMetadata() != b.getMetadata())
        return false;

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

示例3: 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:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:TileEntityFurnace.java

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

示例5: equals

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public boolean equals(Object o)
{
    if (!(o instanceof ContainerKey)) return false;
    ContainerKey ck = (ContainerKey)o;
    if (container.getItem() != ck.container.getItem()) return false;
    if (container.getItemDamage() != ck.container.getItemDamage()) return false;
    if (!ItemStack.areItemStackTagsEqual(container, ck.container)) return false;
    if (fluid == null && ck.fluid != null) return false;
    if (fluid != null && ck.fluid == null) return false;
    if (fluid == null && ck.fluid == null) return true;
    if (fluid.getFluid() != ck.fluid.getFluid()) return false;
    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:15,代碼來源:FluidContainerRegistry.java

示例6: canAddItemToSlot

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Checks if it's possible to add the given itemstack to the given slot.
 */
public static boolean canAddItemToSlot(Slot slotIn, ItemStack stack, boolean stackSizeMatters)
{
    boolean flag = slotIn == null || !slotIn.getHasStack();

    if (slotIn != null && slotIn.getHasStack() && stack != null && stack.isItemEqual(slotIn.getStack()) && ItemStack.areItemStackTagsEqual(slotIn.getStack(), stack))
    {
        flag |= slotIn.getStack().stackSize + (stackSizeMatters ? 0 : stack.stackSize) <= stack.getMaxStackSize();
    }

    return flag;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:Container.java

示例7: storeItemStack

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * stores an itemstack in the users inventory
 */
private int storeItemStack(ItemStack itemStackIn)
{
    for (int i = 0; i < this.mainInventory.length; ++i)
    {
        if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].stackSize < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getMetadata() == itemStackIn.getMetadata()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemStackIn))
        {
            return i;
        }
    }

    return -1;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:16,代碼來源:InventoryPlayer.java

示例8: setInventorySlotContents

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

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

    if (index == SLOT_PRIMARY && !stackEqual) {
        totalCookTime = getCookTime(stack);
        cookTime = 0;
        markDirty();
    }
}
 
開發者ID:jaquadro,項目名稱:GardenStuff,代碼行數:15,代碼來源:TileBloomeryFurnace.java

示例9: isHittingPosition

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
private boolean isHittingPosition(BlockPos pos)
{
    ItemStack itemstack = this.mc.player.getHeldItemMainhand();
    boolean flag = this.currentItemHittingBlock.func_190926_b() && itemstack.func_190926_b();

    if (!this.currentItemHittingBlock.func_190926_b() && !itemstack.func_190926_b())
    {
        flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
    }

    return pos.equals(this.currentBlock) && flag;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:PlayerControllerMP.java

示例10: combineSlots

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
static void combineSlots(EntityPlayerMP player, int dst, int add)
{
    InventoryPlayer inv = player.inventory;
    ItemStack dstStack = inv.getStackInSlot(dst);
    ItemStack addStack = inv.getStackInSlot(add);

    if (addStack == null)
        return;    // Combination is a no-op.

    if (dstStack == null)   // Do a straight move - nothing to combine with.
    {
        inv.setInventorySlotContents(dst, addStack);
        inv.setInventorySlotContents(add, null);
        return;
    }

    // Check we can combine. This logic comes from InventoryPlayer.storeItemStack():
    boolean itemsMatch = dstStack.getItem() == addStack.getItem();
    boolean dstCanStack = dstStack.isStackable() && dstStack.stackSize < dstStack.getMaxStackSize() && dstStack.stackSize < inv.getInventoryStackLimit();
    boolean subTypesMatch = !dstStack.getHasSubtypes() || dstStack.getMetadata() == addStack.getMetadata();
    boolean tagsMatch = ItemStack.areItemStackTagsEqual(dstStack, addStack);
    if (itemsMatch && dstCanStack && subTypesMatch && tagsMatch)
    {
        // We can combine, so figure out how much we have room for:
        int limit = Math.min(dstStack.getMaxStackSize(), inv.getInventoryStackLimit());
        int room = limit - dstStack.stackSize;
        if (addStack.stackSize > room)
        {
            // Not room for all of it, so shift across as much as possible.
            addStack.stackSize -= room;
            dstStack.stackSize += room;
        }
        else
        {
            // Room for the whole lot, so empty out the add slot.
            dstStack.stackSize += addStack.stackSize;
            inv.setInventorySlotContents(add, null);
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:41,代碼來源:InventoryCommandsImplementation.java

示例11: updateTick

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * The update tick for the ingame UI
 */
public void updateTick()
{
    if (this.recordPlayingUpFor > 0)
    {
        --this.recordPlayingUpFor;
    }

    if (this.titlesTimer > 0)
    {
        --this.titlesTimer;

        if (this.titlesTimer <= 0)
        {
            this.displayedTitle = "";
            this.displayedSubTitle = "";
        }
    }

    ++this.updateCounter;

    if (this.mc.player != null)
    {
        ItemStack itemstack = this.mc.player.inventory.getCurrentItem();

        if (itemstack.func_190926_b())
        {
            this.remainingHighlightTicks = 0;
        }
        else if (!this.highlightingItemStack.func_190926_b() && itemstack.getItem() == this.highlightingItemStack.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.highlightingItemStack) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.highlightingItemStack.getMetadata()))
        {
            if (this.remainingHighlightTicks > 0)
            {
                --this.remainingHighlightTicks;
            }
        }
        else
        {
            this.remainingHighlightTicks = 40;
        }

        this.highlightingItemStack = itemstack;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:47,代碼來源:GuiIngame.java

示例12: areMergeCandidates

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
boolean areMergeCandidates(ItemStack source, ItemStack target) {
	return source.isItemEqual(target) && ItemStack.areItemStackTagsEqual(source, target) && target.getCount() < target.getMaxStackSize();
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:4,代碼來源:EntityFrienderman.java

示例13: isItemStackConsideredEqual

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
public static boolean isItemStackConsideredEqual(ItemStack result, ItemStack itemstack1) {
    return ItemStackTools.isValid(itemstack1) && itemstack1.getItem() == result.getItem() && (!result.getHasSubtypes() || result.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(result, itemstack1);
}
 
開發者ID:McJty,項目名稱:interactionwheel,代碼行數:4,代碼來源:InventoryHelper.java

示例14: findFirstAvailableSlotFor

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@SuppressWarnings("SuspiciousNameCombination")
   public static int findFirstAvailableSlotFor(ItemStack is, Optional<Map<Pair<Integer, Integer>, Boolean>> data, EntityPlayer player)
{
	InventoryPlayer inventory = player.inventory;
	for (int i = 0; i < inventory.getSizeInventory(); ++i)
	{
		ItemStack stack = player.inventory.getStackInSlot(i);
		if (ItemStack.areItemsEqual(stack, is) && ItemStack.areItemStackTagsEqual(stack, is))
		{
			int max = Math.min(player.openContainer != null ? player.openContainer.getSlot(i).getItemStackLimit(stack) : inventory.getInventoryStackLimit(), stack.getMaxStackSize());
			if (stack.getCount() < max)
			{
				return Short.MAX_VALUE + i;
			}
		}
	}
	
	for (int i = 0; i < 9; ++i)
	{
		if (inventory.getStackInSlot(i).isEmpty())
		{
			return i;
		}
	}
	
	Map<Pair<Integer, Integer>, Boolean> lookup = data.orElseGet(() -> PlayerInventoryHelper.getSlotData(player));
	Pair<Byte, Byte> volume = getVolume(is);
	slotLoop: for (int i = 9; i < 36; ++i)
	{
		int x = (i - 9) % 9;
		int y = (i - 9) / 9;
		if (x + volume.getLeft() > 9 || y + volume.getRight() > 3)
		{
			continue;
		}
		
		Pair<Integer, Integer> pos = Pair.of(x, y);
		if (lookup.containsKey(pos) && lookup.get(pos))
		{
			continue;
		}
		
		for (int dx = x; dx < x + volume.getLeft(); ++dx)
		{
			for (int dy = y; dy < y + volume.getRight(); ++dy)
			{
				pos = Pair.of(dx, dy);
				if (dx >= 9 || dy >= 3 || (lookup.containsKey(pos) && lookup.get(pos)))
				{
				    continue slotLoop;
				}
			}
		}
		
		return i;
	}
	
	return -1;
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:60,代碼來源:PlayerInventoryHelper.java

示例15: updateTick

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * The update tick for the ingame UI
 */
public void updateTick()
{
    if (this.recordPlayingUpFor > 0)
    {
        --this.recordPlayingUpFor;
    }

    if (this.field_175195_w > 0)
    {
        --this.field_175195_w;

        if (this.field_175195_w <= 0)
        {
            this.field_175201_x = "";
            this.field_175200_y = "";
        }
    }

    ++this.updateCounter;
    this.streamIndicator.func_152439_a();

    if (this.mc.thePlayer != null)
    {
        ItemStack itemstack = this.mc.thePlayer.inventory.getCurrentItem();

        if (itemstack == null)
        {
            this.remainingHighlightTicks = 0;
        }
        else if (this.highlightingItemStack != null && itemstack.getItem() == this.highlightingItemStack.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.highlightingItemStack) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.highlightingItemStack.getMetadata()))
        {
            if (this.remainingHighlightTicks > 0)
            {
                --this.remainingHighlightTicks;
            }
        }
        else
        {
            this.remainingHighlightTicks = 40;
        }

        this.highlightingItemStack = itemstack;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:48,代碼來源:GuiIngame.java


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