mojira.dev
MC-10025

Burn time indicator of a furnace not working correctly after reloading the world

The bug

When you start a furnace burning and then swap out what's in the fuel slot and save and quit, the next time you load the burn time indicator will glitch. The reason for this is that the NBT file for furnaces does not store the max fuel burn time and instead dynamically gets it from the fuel slot, which may no longer contain the same item as was used to initially fuel the furnace. This can be seen in the code snippet attached.

To reproduce

  1. Start furnace burning with a fuel other than a stick.

  2. Allow the burn time to visibly decrease.

  3. Swap the fuel with something that burns shorter than the original fuel.

  4. Save and quit.

  5. Reload the save.

  6. Open the furnace.

  7. The burn time indicator will have increased.

With particularly large differences (lava bucket to stick), the progress bar may wrap around the top of the screen and display twice (see

[media]

).

Fix

Rather than attempting to guess the total burn time of the original item, it should be saved too:

TileEntityFurnace

public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        this.furnaceItemStacks = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
        ItemStackHelper.loadAllItems(compound, this.furnaceItemStacks);
        this.furnaceBurnTime = compound.getShort("BurnTime");
        this.cookTime = compound.getShort("CookTime");
        this.totalCookTime = compound.getShort("CookTimeTotal");
        //this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks.get(1));
        this.currentItemBurnTime = compound.getShort("BurnTimeTotal"); // added

        if (compound.hasKey("CustomName", 8))
        {
            this.furnaceCustomName = compound.getString("CustomName");
        }
    }

    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setShort("BurnTime", (short)this.furnaceBurnTime);
        compound.setShort("CookTime", (short)this.cookTime);
        compound.setShort("CookTimeTotal", (short)this.totalCookTime);
        compound.setShort("BurnTimeTotal", (short)this.currentItemBurnTime); // added
        ItemStackHelper.saveAllItems(compound, this.furnaceItemStacks);

        if (this.hasCustomName())
        {
            compound.setString("CustomName", this.furnaceCustomName);
        }

        return compound;
    }

Linked issues

Attachments

Comments 20

Dean Baset

Unable to reproduce. Please provide a step by step list on how to reproduce. ie:
1. do this
2. now this
3. and finally this

Tails

Confirmed in 13w07a. Just a visuall glitch with the burn time indicator, the burning process is correctly finished after smelting the amount of items according to the fuel type.

Carl Lystad

The fuel source does not need to be swapped, either. Simply unloading the chunk and loading it again is enough to trigger the glitch.

I first noticed it when I used lava buckets to start a bunch of furnaces and went to the Nether to refill the buckets. When I came back, this glitch had appeared.

kbk

Can confirm in 1.5.2 using lava buckets. Apparently, empty bucket or its removal is being treated as if you were swapping the fuel.

kumasasa

Confirmed for 1.6.1 and block of coal

10 more comments
pulpetti

Can confirm for 20w29a

Sourrazz

Confirmed for 1.16.4

Brevort

Does this also occur when switching dimensions or unloading and reloading the chunks in ways other than reloading the world?

Never mind, that's MC-137146.

Avoma

Can confirm in 1.19.2.

j_p_smith

The broken GUI is fixed in 23w32a, but the burn time indicator is still incorrect.

Dimitriye Danilovic

Shugoh

Confirmed

Platform

Normal

Networking

furnace, rendering, smelting

Minecraft 1.4.7, Snapshot 13w07a, Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1, ..., 24w11a, 24w12a, 1.20.6, 1.21, 1.21.3

1.21.4 Pre-Release 2

Retrieved