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


Java TileEntityFurnace.getStackInSlot方法代碼示例

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


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

示例1: sendEnergyToFurnace

import net.minecraft.tileentity.TileEntityFurnace; //導入方法依賴的package包/類
protected void sendEnergyToFurnace(TileEntityFurnace pFurnace) {
    final int FURNACE_COOKING_TICKS = 200;
    final int FURNACE_COOKING_ENERGY = FURNACE_COOKING_TICKS * ModConfiguration.getFurnaceUpgradeHeatingConsumption();

    if (mFurnaceEnergyBuffer < FURNACE_COOKING_ENERGY) {
        mFurnaceEnergyBuffer += getTileEntity().getEnergyStorage().extractEnergy(FURNACE_COOKING_ENERGY - mFurnaceEnergyBuffer, false);
    }

    // Is there anything to smell?
    if (pFurnace.getStackInSlot(0) != null && pFurnace.furnaceBurnTime < FURNACE_COOKING_TICKS) {
        int burnTicksAvailable = mFurnaceEnergyBuffer / ModConfiguration.getFurnaceUpgradeHeatingConsumption();
        if (burnTicksAvailable >= FURNACE_COOKING_TICKS) {
            if (pFurnace.furnaceBurnTime == 0) {
                // Add 1 as first tick is not counted in the burning process.
                pFurnace.furnaceBurnTime += 1;
                BlockFurnace.updateFurnaceBlockState(pFurnace.furnaceBurnTime > 0, pFurnace.getWorldObj(), pFurnace.xCoord, pFurnace.yCoord, pFurnace.zCoord);
            }
            pFurnace.furnaceBurnTime += FURNACE_COOKING_TICKS;
            mFurnaceEnergyBuffer -= FURNACE_COOKING_TICKS * ModConfiguration.getFurnaceUpgradeHeatingConsumption();
        }
    }
}
 
開發者ID:Nauktis,項目名稱:SolarFlux,代碼行數:23,代碼來源:SimpleEnergyDispenserModule.java

示例2: tryMergeStackIntoSlot

import net.minecraft.tileentity.TileEntityFurnace; //導入方法依賴的package包/類
public static void tryMergeStackIntoSlot(TileEntityFurnace furnace, EntityPlayer entityPlayer, int playerSlot, int furnaceSlot) {
  ItemStack current = furnace.getStackInSlot(furnaceSlot);
  ItemStack held = entityPlayer.inventory.getStackInSlot(playerSlot);
  boolean success = false;
  World worldObj = entityPlayer.getEntityWorld();
  if (current.isEmpty()) {
    // just done
    if (worldObj.isRemote == false) {
      furnace.setInventorySlotContents(furnaceSlot, held.copy());
      held = ItemStack.EMPTY;
    }
    success = true;
  }
  else if (held.isItemEqual(current)) {
    //ModMain.logger.info("slot is NOT empty and they match, current old:" + current.stackSize);
    // merging updates the stack size numbers in both furnace and in players
    success = true;
    if (worldObj.isRemote == false) {
      UtilItemStack.mergeItemsBetweenStacks(held, current);
    }
  }
  if (success) {
    if (worldObj.isRemote == false) {
      if (!held.isEmpty() && held.getCount() == 0) {// so now we just fix if something is size zero
        held = ItemStack.EMPTY;
      }
      entityPlayer.inventory.setInventorySlotContents(playerSlot, held);
      entityPlayer.inventory.markDirty();
    }
    UtilSound.playSound(entityPlayer, SoundEvents.ENTITY_ITEM_PICKUP);
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:33,代碼來源:UtilFurnace.java

示例3: breakBlock

import net.minecraft.tileentity.TileEntityFurnace; //導入方法依賴的package包/類
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
    if (!field_149934_M)
    {
        TileEntityFurnace var7 = (TileEntityFurnace)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

        if (var7 != null)
        {
            for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
            {
                ItemStack var9 = var7.getStackInSlot(var8);

                if (var9 != null)
                {
                    float var10 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
                    float var11 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
                    float var12 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;

                    while (var9.stackSize > 0)
                    {
                        int var13 = this.field_149933_a.nextInt(21) + 10;

                        if (var13 > var9.stackSize)
                        {
                            var13 = var9.stackSize;
                        }

                        var9.stackSize -= var13;
                        EntityItem var14 = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + var10), (double)((float)p_149749_3_ + var11), (double)((float)p_149749_4_ + var12), new ItemStack(var9.getItem(), var13, var9.getItemDamage()));

                        if (var9.hasTagCompound())
                        {
                            var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
                        }

                        float var15 = 0.05F;
                        var14.motionX = (double)((float)this.field_149933_a.nextGaussian() * var15);
                        var14.motionY = (double)((float)this.field_149933_a.nextGaussian() * var15 + 0.2F);
                        var14.motionZ = (double)((float)this.field_149933_a.nextGaussian() * var15);
                        p_149749_1_.spawnEntityInWorld(var14);
                    }
                }
            }

            p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
        }
    }

    super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:51,代碼來源:BlockFurnace.java

示例4: breakBlock

import net.minecraft.tileentity.TileEntityFurnace; //導入方法依賴的package包/類
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
    if (!field_149934_M)
    {
        TileEntityFurnace tileentityfurnace = (TileEntityFurnace)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

        if (tileentityfurnace != null)
        {
            for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
            {
                ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);

                if (itemstack != null)
                {
                    float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
                    float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
                    float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;

                    while (itemstack.stackSize > 0)
                    {
                        int j1 = this.field_149933_a.nextInt(21) + 10;

                        if (j1 > itemstack.stackSize)
                        {
                            j1 = itemstack.stackSize;
                        }

                        itemstack.stackSize -= j1;
                        EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

                        if (itemstack.hasTagCompound())
                        {
                            entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                        }

                        float f3 = 0.05F;
                        entityitem.motionX = (double)((float)this.field_149933_a.nextGaussian() * f3);
                        entityitem.motionY = (double)((float)this.field_149933_a.nextGaussian() * f3 + 0.2F);
                        entityitem.motionZ = (double)((float)this.field_149933_a.nextGaussian() * f3);
                        p_149749_1_.spawnEntityInWorld(entityitem);
                    }
                }
            }

            p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
        }
    }

    super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:51,代碼來源:BlockFurnace.java

示例5: breakBlock

import net.minecraft.tileentity.TileEntityFurnace; //導入方法依賴的package包/類
/**
 * Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
 * different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
 * metadata
 */
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
{
    if (!keepFurnaceInventory)
    {
        TileEntityFurnace tileentityfurnace = (TileEntityFurnace)par1World.getBlockTileEntity(par2, par3, par4);

        if (tileentityfurnace != null)
        {
            for (int j1 = 0; j1 < tileentityfurnace.getSizeInventory(); ++j1)
            {
                ItemStack itemstack = tileentityfurnace.getStackInSlot(j1);

                if (itemstack != null)
                {
                    float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
                    float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
                    float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;

                    while (itemstack.stackSize > 0)
                    {
                        int k1 = this.furnaceRand.nextInt(21) + 10;

                        if (k1 > itemstack.stackSize)
                        {
                            k1 = itemstack.stackSize;
                        }

                        itemstack.stackSize -= k1;
                        EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));

                        if (itemstack.hasTagCompound())
                        {
                            entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                        }

                        float f3 = 0.05F;
                        entityitem.motionX = (double)((float)this.furnaceRand.nextGaussian() * f3);
                        entityitem.motionY = (double)((float)this.furnaceRand.nextGaussian() * f3 + 0.2F);
                        entityitem.motionZ = (double)((float)this.furnaceRand.nextGaussian() * f3);
                        par1World.spawnEntityInWorld(entityitem);
                    }
                }
            }

            par1World.func_96440_m(par2, par3, par4, par5);
        }
    }

    super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:56,代碼來源:BlockFurnace.java


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