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


Java ItemStack.getMaxStackSize方法代碼示例

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


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

示例1: giveItemToPlayer

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * This function will first try to set the item at the 'heldItem' position if possible.
 * Otherwise it will try to find a suitable place elsewhere. If that fails it will spawn
 * the item in the world. The stack parameter may be modified
 */
public static void giveItemToPlayer(EntityPlayer player, ItemStack stack) {
    ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
    if (ItemStackTools.isEmpty(heldItem)) {
        player.setHeldItem(EnumHand.MAIN_HAND, stack);
        player.openContainer.detectAndSendChanges();
        return;
    } else if (isItemStackConsideredEqual(heldItem, stack)) {
        if (ItemStackTools.getStackSize(heldItem) < heldItem.getMaxStackSize()) {
            int itemsToAdd = Math.min(ItemStackTools.getStackSize(stack), heldItem.getMaxStackSize() - ItemStackTools.getStackSize(heldItem));
            ItemStackTools.incStackSize(heldItem, itemsToAdd);
            ItemStackTools.incStackSize(stack, -itemsToAdd);
            if (ItemStackTools.isEmpty(stack)) {
                player.openContainer.detectAndSendChanges();
                return;
            }
        }
    }
    // We have items remaining. Add them elsewhere
    if (player.inventory.addItemStackToInventory(stack)) {
        player.openContainer.detectAndSendChanges();
        return;
    }
    // Spawn in world
    spawnItemStack(player.getEntityWorld(), player.getPosition(), stack);
}
 
開發者ID:McJty,項目名稱:interactionwheel,代碼行數:31,代碼來源:InventoryHelper.java

示例2: getOutput

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns the output ItemStack obtained by brewing the passed input and
 * ingredient. Null if no matches are found.
 */
public static ItemStack getOutput(ItemStack input, ItemStack ingredient)
{
    if (input == null || input.getMaxStackSize() != 1 || input.stackSize != 1) return null;
    if (ingredient == null || ingredient.stackSize <= 0) return null;

    for (IBrewingRecipe recipe : recipes)
    {
        ItemStack output = recipe.getOutput(input, ingredient);
        if (output != null)
        {
            return output;
        }
    }
    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:20,代碼來源:BrewingRecipeRegistry.java

示例3: canSmelt

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
 */
private boolean canSmelt()
{
    if (((ItemStack)this.furnaceItemStacks.get(0)).func_190926_b())
    {
        return false;
    }
    else
    {
        ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult((ItemStack)this.furnaceItemStacks.get(0));

        if (itemstack.func_190926_b())
        {
            return false;
        }
        else
        {
            ItemStack itemstack1 = (ItemStack)this.furnaceItemStacks.get(2);
            return itemstack1.func_190926_b() ? true : (!itemstack1.isItemEqual(itemstack) ? false : (itemstack1.func_190916_E() < this.getInventoryStackLimit() && itemstack1.func_190916_E() < itemstack1.getMaxStackSize() ? true : itemstack1.func_190916_E() < itemstack.getMaxStackSize()));
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:TileEntityFurnace.java

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

示例5: isInventoryFull

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns false if the inventory has any room to place items in
 */
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int k = 0; k < aint.length; ++k)
        {
            ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[k]);

            if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize())
            {
                return false;
            }
        }
    }
    else
    {
        int i = inventoryIn.getSizeInventory();

        for (int j = 0; j < i; ++j)
        {
            ItemStack itemstack = inventoryIn.getStackInSlot(j);

            if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
            {
                return false;
            }
        }
    }

    return true;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:38,代碼來源:TileEntityHopper.java

示例6: isFull

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
private boolean isFull()
{
    for (ItemStack itemstack : this.inventory)
    {
        if (itemstack.func_190926_b() || itemstack.func_190916_E() != itemstack.getMaxStackSize())
        {
            return false;
        }
    }

    return true;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:TileEntityHopper.java

示例7: updateDragSplitting

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

示例8: canSmelt

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
 */
private boolean canSmelt()
{
    if (this.furnaceItemStacks[0] == null)
    {
        return false;
    }
    else
    {
        ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
        return itemstack == null ? false : (this.furnaceItemStacks[2] == null ? true : (!this.furnaceItemStacks[2].isItemEqual(itemstack) ? false : (this.furnaceItemStacks[2].stackSize < this.getInventoryStackLimit() && this.furnaceItemStacks[2].stackSize < this.furnaceItemStacks[2].getMaxStackSize() ? true : this.furnaceItemStacks[2].stackSize < itemstack.getMaxStackSize())));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:16,代碼來源:TileEntityFurnace.java

示例9: isFull

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
private boolean isFull()
{
    for (ItemStack itemstack : this.inventory)
    {
        if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
        {
            return false;
        }
    }

    return true;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:TileEntityHopper.java

示例10: hasRoom

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
@Override
public boolean hasRoom(Predicate<ItemStack> matcher) {
    for (ItemStack stack : inventory) {
        if (stack.isEmpty()) {
            return true;
        }
        if (!stack.isEmpty() && matcher.test(stack)) {
            if (stack.getCount() < stack.getMaxStackSize()) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:15,代碼來源:EntityMeeCreeps.java

示例11: isInventoryFull

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns false if the inventory has any room to place items in
 */
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int k : aint)
        {
            ItemStack itemstack1 = isidedinventory.getStackInSlot(k);

            if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize())
            {
                return false;
            }
        }
    }
    else
    {
        int i = inventoryIn.getSizeInventory();

        for (int j = 0; j < i; ++j)
        {
            ItemStack itemstack = inventoryIn.getStackInSlot(j);

            if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
            {
                return false;
            }
        }
    }

    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:38,代碼來源:TileEntityHopper.java

示例12: isInventoryFull

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * Returns false if the inventory has any room to place items in
 */
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int k : aint)
        {
            ItemStack itemstack1 = isidedinventory.getStackInSlot(k);

            if (itemstack1.func_190926_b() || itemstack1.func_190916_E() != itemstack1.getMaxStackSize())
            {
                return false;
            }
        }
    }
    else
    {
        int i = inventoryIn.getSizeInventory();

        for (int j = 0; j < i; ++j)
        {
            ItemStack itemstack = inventoryIn.getStackInSlot(j);

            if (itemstack.func_190926_b() || itemstack.func_190916_E() != itemstack.getMaxStackSize())
            {
                return false;
            }
        }
    }

    return true;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:38,代碼來源:TileEntityHopper.java

示例13: storePartialItemStack

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
/**
 * This function stores as many items of an ItemStack as possible in a matching slot and returns the quantity of
 * left over items.
 */
private int storePartialItemStack(ItemStack itemStackIn)
{
    Item item = itemStackIn.getItem();
    int i = itemStackIn.stackSize;
    int j = this.storeItemStack(itemStackIn);

    if (j == -1)
    {
        j = this.getFirstEmptyStack();
    }

    if (j == -1)
    {
        return i;
    }
    else
    {
        ItemStack itemstack = this.getStackInSlot(j);

        if (itemstack == null)
        {
            itemstack = itemStackIn.copy(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up.
            itemstack.stackSize = 0;

            if (itemStackIn.hasTagCompound())
            {
                itemstack.setTagCompound(itemStackIn.getTagCompound().copy());
            }

            this.setInventorySlotContents(j, itemstack);
        }

        int k = i;

        if (i > itemstack.getMaxStackSize() - itemstack.stackSize)
        {
            k = itemstack.getMaxStackSize() - itemstack.stackSize;
        }

        if (k > this.getInventoryStackLimit() - itemstack.stackSize)
        {
            k = this.getInventoryStackLimit() - itemstack.stackSize;
        }

        if (k == 0)
        {
            return i;
        }
        else
        {
            i = i - k;
            itemstack.stackSize += k;
            itemstack.animationsToGo = 5;
            return i;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:62,代碼來源:InventoryPlayer.java

示例14: getStackLimit

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
protected int getStackLimit(int slot, ItemStack stack) {
    return stack.getMaxStackSize();
}
 
開發者ID:jaredlll08,項目名稱:Machines-and-Stuff,代碼行數:4,代碼來源:ItemStackHandlerAdvanced.java

示例15: canCombine

import net.minecraft.item.ItemStack; //導入方法依賴的package包/類
private static boolean canCombine(ItemStack stack1, ItemStack stack2)
{
    return stack1.getItem() != stack2.getItem() ? false : (stack1.getMetadata() != stack2.getMetadata() ? false : (stack1.func_190916_E() > stack1.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(stack1, stack2)));
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:TileEntityHopper.java


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