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


Java Container.computeStackSize方法代碼示例

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


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

示例1: updateDragSplitting

import net.minecraft.inventory.Container; //導入方法依賴的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: updateDragSplitting

import net.minecraft.inventory.Container; //導入方法依賴的package包/類
private void updateDragSplitting()
{
    ItemStack itemstack = this.mc.player.inventory.getItemStack();

    if (!itemstack.func_190926_b() && this.dragSplitting)
    {
        if (this.dragSplittingLimit == 2)
        {
            this.dragSplittingRemnant = itemstack.getMaxStackSize();
        }
        else
        {
            this.dragSplittingRemnant = itemstack.func_190916_E();

            for (Slot slot : this.dragSplittingSlots)
            {
                ItemStack itemstack1 = itemstack.copy();
                ItemStack itemstack2 = slot.getStack();
                int i = itemstack2.func_190926_b() ? 0 : itemstack2.func_190916_E();
                Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
                int j = Math.min(itemstack1.getMaxStackSize(), slot.getItemStackLimit(itemstack1));

                if (itemstack1.func_190916_E() > j)
                {
                    itemstack1.func_190920_e(j);
                }

                this.dragSplittingRemnant -= itemstack1.func_190916_E() - i;
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:33,代碼來源:GuiContainer.java

示例3: drawSlot

import net.minecraft.inventory.Container; //導入方法依賴的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

示例4: drawSlot

import net.minecraft.inventory.Container; //導入方法依賴的package包/類
/**
 * Draws the given slot: any item in it, the slot's background, the hovered highlight, etc.
 */
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.func_190926_b() && !this.isRightMouseClick;
    ItemStack itemstack1 = this.mc.player.inventory.getItemStack();
    String s = null;

    if (slotIn == this.clickedSlot && !this.draggedStack.func_190926_b() && this.isRightMouseClick && !itemstack.func_190926_b())
    {
        itemstack = itemstack.copy();
        itemstack.func_190920_e(itemstack.func_190916_E() / 2);
    }
    else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && !itemstack1.func_190926_b())
    {
        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().func_190926_b() ? 0 : slotIn.getStack().func_190916_E());
            int k = Math.min(itemstack.getMaxStackSize(), slotIn.getItemStackLimit(itemstack));

            if (itemstack.func_190916_E() > k)
            {
                s = TextFormatting.YELLOW.toString() + k;
                itemstack.func_190920_e(k);
            }
        }
        else
        {
            this.dragSplittingSlots.remove(slotIn);
            this.updateDragSplitting();
        }
    }

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

    if (itemstack.func_190926_b() && slotIn.canBeHovered())
    {
        String s1 = slotIn.getSlotTexture();

        if (s1 != null)
        {
            TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite(s1);
            GlStateManager.disableLighting();
            this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            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(this.mc.player, itemstack, i, j);
        this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, itemstack, i, j, s);
    }

    this.itemRender.zLevel = 0.0F;
    this.zLevel = 0.0F;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:79,代碼來源:GuiContainer.java


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