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


Java TileEntityHopper.getInventoryAtLocation方法代碼示例

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


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

示例1: dispense

import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
protected void dispense(World par1World, int par2, int par3, int par4)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(par1World, par2, par3, par4);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int l = tileentitydispenser.getRandomStackFromInventory();

        if (l < 0)
        {
            par1World.playAuxSFX(1001, par2, par3, par4, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
            int i1 = par1World.getBlockMetadata(par2, par3, par4) & 7;
            IInventory iinventory = TileEntityHopper.getInventoryAtLocation(par1World, (double)(par2 + Facing.offsetsXForSide[i1]), (double)(par3 + Facing.offsetsYForSide[i1]), (double)(par4 + Facing.offsetsZForSide[i1]));
            ItemStack itemstack1;

            if (iinventory != null)
            {
                itemstack1 = TileEntityHopper.insertStack(iinventory, itemstack.copy().splitStack(1), Facing.oppositeSide[i1]);

                if (itemstack1 == null)
                {
                    itemstack1 = itemstack.copy();

                    if (--itemstack1.stackSize == 0)
                    {
                        itemstack1 = null;
                    }
                }
                else
                {
                    itemstack1 = itemstack.copy();
                }
            }
            else
            {
                itemstack1 = this.dropperDefaultBehaviour.dispense(blocksourceimpl, itemstack);

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

            tileentitydispenser.setInventorySlotContents(l, itemstack1);
        }
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:53,代碼來源:BlockDropper.java


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