Jump to content

Custom furnace doesn't save items inside after closing MC (or exiting to menu)


Jeerdus

Recommended Posts

Good day once again,

I have a problem with Custom furnace.

After I put things inside the machine and then close Minecraft or exit to the menu, it doesn't save the things inside the furnace and also the fuel burn time.

If you'll need any source code, just say so.

FYI: I made one more furnace before and it works fine

Link to comment
Share on other sites

Here are my NBT functions from TileEntity file:

public void readFromNBT(NBTTagCompound nbttagcompound)
{
         super.readFromNBT(nbttagcompound);
         NBTTagList nbttaglist = nbttagcompound.getTagList("Items2");
         electrolysisItemStacks = new ItemStack[getSizeInventory()];
         for (int i = 0; i < nbttaglist.tagCount(); i++)
         {
                 NBTTagCompound nbttagcompound2 = (NBTTagCompound)nbttaglist.tagAt(i);
                 byte byte0 = nbttagcompound2.getByte("Slot2");
                 if (byte0 >= 0 && byte0 < electrolysisItemStacks.length)
                 {
                         electrolysisItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound2);
                 }
         }
         electrolysisBurnTime = nbttagcompound.getShort("BurnTime2");
         electrolysisCookTime = nbttagcompound.getShort("CookTime2");
         currentItemBurnTime = getItemBurnTime(electrolysisItemStacks[1]);
}

public void writeToNBT(NBTTagCompound nbttagcompound)
{
         super.writeToNBT(nbttagcompound);
         nbttagcompound.setShort("BurnTime2", (short)electrolysisBurnTime);
         nbttagcompound.setShort("CookTime2", (short)electrolysisCookTime);
         NBTTagList nbttaglist = new NBTTagList();
         for (int i = 0; i < electrolysisItemStacks.length; i++)
         {
                 if (electrolysisItemStacks[i] != null)
                 {
                         NBTTagCompound nbttagcompound2 = new NBTTagCompound();
                         nbttagcompound2.setByte("Slot2", (byte)i);
                         electrolysisItemStacks[i].writeToNBT(nbttagcompound2);
                         nbttaglist.appendTag(nbttagcompound2);
                 }
         }
         nbttagcompound.setTag("Items2", nbttaglist);
}

 

And here are my NBT functions from the previous machine:

public void readFromNBT(NBTTagCompound nbttagcompound)
{
         super.readFromNBT(nbttagcompound);
         NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
         cellingItemStacks = new ItemStack[getSizeInventory()];
         for (int i = 0; i < nbttaglist.tagCount(); i++)
         {
                 NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                 byte byte0 = nbttagcompound1.getByte("Slot");
                 if (byte0 >= 0 && byte0 < cellingItemStacks.length)
                 {
                         cellingItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                 }
         }
         cellingBurnTime = nbttagcompound.getShort("BurnTime");
         cellingCookTime = nbttagcompound.getShort("CookTime");
         currentItemBurnTime = getItemBurnTime(cellingItemStacks[1]);
}

public void writeToNBT(NBTTagCompound nbttagcompound)
{
         super.writeToNBT(nbttagcompound);
         nbttagcompound.setShort("BurnTime", (short)cellingBurnTime);
         nbttagcompound.setShort("CookTime", (short)cellingCookTime);
         NBTTagList nbttaglist = new NBTTagList();
         for (int i = 0; i < cellingItemStacks.length; i++)
         {
                 if (cellingItemStacks[i] != null)
                 {
                         NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                         nbttagcompound1.setByte("Slot", (byte)i);
                         cellingItemStacks[i].writeToNBT(nbttagcompound1);
                         nbttaglist.appendTag(nbttagcompound1);
                 }
         }
         nbttagcompound.setTag("Items", nbttaglist);
}

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.