| 809 | |
| 810 | |
| 811 | void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE * a_BlockTypes, NIBBLETYPE * a_BlockMetas) |
| 812 | { |
| 813 | ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); |
| 814 | int x, y, z; |
| 815 | if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z)) |
| 816 | { |
| 817 | return; |
| 818 | } |
| 819 | int Items = a_NBT.FindChildByName(a_TagIdx, "Items"); |
| 820 | if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List)) |
| 821 | { |
| 822 | return; // Make it an empty furnace - the chunk loader will provide an empty cFurnaceEntity for this |
| 823 | } |
| 824 | |
| 825 | // Convert coords to relative: |
| 826 | int RelX = x; |
| 827 | int RelZ = z; |
| 828 | int ChunkX, ChunkZ; |
| 829 | cChunkDef::AbsoluteToRelative(RelX, y, RelZ, ChunkX, ChunkZ); |
| 830 | |
| 831 | // Create the furnace entity, with proper BlockType and BlockMeta info: |
| 832 | BLOCKTYPE BlockType = cChunkDef::GetBlock(a_BlockTypes, RelX, y, RelZ); |
| 833 | NIBBLETYPE BlockMeta = cChunkDef::GetNibble(a_BlockMetas, RelX, y, RelZ); |
| 834 | std::auto_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(x, y, z, BlockType, BlockMeta, m_World)); |
| 835 | |
| 836 | // Load slots: |
| 837 | for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child)) |
| 838 | { |
| 839 | int Slot = a_NBT.FindChildByName(Child, "Slot"); |
| 840 | if ((Slot < 0) || (a_NBT.GetType(Slot) != TAG_Byte)) |
| 841 | { |
| 842 | continue; |
| 843 | } |
| 844 | cItem Item; |
| 845 | if (LoadItemFromNBT(Item, a_NBT, Child)) |
| 846 | { |
| 847 | Furnace->SetSlot(a_NBT.GetByte(Slot), Item); |
| 848 | } |
| 849 | } // for itr - ItemDefs[] |
| 850 | |
| 851 | // Load burn time: |
| 852 | int BurnTime = a_NBT.FindChildByName(a_TagIdx, "BurnTime"); |
| 853 | if (BurnTime >= 0) |
| 854 | { |
| 855 | Int16 bt = a_NBT.GetShort(BurnTime); |
| 856 | // Anvil doesn't store the time that the fuel can burn. We simply "reset" the current value to be the 100% |
| 857 | Furnace->SetBurnTimes(bt, 0); |
| 858 | } |
| 859 | |
| 860 | // Load cook time: |
| 861 | int CookTime = a_NBT.FindChildByName(a_TagIdx, "CookTime"); |
| 862 | if (CookTime >= 0) |
| 863 | { |
| 864 | Int16 ct = a_NBT.GetShort(CookTime); |
| 865 | // Anvil doesn't store the time that an item takes to cook. We simply use the default - 10 seconds (200 ticks) |
| 866 | Furnace->SetCookTimes(200, ct); |
| 867 | } |
| 868 |
nothing calls this directly
no test coverage detected