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


Java Item.getContainerItem方法代碼示例

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


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

示例1: update

import net.minecraft.item.Item; //導入方法依賴的package包/類
@Override
public void update() {
    boolean needsSave = false;
    boolean burning = this.isBurning();


    if (this.isBurning()) {
        this.furnaceBurnTime--;

    }

    if (!this.world.isRemote) {
        ItemStack fuel = this.fuel.getStackInSlot(0);
        ItemStack input = this.input.getStackInSlot(0);
        if (this.totalCookTime == 0 && this.canSmelt()) {
            this.totalCookTime = this.getCookTime(input);
            needsSave = true;
        }
        if (this.isBurning() || (!fuel.isEmpty() && !input.isEmpty())) {
            if (!this.isBurning() && this.canSmelt()) {
                this.furnaceBurnTime = this.getBurnTime(fuel);
                this.currentItemBurnTime = this.furnaceBurnTime;
                if (this.isBurning()) {
                    needsSave = true;
                    if (!fuel.isEmpty()) {
                        Item item = fuel.getItem();
                        fuel.shrink(1);
                        if (fuel.isEmpty()) {
                            ItemStack container = item.getContainerItem(fuel);
                            this.fuel.setStackInSlot(0, container);
                        }
                    }
                }
            }

            if (this.isBurning() && this.canSmelt()) {
                this.cookTime++;
                if (this.cookTime >= this.totalCookTime) {
                    this.cookTime = 0;
                    this.totalCookTime = this.getCookTime(input);
                    this.smelt();
                    needsSave = true;
                }
            } else {
                this.cookTime = 0;
            }
        } else if (!this.isBurning() && this.cookTime > 0) {
            this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime);
        }

        if (burning != this.isBurning()) {
            needsSave = true;
            CraftiniumForge.setState(this.isBurning(), this.world, this.pos);
        }
    }

    if (needsSave) {
        this.markDirty();
    }
}
 
開發者ID:Randores,項目名稱:Randores2,代碼行數:61,代碼來源:CraftiniumForgeTileEntity.java

示例2: update

import net.minecraft.item.Item; //導入方法依賴的package包/類
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    boolean flag = this.isBurning();
    boolean flag1 = false;

    if (this.isBurning())
    {
        --this.furnaceBurnTime;
    }

    if (!this.world.isRemote)
    {
        ItemStack itemstack = (ItemStack)this.furnaceItemStacks.get(1);

        if (this.isBurning() || !itemstack.func_190926_b() && !((ItemStack)this.furnaceItemStacks.get(0)).func_190926_b())
        {
            if (!this.isBurning() && this.canSmelt())
            {
                this.furnaceBurnTime = getItemBurnTime(itemstack);
                this.currentItemBurnTime = this.furnaceBurnTime;

                if (this.isBurning())
                {
                    flag1 = true;

                    if (!itemstack.func_190926_b())
                    {
                        Item item = itemstack.getItem();
                        itemstack.func_190918_g(1);

                        if (itemstack.func_190926_b())
                        {
                            Item item1 = item.getContainerItem();
                            this.furnaceItemStacks.set(1, item1 == null ? ItemStack.field_190927_a : new ItemStack(item1));
                        }
                    }
                }
            }

            if (this.isBurning() && this.canSmelt())
            {
                ++this.cookTime;

                if (this.cookTime == this.totalCookTime)
                {
                    this.cookTime = 0;
                    this.totalCookTime = this.getCookTime((ItemStack)this.furnaceItemStacks.get(0));
                    this.smeltItem();
                    flag1 = true;
                }
            }
            else
            {
                this.cookTime = 0;
            }
        }
        else if (!this.isBurning() && this.cookTime > 0)
        {
            this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime);
        }

        if (flag != this.isBurning())
        {
            flag1 = true;
            BlockFurnace.setState(this.isBurning(), this.world, this.pos);
        }
    }

    if (flag1)
    {
        this.markDirty();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:77,代碼來源:TileEntityFurnace.java


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