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


Java ISidedInventory.getSlotsForFace方法代碼示例

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


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

示例1: putStackInInventoryAllSlots

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的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, IInventory stack, ItemStack side, @Nullable EnumFacing p_174918_3_)
{
    if (stack instanceof ISidedInventory && p_174918_3_ != null)
    {
        ISidedInventory isidedinventory = (ISidedInventory)stack;
        int[] aint = isidedinventory.getSlotsForFace(p_174918_3_);

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

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

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

示例2: canAccessSlot

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
public static boolean canAccessSlot(IInventory inv, int slot) {
    if (inv instanceof ISidedInventory) {
        ISidedInventory isi = (ISidedInventory) inv;
        //O(n). Ugh.
        for (EnumFacing face : EnumFacing.VALUES) {
            int[] slots = isi.getSlotsForFace(face);
            for (int j = 0; j < slots.length; j++) {
                if (slots[j] == slot) {
                    return true;
                }
            }
        }
    } else {
        return true;
    }
    return false;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:18,代碼來源:InvUtil.java

示例3: isValidItemFor

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
protected boolean isValidItemFor(ItemStack item, TileEntity target, EnumFacing side){
	if(item == null) return false;
	if(target instanceof IInventory){
		BlockPos targetPos = target.getPos();
		ISidedInventory dt = InventoryWrapper.wrap(TileEntityHopper.getInventoryAtPosition(getWorld(),targetPos.getX(), targetPos.getY(), targetPos.getZ()));
		int[] slots = dt.getSlotsForFace(side);
		for(int i = 0; i < slots.length; i++){
			int slot = slots[i];
			if(dt.canInsertItem(slot, item, side)){
				return true;
			}
		}
		return false;
	}else{
		return true;
	}
}
 
開發者ID:cyanobacterium,項目名稱:PowerAdvantageAPI,代碼行數:18,代碼來源:TileEntityConveyorFilter.java

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

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

示例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 = 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

示例7: putStackInInventoryAllSlots

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

示例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 = 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

示例9: putStackInInventoryAllSlots

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的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, @Nullable 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:F1r3w477,項目名稱:CustomWorldGen,代碼行數:33,代碼來源:TileEntityHopper.java

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

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

示例12: 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).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: 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

示例14: InventoryRange

import net.minecraft.inventory.ISidedInventory; //導入方法依賴的package包/類
public InventoryRange(IInventory inv, EnumFacing side) {
    this.inv = inv;
    this.face = side;
    if (inv instanceof ISidedInventory) {
        sidedInv = (ISidedInventory) inv;
        slots = sidedInv.getSlotsForFace(face);
    } else {
        slots = new int[inv.getSizeInventory()];
        for (int i = 0; i < slots.length; i++) {
            slots[i] = i;
        }
    }
}
 
開發者ID:TheCBProject,項目名稱:CodeChickenLib,代碼行數:14,代碼來源:InventoryRange.java

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


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