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


Java ItemStack.areItemStacksEqual方法代码示例

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


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

示例1: detectAndSendChanges

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Looks for changes made in the container, sends them to every listener.
 */
public void detectAndSendChanges()
{
    for (int i = 0; i < this.inventorySlots.size(); ++i)
    {
        ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack();
        ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i);

        if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
        {
            itemstack1 = itemstack == null ? null : itemstack.copy();
            this.inventoryItemStacks.set(i, itemstack1);

            for (int j = 0; j < this.crafters.size(); ++j)
            {
                ((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, itemstack1);
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:Container.java

示例2: detectAndSendChanges

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Looks for changes made in the container, sends them to every listener.
 */
public void detectAndSendChanges()
{
    for (int i = 0; i < this.inventorySlots.size(); ++i)
    {
        ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack();
        ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i);

        if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
        {
            itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack.copy();
            this.inventoryItemStacks.set(i, itemstack1);

            for (int j = 0; j < this.listeners.size(); ++j)
            {
                ((IContainerListener)this.listeners.get(j)).sendSlotContents(this, i, itemstack1);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:Container.java

示例3: equals

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj) 
{
	if(this == obj) return true;
	if(obj instanceof StackRecipeElement)
	{
		return ItemStack.areItemStacksEqual(((StackRecipeElement) obj).stack, this.stack);
	}
	return false;
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:11,代码来源:StackRecipeElement.java

示例4: playerTick

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SubscribeEvent
public void playerTick(TickEvent.PlayerTickEvent event)
{
    if(event.side == Side.CLIENT && event.phase == TickEvent.Phase.END)
    {
        EntityPlayer player = event.player;

        ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
        if(heldItem != currentTool.get(player.getName()) && (heldItem.isEmpty() || (Block.getBlockFromItem(heldItem.getItem()) == Blocks.AIR)))
        {
            if(currentTool.get(player.getName()) != null && (currentTool.get(player.getName()).getItem().isFull3D() || currentTool.get(player.getName()).getItem() instanceof ItemBow) && !BackTools.blacklist.contains(currentTool.get(player.getName()).getItem()))
            {
                ItemStack is = currentTool.get(player.getName()).copy();
                IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(is);
                if(!(model instanceof ModelBaseWrapper))
                {
                    is.setItemDamage(0);
                    ItemStack prevTool = playerTool.get(player.getName());
                    if(prevTool == null || (prevTool.isEmpty() || !ItemStack.areItemStacksEqual(prevTool, is)))
                    {
                        playerTool.put(player.getName(), is);
                    }
                }
            }
            currentTool.put(player.getName(), heldItem);
        }
    }
}
 
开发者ID:iChun,项目名称:BackTools,代码行数:29,代码来源:EventHandlerClient.java

示例5: removeRecipe

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void removeRecipe(RecipeElement input, ItemStack output)
{
    ItemStack result = instance().smeltingList.get(input);
    if(instance().smeltingList.containsKey(input) && ItemStack.areItemStacksEqual(result, output)) return;
    {
	instance().experienceList.remove(result);
	instance().smeltingList.remove(input);
    }
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:10,代码来源:KilnRecipeHandler.java

示例6: getInventoryMatcher

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public Predicate<ItemStack> getInventoryMatcher() {
    return stack -> {
        for (ItemStack s : inventory) {
            if (ItemStack.areItemStacksEqual(s, stack)) {
                return true;
            }
        }
        return false;
    };
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:12,代码来源:EntityMeeCreeps.java

示例7: setStackInSlot

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void setStackInSlot(int slot, @Nonnull ItemStack stack) {
	validateSlotIndex(slot);
	if (ItemStack.areItemStacksEqual(stacks.get(slot), stack)) {
		return;
	}
	stacks.set(slot, stack);
	onContentsChanged(slot);
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:10,代码来源:DankNullItemHandler.java

示例8: areItemStacksEqualForCrafting

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/** An unlimited type of areItemStacksEqual for crafting recipes (non-amount sensitive, cannot be null) */
public static boolean areItemStacksEqualForCrafting(ItemStack... stacks) {
	ItemStack comp = stacks[0];
	if(comp.isEmpty()) return false;
	ItemStack comp1 = comp.copy(); comp1.setCount(1);
	for(int n = 1; n < stacks.length; n++) {
		if(stacks[n].isEmpty()) return false;
		ItemStack comp2 = stacks[n].copy(); comp2.setCount(1);
		if(!ItemStack.areItemStacksEqual(comp1, comp2)) return false;
	}
	return true;
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:13,代码来源:ACUtils.java

示例9: fromSmelting

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static <T extends IRecipeWrapper> Supplied<CraftingControl> fromSmelting(ItemStack input)
{
    return new Supplied<>(() ->
    {
        IRecipeCategory cat = PMJeiPlugin.RUNTIME.getRecipeRegistry().getRecipeCategory(VanillaRecipeCategoryUid.SMELTING);
        List<T> lst = PMJeiPlugin.RUNTIME.getRecipeRegistry().getRecipeWrappers(cat);
        T rec = null;
        try
        {
            IIngredients holder = INGREDIENTS.newInstance();
            recipeLoop:
            for (T wr : lst)
            {
                wr.getIngredients(holder);
                List<List<ItemStack>> inp = holder.getInputs(ItemStack.class);
                if (inp.size() > 0)
                {
                    List<ItemStack> i = inp.get(0);
                    for (ItemStack is : i)
                    {
                        if (ItemStack.areItemStacksEqual(is, input))
                        {
                            rec = wr;
                            break recipeLoop;
                        }
                    }
                }
            }
        }
        catch (InstantiationException | IllegalAccessException e)
        {
            throw new ReportedException(CrashReport.makeCrashReport(e, "Something went wrong when creating furnace recipe renderer"));
        }
        return new CraftingControl(cat, rec, BORDER_VANILLA, BORDER_VANILLA_SIZE);
    });
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:37,代码来源:CraftingControl.java

示例10: shouldCauseReequipAnimation

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
{
    return slotChanged || !ItemStack.areItemStacksEqual(oldStack, newStack);
}
 
开发者ID:iChun,项目名称:Torched,代码行数:6,代码来源:ItemTorchGun.java

示例11: appendItemInShop

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void appendItemInShop ( Account acc, Shop s, int catId, int merchId ) {

	ItemInfo ii = ( ItemInfo ) s . cats [ catId ] . getMerch ( merchId ) ;

	if ( ii . limit < 10 && ItemStack . areItemStacksEqual ( ii . m_stack, acc . manageSession . currentItemStack ) ) {
		
		acc . manageSession . setItemStack ( null ) ;

		ii . limit ++ ;

		s . cats [ catId ] . updateMerch ( merchId, ii ) ;
		
		ModNetworkRegistry . sendToAllAddMerchPacket ( ii ) ;
        
	}
	
}
 
开发者ID:Pishka,项目名称:MineDonate,代码行数:18,代码来源:ModShopManager.java

示例12: shouldCauseReequipAnimation

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
	return !ItemStack.areItemStacksEqual(oldStack, newStack) || slotChanged;
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:5,代码来源:ItemDankNull.java

示例13: processClickWindow

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
 * didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
 * the same open container/inventory
 */
public void processClickWindow(CPacketClickWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    this.playerEntity.markPlayerActive();

    if (this.playerEntity.openContainer.windowId == packetIn.getWindowId() && this.playerEntity.openContainer.getCanCraft(this.playerEntity))
    {
        if (this.playerEntity.isSpectator())
        {
            NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>func_191196_a();

            for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i)
            {
                nonnulllist.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack());
            }

            this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, nonnulllist);
        }
        else
        {
            ItemStack itemstack2 = this.playerEntity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getClickType(), this.playerEntity);

            if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack2))
            {
                this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
                this.playerEntity.isChangingQuantityOnly = true;
                this.playerEntity.openContainer.detectAndSendChanges();
                this.playerEntity.updateHeldItem();
                this.playerEntity.isChangingQuantityOnly = false;
            }
            else
            {
                this.pendingTransactions.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(packetIn.getActionNumber()));
                this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), false));
                this.playerEntity.openContainer.setCanCraft(this.playerEntity, false);
                NonNullList<ItemStack> nonnulllist1 = NonNullList.<ItemStack>func_191196_a();

                for (int j = 0; j < this.playerEntity.openContainer.inventorySlots.size(); ++j)
                {
                    ItemStack itemstack = ((Slot)this.playerEntity.openContainer.inventorySlots.get(j)).getStack();
                    ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack;
                    nonnulllist1.add(itemstack1);
                }

                this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, nonnulllist1);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:55,代码来源:NetHandlerPlayServer.java

示例14: processPlayerBlockPlacement

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Processes block placement and block activation (anvil, furnace, etc.)
 */
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
    boolean flag = false;
    BlockPos blockpos = packetIn.getPosition();
    EnumFacing enumfacing = EnumFacing.getFront(packetIn.getPlacedBlockDirection());
    this.playerEntity.markPlayerActive();

    if (packetIn.getPlacedBlockDirection() == 255)
    {
        if (itemstack == null)
        {
            return;
        }

        this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
    }
    else if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ());
        }

        flag = true;
    }
    else
    {
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
        this.playerEntity.playerNetServerHandler.sendPacket(new S02PacketChat(chatcomponenttranslation));
        flag = true;
    }

    if (flag)
    {
        this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos));
        this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos.offset(enumfacing)));
    }

    itemstack = this.playerEntity.inventory.getCurrentItem();

    if (itemstack != null && itemstack.stackSize == 0)
    {
        this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = null;
        itemstack = null;
    }

    if (itemstack == null || itemstack.getMaxItemUseDuration() == 0)
    {
        this.playerEntity.isChangingQuantityOnly = true;
        this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
        Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
        this.playerEntity.openContainer.detectAndSendChanges();
        this.playerEntity.isChangingQuantityOnly = false;

        if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()))
        {
            this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:68,代码来源:NetHandlerPlayServer.java

示例15: processClickWindow

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
 * didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
 * the same open container/inventory
 */
public void processClickWindow(C0EPacketClickWindow packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
    this.playerEntity.markPlayerActive();

    if (this.playerEntity.openContainer.windowId == packetIn.getWindowId() && this.playerEntity.openContainer.getCanCraft(this.playerEntity))
    {
        if (this.playerEntity.isSpectator())
        {
            List<ItemStack> list = Lists.<ItemStack>newArrayList();

            for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i)
            {
                list.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack());
            }

            this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, list);
        }
        else
        {
            ItemStack itemstack = this.playerEntity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getMode(), this.playerEntity);

            if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack))
            {
                this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
                this.playerEntity.isChangingQuantityOnly = true;
                this.playerEntity.openContainer.detectAndSendChanges();
                this.playerEntity.updateHeldItem();
                this.playerEntity.isChangingQuantityOnly = false;
            }
            else
            {
                this.field_147372_n.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(packetIn.getActionNumber()));
                this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), false));
                this.playerEntity.openContainer.setCanCraft(this.playerEntity, false);
                List<ItemStack> list1 = Lists.<ItemStack>newArrayList();

                for (int j = 0; j < this.playerEntity.openContainer.inventorySlots.size(); ++j)
                {
                    list1.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(j)).getStack());
                }

                this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, list1);
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:53,代码来源:NetHandlerPlayServer.java


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