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


Java IInventory.getSizeInventory方法代碼示例

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


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

示例1: getItemBlockWithInventory

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
public ItemStack getItemBlockWithInventory(IInventory inventory, ItemStack stack) {
	if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock && inventory != null && inventory.getSizeInventory() > 0) {
		if (!stack.hasTagCompound()) {
			stack.setTagCompound(new NBTTagCompound());
		}
		NBTTagCompound stackNBT = stack.getOrCreateSubCompound("BlockEntityTag");
		NBTTagList stackList = new NBTTagList();
		for (int i = 0; i < inventory.getSizeInventory(); i++) {
			if (inventory.getStackInSlot(i).isEmpty()) {
				continue;
			}
			NBTTagCompound slotNBT = new NBTTagCompound();
			slotNBT.setByte("Slot", (byte) i);
			inventory.getStackInSlot(i).writeToNBT(slotNBT);
			stackList.appendTag(slotNBT);
		}
		stackNBT.setTag("Items", stackList);
		stack.setTagInfo("BlockEntityTag", stackNBT);
		return stack;
	}
	return null;
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:23,代碼來源:EntityFrienderman.java

示例2: load

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
/**
 * Load inventory data from NBT tag
 * @param inventory Target inventory
 * @param tag tag to load
 * @param seed Loading seed
 */
private static void load(IInventory inventory, NBTTagCompound tag, long seed) {
    if (tag == null || !Configurator.NATIVE_LOOT) {
        return;
    }
    Random random = new Random(seed);
    NBTTagList items = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < items.tagCount() && i < inventory.getSizeInventory(); ++i) {
        NBTTagCompound stackTag = items.getCompoundTagAt(i);
        String itemName = stackTag.getString("id").replaceAll(".*:", "");
        itemName = itemName.isEmpty() ? String.valueOf(stackTag.getShort("id")) : itemName;
        Pattern iPattern = Pattern.compile(Pattern.quote(itemName), Pattern.CASE_INSENSITIVE);
        UItem item = Utils.select(UItems.items.select(iPattern), random.nextLong());
        byte count = items.getCompoundTagAt(i).getByte("Count");
        int damage = items.getCompoundTagAt(i).getShort("Damage");
        int slot = stackTag.hasKey("Slot", Constants.NBT.TAG_BYTE) ? stackTag.getByte("Slot") : i;
        slot = (slot < 0 || slot >= inventory.getSizeInventory()) ? i : slot;
        if (item != null && count > 0 && UItems.getPossibleMeta(item).contains(damage)) {
            inventory.setInventorySlotContents(slot, new UItemStack(item, count, damage).getItemStack());
        }
    }
}
 
開發者ID:ternsip,項目名稱:StructPro,代碼行數:28,代碼來源:Tiles.java

示例3: moveItemsIntoStack

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
private static void moveItemsIntoStack(IInventory chest, ItemStack stack)
{
    if (stack.getTagCompound() == null)
    {
        stack.setTagCompound(new NBTTagCompound());
    }
    NBTTagList nbtList = new NBTTagList();

    for (int i = 0; i < chest.getSizeInventory(); ++i)
    {
        if (!chest.getStackInSlot(i).isEmpty())
        {
            NBTTagCompound nbtTabCompound2 = new NBTTagCompound();
            nbtTabCompound2.setShort("Slot", (short) i);
            chest.getStackInSlot(i).copy().writeToNBT(nbtTabCompound2);
            chest.setInventorySlotContents(i, ItemStack.EMPTY);
            nbtList.appendTag(nbtTabCompound2);
        }
    }
    stack.getTagCompound().setTag("Items", nbtList);
}
 
開發者ID:cubex2,項目名稱:chesttransporter,代碼行數:22,代碼來源:ItemChestTransporter.java

示例4: hasPaymentOrderInMatrix

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
private boolean hasPaymentOrderInMatrix(IInventory matrix)
{
	int counter = 0;

	while (counter < matrix.getSizeInventory())
	{
		if (matrix.getStackInSlot(counter) != null && matrix.getStackInSlot(counter).getItem() instanceof PaymentOrder)
		{
			return true;	// Found it
		}

		counter += 1;
	}

	return false;
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:17,代碼來源:Recipe_LeaderRequired.java

示例5: getSlotToPushTo

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
protected int getSlotToPushTo(IInventory inventory) {
	int slot = 0;
	for(; slot < inventory.getSizeInventory(); ++slot) {
		if(debug) {
			FMLLog.log(Level.INFO, "E " + (inventory.getStackInSlot(slot) != null));
			if(inventory.getStackInSlot(slot) != null) {
				FMLLog.log(Level.INFO, "E " + slot + " " + inventory.getStackInSlot(slot).toString());
				FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot) == null));
				FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem()));
				FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot).getItemDamage() == blockItemStack.getItemDamage()));
				FMLLog.log(Level.INFO, "E-true " + inventory.getStackInSlot(slot).stackSize + " < " + inventory.getStackInSlot(slot).getItem().getItemStackLimit(inventory.getStackInSlot(slot)));
			}
		}
		if(inventory.getStackInSlot(slot) == null || inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem() && inventory.getStackInSlot(slot).getItemDamage() == blockItemStack.getItemDamage()
				&& inventory.getStackInSlot(slot).stackSize < inventory.getStackInSlot(slot).getItem().getItemStackLimit(inventory.getStackInSlot(slot)))
			break;
	}

	if(slot > inventory.getSizeInventory() - 1)
		slot = inventory.getSizeInventory() - 1;

	if(debug)
		FMLLog.log(Level.INFO, "E" + slot);

	return slot;
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:27,代碼來源:TileEntityGrabber.java

示例6: handleItem

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
private static void handleItem(EntityPlayer entityPlayer, IInventory inventory, Item[] items)
{
	for (int index = 0; index < inventory.getSizeInventory(); index++)
	{
		if (inventory.getStackInSlot(index) == null)
			continue;
		
		for (int itemIndex = 0; itemIndex < items.length; itemIndex++)
		{
			damageItem(entityPlayer, inventory, index, items[itemIndex]);
		}
	}
}
 
開發者ID:Wahazar,項目名稱:TFCPrimitiveTech,代碼行數:14,代碼來源:CraftingHandler.java

示例7: countSlotsNotEmpty

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
private static int countSlotsNotEmpty(IInventory inventory)
{
	int result = 0;
	for (int i = 0; i < inventory.getSizeInventory(); i++)
	{
		if (!inventory.getStackInSlot(i).isEmpty()) result++;
	}
	return result;
}
 
開發者ID:crazysnailboy,項目名稱:CombinedPotions,代碼行數:10,代碼來源:RecipeCombinedPotions.java

示例8: matches

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
@Override
public boolean matches(IInventory inv) {
	if (inv.getSizeInventory()<9) return false;
	for(int i=0; i<9; i++) {
		if (ingredients[i]==null) {
			if (!inv.getStackInSlot(i).isEmpty()) return false;
		} else {
			if (!OreItems.matches(ingredients[i], inv.getStackInSlot(i))) return false;
		}
	}
	return true;
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:13,代碼來源:RotaryGridRecipe.java

示例9: isInventoryEmpty

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
/**
 * Returns false if the specified IInventory contains any items
 */
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int i = 0; i < aint.length; ++i)
        {
            if (isidedinventory.getStackInSlot(aint[i]) != null)
            {
                return false;
            }
        }
    }
    else
    {
        int j = inventoryIn.getSizeInventory();

        for (int k = 0; k < j; ++k)
        {
            if (inventoryIn.getStackInSlot(k) != null)
            {
                return false;
            }
        }
    }

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

示例10: putStackInInventoryAllSlots

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
/**
 * Attempts to place the passed stack in the inventory, using as many slots as required. Returns leftover items
 */
public static ItemStack putStackInInventoryAllSlots(IInventory inventoryIn, ItemStack stack, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory && side != null)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int k = 0; k < aint.length && stack != null && stack.stackSize > 0; ++k)
        {
            stack = insertStack(inventoryIn, stack, aint[k], side);
        }
    }
    else
    {
        int i = inventoryIn.getSizeInventory();

        for (int j = 0; j < i && stack != null && stack.stackSize > 0; ++j)
        {
            stack = insertStack(inventoryIn, stack, j, side);
        }
    }

    if (stack != null && stack.stackSize == 0)
    {
        stack = null;
    }

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

示例11: GuiChest

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
public GuiChest(IInventory upperInv, IInventory lowerInv)
{
    super(new ContainerChest(upperInv, lowerInv, Minecraft.getMinecraft().thePlayer));
    this.upperChestInventory = upperInv;
    this.lowerChestInventory = lowerInv;
    this.allowUserInput = false;
    int i = 222;
    int j = i - 108;
    this.inventoryRows = lowerInv.getSizeInventory() / 9;
    this.ySize = j + this.inventoryRows * 18;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:12,代碼來源:GuiChest.java

示例12: isInventoryEmpty

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
/**
 * Returns false if the specified IInventory contains any items
 */
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int i : aint)
        {
            if (!isidedinventory.getStackInSlot(i).func_190926_b())
            {
                return false;
            }
        }
    }
    else
    {
        int j = inventoryIn.getSizeInventory();

        for (int k = 0; k < j; ++k)
        {
            if (!inventoryIn.getStackInSlot(k).func_190926_b())
            {
                return false;
            }
        }
    }

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

示例13: isInventoryEmpty

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
/**
 * Returns false if the specified IInventory contains any items
 */
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
    if (inventoryIn instanceof ISidedInventory)
    {
        ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
        int[] aint = isidedinventory.getSlotsForFace(side);

        for (int i : aint)
        {
            if (isidedinventory.getStackInSlot(i) != null)
            {
                return false;
            }
        }
    }
    else
    {
        int j = inventoryIn.getSizeInventory();

        for (int k = 0; k < j; ++k)
        {
            if (inventoryIn.getStackInSlot(k) != null)
            {
                return false;
            }
        }
    }

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

示例14: captureDroppedItems

import net.minecraft.inventory.IInventory; //導入方法依賴的package包/類
public static boolean captureDroppedItems(IHopper p_145891_0_)
{
    IInventory iinventory = getHopperInventory(p_145891_0_);

    if (iinventory != null)
    {
        EnumFacing enumfacing = EnumFacing.DOWN;

        if (isInventoryEmpty(iinventory, enumfacing))
        {
            return false;
        }

        if (iinventory instanceof ISidedInventory)
        {
            ISidedInventory isidedinventory = (ISidedInventory)iinventory;
            int[] aint = isidedinventory.getSlotsForFace(enumfacing);

            for (int i = 0; i < aint.length; ++i)
            {
                if (pullItemFromSlot(p_145891_0_, iinventory, aint[i], enumfacing))
                {
                    return true;
                }
            }
        }
        else
        {
            int j = iinventory.getSizeInventory();

            for (int k = 0; k < j; ++k)
            {
                if (pullItemFromSlot(p_145891_0_, iinventory, k, enumfacing))
                {
                    return true;
                }
            }
        }
    }
    else
    {
        for (EntityItem entityitem : func_181556_a(p_145891_0_.getWorld(), p_145891_0_.getXPos(), p_145891_0_.getYPos() + 1.0D, p_145891_0_.getZPos()))
        {
            if (putDropInInventoryAllSlots(p_145891_0_, entityitem))
            {
                return true;
            }
        }
    }

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


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