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


Java Slot.getItemStackLimit方法代码示例

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


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

示例1: updateDragSplitting

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
private void updateDragSplitting()
{
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    if (itemstack != null && this.dragSplitting)
    {
        this.dragSplittingRemnant = itemstack.stackSize;

        for (Slot slot : this.dragSplittingSlots)
        {
            ItemStack itemstack1 = itemstack.copy();
            int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
            Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);

            if (itemstack1.stackSize > itemstack1.getMaxStackSize())
            {
                itemstack1.stackSize = itemstack1.getMaxStackSize();
            }

            if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
            {
                itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
            }

            this.dragSplittingRemnant -= itemstack1.stackSize - i;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:GuiContainer.java

示例2: drawSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
private void drawSlot(Slot slotIn)
{
    int i = slotIn.xDisplayPosition;
    int j = slotIn.yDisplayPosition;
    ItemStack itemstack = slotIn.getStack();
    boolean flag = false;
    boolean flag1 = slotIn == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick;
    ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
    String s = null;

    if (slotIn == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
    {
        itemstack = itemstack.copy();
        itemstack.stackSize /= 2;
    }
    else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null)
    {
        if (this.dragSplittingSlots.size() == 1)
        {
            return;
        }

        if (Container.canAddItemToSlot(slotIn, itemstack1, true) && this.inventorySlots.canDragIntoSlot(slotIn))
        {
            itemstack = itemstack1.copy();
            flag = true;
            Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().stackSize);

            if (itemstack.stackSize > itemstack.getMaxStackSize())
            {
                s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
                itemstack.stackSize = itemstack.getMaxStackSize();
            }

            if (itemstack.stackSize > slotIn.getItemStackLimit(itemstack))
            {
                s = EnumChatFormatting.YELLOW + "" + slotIn.getItemStackLimit(itemstack);
                itemstack.stackSize = slotIn.getItemStackLimit(itemstack);
            }
        }
        else
        {
            this.dragSplittingSlots.remove(slotIn);
            this.updateDragSplitting();
        }
    }

    this.zLevel = 100.0F;
    this.itemRender.zLevel = 100.0F;

    if (itemstack == null)
    {
        String s1 = slotIn.getSlotTexture();

        if (s1 != null)
        {
            TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite(s1);
            GlStateManager.disableLighting();
            this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
            this.drawTexturedModalRect(i, j, textureatlassprite, 16, 16);
            GlStateManager.enableLighting();
            flag1 = true;
        }
    }

    if (!flag1)
    {
        if (flag)
        {
            drawRect(i, j, i + 16, j + 16, -2130706433);
        }

        GlStateManager.enableDepth();
        this.itemRender.renderItemAndEffectIntoGUI(itemstack, i, j);
        this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, itemstack, i, j, s);
    }

    this.itemRender.zLevel = 0.0F;
    this.zLevel = 0.0F;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:81,代码来源:GuiContainer.java


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