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


Java IInventory.getStackInSlot方法代码示例

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


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

示例1: findStack

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
@Nullable
public BeltGetter findStack(EntityPlayer player)
{
    IInventory playerInv = player.inventory;
    for (int i = 0; i < playerInv.getSizeInventory(); i++)
    {
        ItemStack inSlot = playerInv.getStackInSlot(i);
        if (inSlot.getCount() > 0)
        {
            if (inSlot.getItem() instanceof ItemToolBelt)
            {
                return new InventoryBeltGetter(player, i);
            }
        }
    }

    return null;
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:19,代码来源:BeltFinder.java

示例2: getStackWithInventory

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public static ItemStack getStackWithInventory(IInventory inventory, IBlockState state) {
	if (inventory != null && inventory.getSizeInventory() > 0 && state != null) {
		ItemStack stack = new ItemStack(Item.getItemFromBlock(state.getBlock()));
		NBTTagCompound stackNBT = new NBTTagCompound();//stack.getSubCompound("BlockEntityTag", true);
		NBTTagList stackList = new NBTTagList();
		for (int i = 0; i < inventory.getSizeInventory(); i++) {
			if (inventory.getStackInSlot(i) == null) {
				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,代码行数:21,代码来源:ChestUtils.java

示例3: arrowNock

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
@SubscribeEvent
public void arrowNock(ArrowNockEvent event) {
	if (event.result == null)
		return;
	IInventory invt = event.entityPlayer.inventory;
	for (int i = 0; i < invt.getSizeInventory(); i++) {
		ItemStack stack = invt.getStackInSlot(i);
		if (stack == null || stack.stackSize <= 0)
			continue;
		if (stack.getItem() == Items.arrow)
			return;
		if (stack.getItem() == ModItems.tipped_arrow) {
			event.setCanceled(true);
			event.entityPlayer.setItemInUse(event.result, event.result.getItem().getMaxItemUseDuration(event.result));
			return;
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:19,代码来源:ServerEventHandler.java

示例4: pullItemFromSlot

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
 * Pulls from the specified slot in the inventory and places in any available slot in the hopper. Returns true if
 * the entire stack was moved
 */
private static boolean pullItemFromSlot(IHopper hopper, IInventory inventoryIn, int index, EnumFacing direction)
{
    ItemStack itemstack = inventoryIn.getStackInSlot(index);

    if (itemstack != null && canExtractItemFromSlot(inventoryIn, itemstack, index, direction))
    {
        ItemStack itemstack1 = itemstack.copy();
        ItemStack itemstack2 = putStackInInventoryAllSlots(hopper, inventoryIn.decrStackSize(index, 1), (EnumFacing)null);

        if (itemstack2 == null || itemstack2.stackSize == 0)
        {
            inventoryIn.markDirty();
            return true;
        }

        inventoryIn.setInventorySlotContents(index, itemstack1);
    }

    return false;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:25,代码来源:TileEntityHopper.java

示例5: pushItemIInventory

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
protected boolean pushItemIInventory(IInventory inventory, int slot) {
	if(blockItemStack.stackSize > 1) {
		ItemStack oldStack = blockItemStack.copy();
		ItemStack newStack = blockItemStack.splitStack(1);
		
		if(inventory.getStackInSlot(slot) == null) {
			if(debug)
				FMLLog.log(Level.INFO, "fF");
			inventory.setInventorySlotContents(slot, newStack.copy());
			newStack = null;
			markDirty = true;
		} else if(inventory.getStackInSlot(slot).getItem() == newStack.getItem() && inventory.getStackInSlot(slot).stackSize < inventory.getInventoryStackLimit() && inventory.getStackInSlot(slot).stackSize < inventory.getStackInSlot(slot).getMaxStackSize()) {
			if(debug)
				FMLLog.log(Level.INFO, "fG");
			newStack.stackSize += inventory.getStackInSlot(slot).stackSize;
			inventory.setInventorySlotContents(slot, newStack.copy());
			newStack = null;
			markDirty = true;
		} else {
			if(debug)
				FMLLog.log(Level.INFO, "fGa");
		}
		
		if(newStack == null || newStack.stackSize == 0) {
			if(debug)
				FMLLog.log(Level.INFO, "fDa");
			markDirty = true;
		} else {
			blockItemStack = oldStack;
		}
	}
	return markDirty;
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:34,代码来源:TileEntityGrabberFiltering.java

示例6: getItemStack

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
private static ItemStack getItemStack(IInventory inventory, Item item)
{
	for (int index = 0; index < inventory.getSizeInventory(); index++)
	{
		if(inventory.getStackInSlot(index) == null)
			continue;
		
		if(inventory.getStackInSlot(index).getItem() == item)
			return inventory.getStackInSlot(index);
	}
	
	return null;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:14,代码来源:CraftingHandler.java

示例7: isSimilar

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
private boolean isSimilar(IInventory handler, ItemStack stack) {
    Set<Integer> ores = getOres(stack);
    for (int i = 0 ; i < handler.getSizeInventory() ; i++) {
        ItemStack s = handler.getStackInSlot(i);
        if (matchStack(stack, ores, s)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:McJty,项目名称:interactionwheel,代码行数:11,代码来源:DumpSimilarInventoryAction.java

示例8: getFirstItem

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public static ItemStack getFirstItem(IInventory inventory, Predicate<ItemStack> pred) {
	
		for (int i = 0; i<inventory.getSizeInventory(); i++) {
			ItemStack stack=inventory.getStackInSlot(i);
			if (!stack.isEmpty() && pred.apply(stack))
				return stack;
		}
		return ItemStack.EMPTY;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:10,代码来源:TF2Util.java

示例9: isInventoryFull

import net.minecraft.inventory.IInventory; //导入方法依赖的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

示例10: copyProps

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public static void copyProps(IInventory craftMatrix, ItemStack newItem)
{
	// Step 1, find the actual item (It's possible that this is not a reloading action, meaning there is no weapon to copy the name from)
	
	int slot = 0;
	
	while (slot < 9)
	{
		ItemStack stack = craftMatrix.getStackInSlot(slot);
		
		if (stack != null && stack.getItem() instanceof _WeaponBase)	// Found it. Does it have a name tag?
		{
			if (stack.hasDisplayName() && !newItem.hasDisplayName()) { newItem.setStackDisplayName(stack.getDisplayName()); }
			// else, has no custom display name or the new item already has one. Fine with me either way.
			
			// Upgrades
			if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("hasEmeraldMuzzle"))
			{
				if (!newItem.hasTagCompound()) { newItem.setTagCompound(new NBTTagCompound()); }	// Init
				newItem.getTagCompound().setBoolean("hasEmeraldMuzzle", true);						// Keeping the upgrade
			}
			
			return;	// Either way, we're done here
		}
		// else, either doesn't exist or not what I'm looking for
		
		slot += 1;
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:30,代码来源:Helper.java

示例11: 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

示例12: pushItemIInventory

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
protected boolean pushItemIInventory(IInventory inventory, int slot) {
	if(inventory.getStackInSlot(slot) == null) {
		if(debug)
			FMLLog.log(Level.INFO, "gF");
		inventory.setInventorySlotContents(slot, blockItemStack.copy());
		blockItemStack = null;
		markDirty = true;
	} else {
		if(debug)
			FMLLog.log(Level.INFO, "gGa");
	}
	return markDirty;
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:14,代码来源:TileEntityGrabberGreedy.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 = 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:SkidJava,项目名称:BaseClient,代码行数:34,代码来源:TileEntityHopper.java

示例14: extract

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
public static Pair<ItemStack, Integer> extract(TileEntity tile, EnumFacing from, int[] col, IInventory inv, boolean fullStack) {

		if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, from)) {
			IItemHandlerModifiable handler = (IItemHandlerModifiable) tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, from);
			if (handler != null) {
				int invSize = handler.getSlots();

				for (int i = 0; i < invSize; i++) {
					ItemStack current = handler.getStackInSlot(i);

					for (int j = 0; j < inv.getSizeInventory(); j++) {
						ItemStack stack = inv.getStackInSlot(j);
						int color = -1;
						if (stack != null && stack != ItemStack.EMPTY && stack.getItem() != Items.AIR) {
							if (areItemStacksEqual(stack, current)) {
								int column = j >= 0 && j <= 3 ? 0 : j >= 4 && j <= 7 ? 1 : j >= 8 && j <= 11 ? 2 : j >= 12 && j <= 15 ? 3 : j >= 16 || j <= 19 ? 4 : -1;

								if (column == -1)
									return null;

								color = col[column];

								if (current != null && !current.isEmpty() && current.getItem() != Items.AIR) {
									ItemStack extracted = handler.extractItem(i, !fullStack ? 1 : current.getCount(), false);
									return Pair.of(extracted, color);
								}
							}
						}
					}

				}
			}
		} // TODO: TileEntities that don't have capabilities - needs testing

		return Pair.of(ItemStack.EMPTY, -1);
	}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:37,代码来源:TubeUtil.java

示例15: insertStack

import net.minecraft.inventory.IInventory; //导入方法依赖的package包/类
/**
 * Insert the specified stack to the specified inventory and return any leftover items
 */
private static ItemStack insertStack(IInventory inventoryIn, ItemStack stack, int index, EnumFacing side)
{
    ItemStack itemstack = inventoryIn.getStackInSlot(index);

    if (canInsertItemInSlot(inventoryIn, stack, index, side))
    {
        boolean flag = false;

        if (itemstack == null)
        {
            inventoryIn.setInventorySlotContents(index, stack);
            stack = null;
            flag = true;
        }
        else if (canCombine(itemstack, stack))
        {
            int i = stack.getMaxStackSize() - itemstack.stackSize;
            int j = Math.min(stack.stackSize, i);
            stack.stackSize -= j;
            itemstack.stackSize += j;
            flag = j > 0;
        }

        if (flag)
        {
            if (inventoryIn instanceof TileEntityHopper)
            {
                TileEntityHopper tileentityhopper = (TileEntityHopper)inventoryIn;

                if (tileentityhopper.mayTransfer())
                {
                    tileentityhopper.setTransferCooldown(8);
                }

                inventoryIn.markDirty();
            }

            inventoryIn.markDirty();
        }
    }

    return stack;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:47,代码来源:TileEntityHopper.java


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