Java Code Examples for net.minecraft.item.Item.getContainerItem()

The following are Jave code examples for showing how to use getContainerItem() of the net.minecraft.item.Item class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Randores2   File: CraftiniumForgeTileEntity.java   View Source Code Vote up 4 votes
@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();
    }
}
 
Example 2
Project: Backmemed   File: TileEntityFurnace.java   View Source Code Vote up 4 votes
/**
 * 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();
    }
}