当前位置: 首页>>代码示例>>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;未经允许,请勿转载。