diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-20 13:41:44 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-20 13:41:44 +0200 |
commit | 8dd5fe507083dd390742d782325ef3754f32fd59 (patch) | |
tree | 1918df5fedd7f3ec21a72dcc85d1e898fb18801e /source/WorldStorage/WSSAnvil.cpp | |
parent | Implemented hopper output (diff) | |
download | cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.tar cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.tar.gz cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.tar.bz2 cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.tar.lz cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.tar.xz cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.tar.zst cuberite-8dd5fe507083dd390742d782325ef3754f32fd59.zip |
Diffstat (limited to '')
-rw-r--r-- | source/WorldStorage/WSSAnvil.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp index f0b0113da..8f23cc773 100644 --- a/source/WorldStorage/WSSAnvil.cpp +++ b/source/WorldStorage/WSSAnvil.cpp @@ -331,7 +331,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT cEntityList Entities; cBlockEntityList BlockEntities; LoadEntitiesFromNBT (Entities, a_NBT, a_NBT.FindChildByName(Level, "Entities")); - LoadBlockEntitiesFromNBT(BlockEntities, a_NBT, a_NBT.FindChildByName(Level, "TileEntities")); + LoadBlockEntitiesFromNBT(BlockEntities, a_NBT, a_NBT.FindChildByName(Level, "TileEntities"), BlockTypes, MetaData); bool IsLightValid = (a_NBT.FindChildByName(Level, "MCSIsLightValid") > 0); @@ -539,7 +539,7 @@ void cWSSAnvil::LoadEntitiesFromNBT(cEntityList & a_Entities, const cParsedNBT & -void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) +void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE * a_BlockTypes, NIBBLETYPE * a_BlockMetas) { if ((a_TagIdx < 0) || (a_NBT.GetType(a_TagIdx) != TAG_List)) { @@ -567,7 +567,7 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con } else if (strncmp(a_NBT.GetData(sID), "Furnace", a_NBT.GetDataLength(sID)) == 0) { - LoadFurnaceFromNBT(a_BlockEntities, a_NBT, Child); + LoadFurnaceFromNBT(a_BlockEntities, a_NBT, Child, a_BlockTypes, a_BlockMetas); } else if (strncmp(a_NBT.GetData(sID), "Hopper", a_NBT.GetDataLength(sID)) == 0) { @@ -737,7 +737,7 @@ void cWSSAnvil::LoadDropperFromNBT(cBlockEntityList & a_BlockEntities, const cPa -void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) +void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE * a_BlockTypes, NIBBLETYPE * a_BlockMetas) { ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); int x, y, z; @@ -750,7 +750,19 @@ void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cPa { return; // Make it an empty furnace - the chunk loader will provide an empty cFurnaceEntity for this } - std::auto_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(x, y, z, m_World)); + + // Convert coords to relative: + int RelX = x; + int RelZ = z; + int ChunkX, ChunkZ; + cChunkDef::AbsoluteToRelative(RelX, y, RelZ, ChunkX, ChunkZ); + + // Create the furnace entity, with proper BlockType and BlockMeta info: + BLOCKTYPE BlockType = cChunkDef::GetBlock(a_BlockTypes, RelX, y, RelZ); + NIBBLETYPE BlockMeta = cChunkDef::GetNibble(a_BlockMetas, RelX, y, RelZ); + std::auto_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(x, y, z, BlockType, BlockMeta, m_World)); + + // Load slots: for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child)) { int Slot = a_NBT.FindChildByName(Child, "Slot"); @@ -764,6 +776,8 @@ void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cPa Furnace->SetSlot(a_NBT.GetByte(Slot), Item); } } // for itr - ItemDefs[] + + // Load burn time: int BurnTime = a_NBT.FindChildByName(a_TagIdx, "BurnTime"); if (BurnTime >= 0) { @@ -771,6 +785,8 @@ void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cPa // Anvil doesn't store the time that the fuel can burn. We simply "reset" the current value to be the 100% Furnace->SetBurnTimes(bt, 0); } + + // Load cook time: int CookTime = a_NBT.FindChildByName(a_TagIdx, "CookTime"); if (CookTime >= 0) { @@ -778,6 +794,8 @@ void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cPa // Anvil doesn't store the time that an item takes to cook. We simply use the default - 10 seconds (200 ticks) Furnace->SetCookTimes(200, ct); } + + // Restart cooking: Furnace->ContinueCooking(); a_BlockEntities.push_back(Furnace.release()); } |