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


Java ISidedInventory.getStackInSlot方法代碼示例

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


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

示例1: canInsertItemInto

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
protected static boolean canInsertItemInto(ItemStack item, ISidedInventory dest, EnumFacing destFace){
	if(item == null || item.getItem() == null || isLocked(dest)){
		return false;
	}
	int[] slots = dest.getSlotsForFace(destFace);
	for(int i = 0; i < slots.length; i++){
		int slot = slots[i];
		if(dest.canInsertItem(slot, item, destFace)){
			ItemStack destItem = dest.getStackInSlot(slot);
			if(destItem == null) {
				return true;
			} else {
				return ItemStack.areItemsEqual(item, destItem);
			}
		}
	}
	return false;
}
 
開發者ID:cyanobacterium,項目名稱:PowerAdvantageAPI,代碼行數:19,代碼來源:TileEntityConveyor.java

示例2: canInsert

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
private boolean canInsert(ItemStack item, EnumFacing f){
	TileEntity target = getWorld().getTileEntity(getPos().offset(f));
	if(target instanceof IInventory){
		EnumFacing side = f.getOpposite();
		ISidedInventory dt = InventoryWrapper.wrap((IInventory)target);
		int[] slots = dt.getSlotsForFace(side);
		for(int i = 0; i < slots.length; i++){
			int slot = slots[i];
			if(dt.canInsertItem(slot, item, side)){
				ItemStack targetSlot = dt.getStackInSlot(slot);
				if( (targetSlot == null) || 
						(ItemStack.areItemsEqual(item, targetSlot) 
								&& !targetSlot.getItem().isDamageable()
								&& targetSlot.stackSize < targetSlot.getMaxStackSize()
								&& targetSlot.stackSize < dt.getInventoryStackLimit())){
					return true;
				}
			}
		}
		return false;
	}else{
		return false;
	}
}
 
開發者ID:cyanobacterium,項目名稱:PowerAdvantageAPI,代碼行數:25,代碼來源:TileEntityOverflowFilter.java

示例3: extractItemStackFromInventory

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
public static ItemStack extractItemStackFromInventory(IInventory theInventory, int side) {

		ItemStack retStack = null;

		if (theInventory instanceof ISidedInventory) {
			ISidedInventory sidedInv = (ISidedInventory) theInventory;
			int slots[] = sidedInv.getAccessibleSlotsFromSide(side);
			for (int i = 0; i < slots.length && retStack == null; i++) {
				if (sidedInv.getStackInSlot(i) != null && sidedInv.canExtractItem(i, sidedInv.getStackInSlot(i), side)) {
					retStack = sidedInv.getStackInSlot(i).copy();
					sidedInv.setInventorySlotContents(i, null);
				}
			}
		} else {
			for (int i = 0; i < theInventory.getSizeInventory() && retStack == null; i++) {
				if (theInventory.getStackInSlot(i) != null) {
					retStack = theInventory.getStackInSlot(i).copy();
					theInventory.setInventorySlotContents(i, null);
				}
			}
		}
		if (retStack != null) {
			theInventory.onInventoryChanged();
		}
		return retStack;
	}
 
開發者ID:PaleoCrafter,項目名稱:R0b0ts,代碼行數:27,代碼來源:InventoryHelper.java

示例4: isInventoryFull

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

示例5: isInventoryEmpty

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

示例6: isInventoryFull

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

示例7: isInventoryFull

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

示例8: isInventoryEmpty

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

示例9: update

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
@Override
public void update(){
	super.update();
	if(!getWorld().isRemote){
		
		boolean powerChanged = (lastSyncPowerStored != getEnergyStored() && shouldDoWorkThisTick(5));
	    if(powerChanged) {
	      lastSyncPowerStored = getEnergyStored();
	      NBTTagCompound nbt = new NBTTagCompound();
	      nbt.setInteger("Power", getEnergyStored());
	      CrystalModNetwork.sendToAllAround(new PacketTileMessage(getPos(), "UpdatePower", nbt), this);
	    }
		
		ISidedInventory inv = getInventory();
		if(inv !=null){
			EnumFacing face = EnumFacing.getFront(facing);
			int[] slots = inv.getSlotsForFace(face.getOpposite());
			for(int i = 0; i < slots.length; i++){
				int s = slots[i];
				ItemStack stack = inv.getStackInSlot(s);
				if(ItemStackTools.isValid(stack)){
					if(canChargeItem(stack)){
						chargeItem(stack);
					}
				}
			}
		}
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:30,代碼來源:TileEntityInventoryCharger.java

示例10: func_152102_a

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
private boolean func_152102_a(IInventory p_152102_1_, int p_152102_2_)
{
    if (p_152102_1_ instanceof ISidedInventory && p_152102_2_ > -1)
    {
        ISidedInventory isidedinventory = (ISidedInventory)p_152102_1_;
        int[] aint = isidedinventory.getAccessibleSlotsFromSide(p_152102_2_);

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

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

        for (int k = 0; k < j; ++k)
        {
            ItemStack itemstack = p_152102_1_.getStackInSlot(k);

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

    return true;
}
 
開發者ID:jtrent238,項目名稱:PopularMMOS-EpicProportions-Mod,代碼行數:35,代碼來源:TileEntityBlockChristmasPresents_Red.java

示例11: func_152103_b

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
private static boolean func_152103_b(IInventory p_152103_0_, int p_152103_1_)
{
    if (p_152103_0_ instanceof ISidedInventory && p_152103_1_ > -1)
    {
        ISidedInventory isidedinventory = (ISidedInventory)p_152103_0_;
        int[] aint = isidedinventory.getAccessibleSlotsFromSide(p_152103_1_);

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

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

    return true;
}
 
開發者ID:jtrent238,項目名稱:PopularMMOS-EpicProportions-Mod,代碼行數:31,代碼來源:TileEntityBlockChristmasPresents_Red.java

示例12: isInventoryEmpty

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
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:r1chardj0n3s,項目名稱:pycode-minecraft,代碼行數:31,代碼來源:PyCodeBlockTileEntity.java

示例13: addToSidedInventory

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
private ItemStack addToSidedInventory(ISidedInventory inventory, int side, ItemStack stack)
{
    ItemStack adding = stack.copy();
    int[] accessibleSlots = inventory.getAccessibleSlotsFromSide(side);
    for (int i = 0; i < accessibleSlots.length && adding.stackSize > 0; i++)
    {
        int slot = accessibleSlots[i];
        ItemStack inSlot = inventory.getStackInSlot(slot);
        if (inSlot == null || inSlot.getItem() == null)
        {
            inventory.setInventorySlotContents(slot, adding.copy());
            adding.stackSize = 0;
        } else if (inSlot.isItemEqual(adding) && ItemStack.areItemStackTagsEqual(stack, inSlot))
        {
            int stackLimit = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit());
            int remaining = inSlot.stackSize + adding.stackSize - stackLimit;
            if (remaining > 0)
            {
                inSlot.stackSize = stackLimit;
                adding.stackSize = remaining;
            } else
            {
                inSlot.stackSize += adding.stackSize;
                adding.stackSize = 0;
            }
        }
    }
    return adding;
}
 
開發者ID:MrSpring,項目名稱:ToggleBlocks,代碼行數:30,代碼來源:TileEntityToggleBlock.java

示例14: getFromSidedInventory

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
private ItemStack getFromSidedInventory(ISidedInventory inventory, int side, ItemStack stack)
{
    ItemStack result = null;
    int[] accessibleSlots = inventory.getAccessibleSlotsFromSide(side);
    for (int i = 0; i < accessibleSlots.length && result == null; i++)
    {
        int slot = accessibleSlots[i];
        ItemStack inSlot = inventory.getStackInSlot(slot);
        if (inSlot != null && inSlot.isItemEqual(stack) && inSlot.stackSize > 0)
            result = inSlot;
    }
    return result;
}
 
開發者ID:MrSpring,項目名稱:ToggleBlocks,代碼行數:14,代碼來源:TileEntityToggleBlock.java

示例15: getTFromSidedInventory

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
private ItemStack getTFromSidedInventory(ISidedInventory inventory, int side, String toolType)
{
    ItemStack result = null;
    int[] accessibleSlots = inventory.getAccessibleSlotsFromSide(side);
    for (int slot : accessibleSlots)
    {
        ItemStack inSlot = inventory.getStackInSlot(slot);
        if (isItemTool(toolType, inSlot))
            result = inSlot;
    }
    return result;
}
 
開發者ID:MrSpring,項目名稱:ToggleBlocks,代碼行數:13,代碼來源:TileEntityToggleBlock.java


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