Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-10025

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.4.7, Snapshot 13w07a, Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1, Minecraft 1.5.2, Minecraft 1.6.1, Minecraft 1.6.2, Minecraft 13w36a, Minecraft 13w36b, Minecraft 1.7.4, Minecraft 1.7.10, Minecraft 1.10.2, Minecraft 16w35a, Minecraft 16w36a, Minecraft 16w38a, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w48a, Minecraft 17w50a, Minecraft 18w01a, Minecraft 18w03b, Minecraft 18w06a, Minecraft 18w09a, Minecraft 18w10d, Minecraft 18w20c, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w14a, Minecraft 1.14.3, 1.14.4, 19w39a, 1.15 Pre-release 6, 1.15.1, 20w07a, 1.16, 1.16.1, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 1, 1.16.4 Pre-release 2, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05a, 21w05b, 21w06a, 21w14a, 21w15a, 21w16a, 21w17a, 21w18a, 21w19a, 21w20a, 1.17 Pre-release 1, 1.17 Pre-release 4, 1.17, 1.17.1 Pre-release 1, 1.17.1, 21w37a, 21w41a, 1.18 Pre-release 7, 1.18 Pre-release 8, 1.19, 1.19.2, 1.19.3, 23w03a, 23w04a, 23w05a, 23w06a, 23w07a, 1.19.4 Pre-release 3, 1.19.4, 23w13a, 23w14a, 1.20 Pre-release 1, 1.20 Pre-release 2, 1.20 Pre-release 4, 1.20.1, 23w31a, 23w32a, 23w33a, 23w35a, 1.20.2 Pre-release 1, 1.20.2 Pre-release 2, 1.20.2, 23w40a, 23w41a, 23w42a, 23w44a, 1.20.4, 24w03b, 24w04a, 24w05a, 24w11a, 24w12a, 1.20.6, 1.21, 1.21.3
    • Confirmed
    • Networking
    • Normal
    • Platform

      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 2016-09-19_14.59.18.png).

      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;
          }
      

        1. 2016-09-19_14.59.18.png
          2016-09-19_14.59.18.png
          145 kB
        2. 23w31a.png
          23w31a.png
          207 kB
        3. Snippet.txt
          0.8 kB

            HugoHagglund [Mojang] SHugoh
            dimitriye98 Dimitriye Danilovic
            Votes:
            40 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              CHK: